Skip to content

Commit

Permalink
expose IP_SPACE_EXHAUSTED
Browse files Browse the repository at this point in the history
  • Loading branch information
brett-elliott committed Mar 16, 2021
1 parent b2951aa commit dadb7b3
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@ const (
defaultOperationWaitTimeout = 20 * time.Second
defaultOperationPollInterval = 100 * time.Millisecond
defaultOperationDeletionPollInterval = 1 * time.Second
// ErrorCodeQuotaExceeded is error code used in InstanceErrorInfo if quota exceeded error occurs.
// ErrorCodeQuotaExceeded is an error code used in InstanceErrorInfo if quota exceeded error occurs.
ErrorCodeQuotaExceeded = "QUOTA_EXCEEDED"

// ErrorCodeResourcePoolExhausted is error code used in InstanceErrorInfo if requested resources
// ErrorCodeResourcePoolExhausted is an error code used in InstanceErrorInfo if requested resources
// cannot be provisioned by cloud provider.
ErrorCodeResourcePoolExhausted = "RESOURCE_POOL_EXHAUSTED"

// ErrorCodeOther is error code used in InstanceErrorInfo if other error occurs.
// ErrorIPSpaceExhausted is an error code used in InstanceErrorInfo if the IP space has been
// exhausted.
ErrorIPSpaceExhausted = "IP_SPACE_EXHAUSTED"

// ErrorCodeOther is an error code used in InstanceErrorInfo if other error occurs.
ErrorCodeOther = "OTHER"
)

Expand Down Expand Up @@ -260,9 +264,12 @@ func (client *autoscalingGceClientV1) FetchMigInstances(migRef GceRef) ([]cloudp
if isResourcePoolExhaustedErrorCode(instanceError.Code) {
errorInfo.ErrorClass = cloudprovider.OutOfResourcesErrorClass
errorInfo.ErrorCode = ErrorCodeResourcePoolExhausted
} else if isQuotaExceededErrorCoce(instanceError.Code) {
} else if isQuotaExceededErrorCode(instanceError.Code) {
errorInfo.ErrorClass = cloudprovider.OutOfResourcesErrorClass
errorInfo.ErrorCode = ErrorCodeQuotaExceeded
} else if isIPSpaceExhaustedErrorCode(instanceError.Code) {
errorInfo.ErrorClass = cloudprovider.OtherErrorClass
errorInfo.ErrorCode = ErrorIPSpaceExhausted
} else if isInstanceNotRunningYet(gceInstance) {
if !errorFound {
// do not override error code with OTHER
Expand Down Expand Up @@ -314,10 +321,14 @@ func isResourcePoolExhaustedErrorCode(errorCode string) bool {
return errorCode == "RESOURCE_POOL_EXHAUSTED" || errorCode == "ZONE_RESOURCE_POOL_EXHAUSTED" || errorCode == "ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS"
}

func isQuotaExceededErrorCoce(errorCode string) bool {
func isQuotaExceededErrorCode(errorCode string) bool {
return strings.Contains(errorCode, "QUOTA")
}

func isIPSpaceExhaustedErrorCode(errorCode string) bool {
return strings.Contains(errorCode, "IP_SPACE_EXHAUSTED")
}

func isInstanceNotRunningYet(gceInstance *gce.ManagedInstance) bool {
return gceInstance.InstanceStatus == "" || gceInstance.InstanceStatus == "PROVISIONING" || gceInstance.InstanceStatus == "STAGING"
}
Expand Down

0 comments on commit dadb7b3

Please sign in to comment.