Skip to content

Commit

Permalink
Merge pull request #4137 from jayantjain93/permission-error
Browse files Browse the repository at this point in the history
Adding support for PERMISSIONS_ERROR in gce cloud provider
  • Loading branch information
k8s-ci-robot authored Jun 11, 2021
2 parents 0623a00 + 671df22 commit f57b8f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const (
// exhausted.
ErrorIPSpaceExhausted = "IP_SPACE_EXHAUSTED"

// ErrorCodePermissions is an error code used in InstanceErrorInfo if the user is facing
// permissions error
ErrorCodePermissions = "PERMISSIONS_ERROR"

// ErrorCodeOther is an error code used in InstanceErrorInfo if other error occurs.
ErrorCodeOther = "OTHER"
)
Expand Down Expand Up @@ -271,6 +275,9 @@ func (client *autoscalingGceClientV1) FetchMigInstances(migRef GceRef) ([]cloudp
} else if isIPSpaceExhaustedErrorCode(instanceError.Code) {
errorInfo.ErrorClass = cloudprovider.OtherErrorClass
errorInfo.ErrorCode = ErrorIPSpaceExhausted
} else if isPermissionsError(instanceError.Code) {
errorInfo.ErrorClass = cloudprovider.OtherErrorClass
errorInfo.ErrorCode = ErrorCodePermissions
} else if isInstanceNotRunningYet(gceInstance) {
if !errorFound {
// do not override error code with OTHER
Expand Down Expand Up @@ -306,7 +313,7 @@ func (client *autoscalingGceClientV1) FetchMigInstances(migRef GceRef) ([]cloudp
}
klogx.V(4).Over(errorLoggingQuota).Infof("Got %v other GCE instances being created with lastAttemptErrors", -errorLoggingQuota.Left())
if len(errorCodeCounts) > 0 {
klog.V(4).Infof("Spotted following instance creation error codes: %#v", errorCodeCounts)
klog.Warningf("Spotted following instance creation error codes: %#v", errorCodeCounts)
}
return infos, nil
}
Expand All @@ -330,6 +337,10 @@ func isIPSpaceExhaustedErrorCode(errorCode string) bool {
return strings.Contains(errorCode, "IP_SPACE_EXHAUSTED")
}

func isPermissionsError(errorCode string) bool {
return strings.Contains(errorCode, "PERMISSIONS_ERROR")
}

func isInstanceNotRunningYet(gceInstance *gce.ManagedInstance) bool {
return gceInstance.InstanceStatus == "" || gceInstance.InstanceStatus == "PROVISIONING" || gceInstance.InstanceStatus == "STAGING"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ func TestErrors(t *testing.T) {
expectedErrorCode: "QUOTA_EXCEEDED",
expectedErrorClass: cloudprovider.OutOfResourcesErrorClass,
},
{
errorCodes: []string{"PERMISSIONS_ERROR"},
expectedErrorCode: "PERMISSIONS_ERROR",
expectedErrorClass: cloudprovider.OtherErrorClass,
},
{
errorCodes: []string{"xyz", "abc"},
expectedErrorCode: "OTHER",
Expand Down

0 comments on commit f57b8f9

Please sign in to comment.