Skip to content

Commit 74c47f3

Browse files
authored
Merge pull request #720 from l1b0k/feat/code
openapi: adapt the QuotaExceeded.PrivateIpAddress code
2 parents 25e012a + 2e90d62 commit 74c47f3

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

pkg/aliyun/client/errors/errors.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const (
1717
// Reference: https://help.aliyun.com/document_detail/85917.html
1818
InvalidVSwitchIDIPNotEnough = "InvalidVSwitchId.IpNotEnough"
1919

20+
QuotaExceededPrivateIPAddress = "QuotaExceeded.PrivateIpAddress"
21+
2022
// ErrEniPerInstanceLimitExceeded CreateNetworkInterfaces const error message
2123
// Reference: https://help.aliyun.com/document_detail/85917.html
2224
ErrEniPerInstanceLimitExceeded = "EniPerInstanceLimitExceeded"

pkg/controller/multi-ip/node/pool.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ func (n *ReconcileNode) createENI(ctx context.Context, node *networkv1beta1.Node
11661166

11671167
result, err := n.aliyun.CreateNetworkInterface(ctx, typeOption, createOpts)
11681168
if err != nil {
1169-
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough) {
1169+
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough, apiErr.QuotaExceededPrivateIPAddress) {
11701170
// block
11711171
n.vswpool.Block(createOpts.NetworkInterfaceOptions.VSwitchID)
11721172
}
@@ -1233,7 +1233,7 @@ func (n *ReconcileNode) assignIP(ctx context.Context, opt *eniOptions) error {
12331233
Backoff: &bo,
12341234
})
12351235
if err != nil {
1236-
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough) {
1236+
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough, apiErr.QuotaExceededPrivateIPAddress) {
12371237
// block
12381238
n.vswpool.Block(opt.eniRef.VSwitchID)
12391239
}
@@ -1262,7 +1262,7 @@ func (n *ReconcileNode) assignIP(ctx context.Context, opt *eniOptions) error {
12621262
Backoff: &bo,
12631263
})
12641264
if err != nil {
1265-
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough) {
1265+
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough, apiErr.QuotaExceededPrivateIPAddress) {
12661266
// block
12671267
n.vswpool.Block(opt.eniRef.VSwitchID)
12681268
}
@@ -1416,7 +1416,7 @@ func addIPToMap(in map[string]*networkv1beta1.IP, ip *networkv1beta1.IP) {
14161416
}
14171417

14181418
func isIPNotEnough(err error) bool {
1419-
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough) {
1419+
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough, apiErr.QuotaExceededPrivateIPAddress) {
14201420
return true
14211421
}
14221422
// can not find vsw

pkg/controller/pod/pod_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ func (m *ReconcilePod) createENI(ctx context.Context, allocs *[]*v1beta1.Allocat
608608
eni, err := m.aliyun.CreateNetworkInterface(ctx, option)
609609
if err != nil {
610610

611-
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough) {
611+
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough, apiErr.QuotaExceededPrivateIPAddress) {
612612
m.swPool.Block(alloc.ENI.VSwitchID)
613613
}
614614

pkg/eni/local.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ func (l *Local) errorHandleLocked(err error) {
937937
}
938938
}
939939

940-
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough) {
940+
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough, apiErr.QuotaExceededPrivateIPAddress) {
941941
next := time.Now().Add(10 * time.Minute)
942942
if next.After(l.ipAllocInhibitExpireAt) {
943943
l.ipAllocInhibitExpireAt = next

pkg/factory/aliyun/aliyun.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (a *Aliyun) CreateNetworkInterface(ipv4, ipv6 int, eniType string) (*daemon
120120

121121
eni, innerErr = a.openAPI.CreateNetworkInterface(ctx, option)
122122
if innerErr != nil {
123-
if apiErr.ErrorCodeIs(innerErr, apiErr.InvalidVSwitchIDIPNotEnough) {
123+
if apiErr.ErrorCodeIs(innerErr, apiErr.InvalidVSwitchIDIPNotEnough, apiErr.QuotaExceededPrivateIPAddress) {
124124
a.vsw.Block(vswID)
125125
return false, nil
126126
}

0 commit comments

Comments
 (0)