Adding support for PERMISSIONS_ERROR in gce cloud provider
This commit is contained in:
parent
0623a00d29
commit
671df22f9a
|
|
@ -50,6 +50,10 @@ const (
|
||||||
// exhausted.
|
// exhausted.
|
||||||
ErrorIPSpaceExhausted = "IP_SPACE_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 is an error code used in InstanceErrorInfo if other error occurs.
|
||||||
ErrorCodeOther = "OTHER"
|
ErrorCodeOther = "OTHER"
|
||||||
)
|
)
|
||||||
|
|
@ -271,6 +275,9 @@ func (client *autoscalingGceClientV1) FetchMigInstances(migRef GceRef) ([]cloudp
|
||||||
} else if isIPSpaceExhaustedErrorCode(instanceError.Code) {
|
} else if isIPSpaceExhaustedErrorCode(instanceError.Code) {
|
||||||
errorInfo.ErrorClass = cloudprovider.OtherErrorClass
|
errorInfo.ErrorClass = cloudprovider.OtherErrorClass
|
||||||
errorInfo.ErrorCode = ErrorIPSpaceExhausted
|
errorInfo.ErrorCode = ErrorIPSpaceExhausted
|
||||||
|
} else if isPermissionsError(instanceError.Code) {
|
||||||
|
errorInfo.ErrorClass = cloudprovider.OtherErrorClass
|
||||||
|
errorInfo.ErrorCode = ErrorCodePermissions
|
||||||
} else if isInstanceNotRunningYet(gceInstance) {
|
} else if isInstanceNotRunningYet(gceInstance) {
|
||||||
if !errorFound {
|
if !errorFound {
|
||||||
// do not override error code with OTHER
|
// do not override error code with OTHER
|
||||||
|
|
@ -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())
|
klogx.V(4).Over(errorLoggingQuota).Infof("Got %v other GCE instances being created with lastAttemptErrors", -errorLoggingQuota.Left())
|
||||||
if len(errorCodeCounts) > 0 {
|
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
|
return infos, nil
|
||||||
}
|
}
|
||||||
|
|
@ -330,6 +337,10 @@ func isIPSpaceExhaustedErrorCode(errorCode string) bool {
|
||||||
return strings.Contains(errorCode, "IP_SPACE_EXHAUSTED")
|
return strings.Contains(errorCode, "IP_SPACE_EXHAUSTED")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isPermissionsError(errorCode string) bool {
|
||||||
|
return strings.Contains(errorCode, "PERMISSIONS_ERROR")
|
||||||
|
}
|
||||||
|
|
||||||
func isInstanceNotRunningYet(gceInstance *gce.ManagedInstance) bool {
|
func isInstanceNotRunningYet(gceInstance *gce.ManagedInstance) bool {
|
||||||
return gceInstance.InstanceStatus == "" || gceInstance.InstanceStatus == "PROVISIONING" || gceInstance.InstanceStatus == "STAGING"
|
return gceInstance.InstanceStatus == "" || gceInstance.InstanceStatus == "PROVISIONING" || gceInstance.InstanceStatus == "STAGING"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,11 @@ func TestErrors(t *testing.T) {
|
||||||
expectedErrorCode: "QUOTA_EXCEEDED",
|
expectedErrorCode: "QUOTA_EXCEEDED",
|
||||||
expectedErrorClass: cloudprovider.OutOfResourcesErrorClass,
|
expectedErrorClass: cloudprovider.OutOfResourcesErrorClass,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
errorCodes: []string{"PERMISSIONS_ERROR"},
|
||||||
|
expectedErrorCode: "PERMISSIONS_ERROR",
|
||||||
|
expectedErrorClass: cloudprovider.OtherErrorClass,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
errorCodes: []string{"xyz", "abc"},
|
errorCodes: []string{"xyz", "abc"},
|
||||||
expectedErrorCode: "OTHER",
|
expectedErrorCode: "OTHER",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue