Skip to content

Commit

Permalink
openapi: adapt the QuotaExceeded.PrivateIpAddress code
Browse files Browse the repository at this point in the history
Signed-off-by: l1b0k <[email protected]>
  • Loading branch information
l1b0k committed Nov 13, 2024
1 parent ea4d6ff commit 751ec37
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions pkg/aliyun/client/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const (
// Reference: https://help.aliyun.com/document_detail/85917.html
InvalidVSwitchIDIPNotEnough = "InvalidVSwitchId.IpNotEnough"

QuotaExceededPrivateIPAddress = "QuotaExceeded.PrivateIpAddress"

// ErrEniPerInstanceLimitExceeded CreateNetworkInterfaces const error message
// Reference: https://help.aliyun.com/document_detail/85917.html
ErrEniPerInstanceLimitExceeded = "EniPerInstanceLimitExceeded"
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/multi-ip/node/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ func (n *ReconcileNode) createENI(ctx context.Context, node *networkv1beta1.Node

result, err := n.aliyun.CreateNetworkInterface(ctx, typeOption, createOpts)
if err != nil {
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough) {
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough, apiErr.QuotaExceededPrivateIPAddress) {
// block
n.vswpool.Block(createOpts.NetworkInterfaceOptions.VSwitchID)
}
Expand Down Expand Up @@ -1233,7 +1233,7 @@ func (n *ReconcileNode) assignIP(ctx context.Context, opt *eniOptions) error {
Backoff: &bo,
})
if err != nil {
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough) {
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough, apiErr.QuotaExceededPrivateIPAddress) {
// block
n.vswpool.Block(opt.eniRef.VSwitchID)
}
Expand Down Expand Up @@ -1262,7 +1262,7 @@ func (n *ReconcileNode) assignIP(ctx context.Context, opt *eniOptions) error {
Backoff: &bo,
})
if err != nil {
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough) {
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough, apiErr.QuotaExceededPrivateIPAddress) {
// block
n.vswpool.Block(opt.eniRef.VSwitchID)
}
Expand Down Expand Up @@ -1416,7 +1416,7 @@ func addIPToMap(in map[string]*networkv1beta1.IP, ip *networkv1beta1.IP) {
}

func isIPNotEnough(err error) bool {
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough) {
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough, apiErr.QuotaExceededPrivateIPAddress) {
return true
}
// can not find vsw
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/pod/pod_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ func (m *ReconcilePod) createENI(ctx context.Context, allocs *[]*v1beta1.Allocat
eni, err := m.aliyun.CreateNetworkInterface(ctx, option)
if err != nil {

if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough) {
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough, apiErr.QuotaExceededPrivateIPAddress) {
m.swPool.Block(alloc.ENI.VSwitchID)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/eni/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ func (l *Local) errorHandleLocked(err error) {
}
}

if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough) {
if apiErr.ErrorCodeIs(err, apiErr.InvalidVSwitchIDIPNotEnough, apiErr.QuotaExceededPrivateIPAddress) {
next := time.Now().Add(10 * time.Minute)
if next.After(l.ipAllocInhibitExpireAt) {
l.ipAllocInhibitExpireAt = next
Expand Down
2 changes: 1 addition & 1 deletion pkg/factory/aliyun/aliyun.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (a *Aliyun) CreateNetworkInterface(ipv4, ipv6 int, eniType string) (*daemon

eni, innerErr = a.openAPI.CreateNetworkInterface(ctx, option)
if innerErr != nil {
if apiErr.ErrorCodeIs(innerErr, apiErr.InvalidVSwitchIDIPNotEnough) {
if apiErr.ErrorCodeIs(innerErr, apiErr.InvalidVSwitchIDIPNotEnough, apiErr.QuotaExceededPrivateIPAddress) {
a.vsw.Block(vswID)
return false, nil
}
Expand Down

0 comments on commit 751ec37

Please sign in to comment.