Skip to content

Commit

Permalink
Merge pull request #2521 from losipiuk/lo/rename-stockout
Browse files Browse the repository at this point in the history
Rename STOCKOUT to RESOURCE_POOL_EXHAUSTED
  • Loading branch information
k8s-ci-robot authored Nov 12, 2019
2 parents c5f50b2 + 7b499aa commit 8871f17
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
11 changes: 6 additions & 5 deletions cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ const (
// ErrorCodeQuotaExceeded is error code used in InstanceErrorInfo if quota exceeded error occurs.
ErrorCodeQuotaExceeded = "QUOTA_EXCEEDED"

// ErrorCodeStockout is error code used in InstanceErrorInfo if stockout occurs.
ErrorCodeStockout = "STOCKOUT"
// ErrorCodeResourcePoolExhausted is 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.
ErrorCodeOther = "OTHER"
Expand Down Expand Up @@ -232,9 +233,9 @@ func (client *autoscalingGceClientV1) FetchMigInstances(migRef GceRef) ([]cloudp
lastAttemptErrors := getLastAttemptErrors(gceInstance)
for _, instanceError := range lastAttemptErrors {
errorCodeCounts[instanceError.Code]++
if isStockoutErrorCode(instanceError.Code) {
if isResourcePoolExhaustedErrorCode(instanceError.Code) {
errorInfo.ErrorClass = cloudprovider.OutOfResourcesErrorClass
errorInfo.ErrorCode = ErrorCodeStockout
errorInfo.ErrorCode = ErrorCodeResourcePoolExhausted
} else if isQuotaExceededErrorCoce(instanceError.Code) {
errorInfo.ErrorClass = cloudprovider.OutOfResourcesErrorClass
errorInfo.ErrorCode = ErrorCodeQuotaExceeded
Expand Down Expand Up @@ -285,7 +286,7 @@ func getLastAttemptErrors(instance *gce.ManagedInstance) []*gce.ManagedInstanceL
return nil
}

func isStockoutErrorCode(errorCode string) bool {
func isResourcePoolExhaustedErrorCode(errorCode string) bool {
return errorCode == "RESOURCE_POOL_EXHAUSTED" || errorCode == "ZONE_RESOURCE_POOL_EXHAUSTED" || errorCode == "ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS"
}

Expand Down
24 changes: 12 additions & 12 deletions cluster-autoscaler/cloudprovider/gce/gce_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -976,35 +976,35 @@ func TestGetMigNodesComplex(t *testing.T) {
"",
},
{
"none-creating-stockout_error",
buildManagedInstanceWithCurrentActionAndErrorResponsePart("europe-west1-b", "none-creating-stockout_error", "CREATING", "RESOURCE_POOL_EXHAUSTED", "No resources!"),
"none-creating-resource_pool_exhausted_error",
buildManagedInstanceWithCurrentActionAndErrorResponsePart("europe-west1-b", "none-creating-resource_pool_exhausted_error", "CREATING", "RESOURCE_POOL_EXHAUSTED", "No resources!"),
cloudprovider.InstanceCreating,
cloudprovider.OutOfResourcesErrorClass,
ErrorCodeStockout,
ErrorCodeResourcePoolExhausted,
"No resources!",
},
{
"none-creating-zonal_stockout_error",
buildManagedInstanceWithCurrentActionAndErrorResponsePart("europe-west1-b", "none-creating-zonal_stockout_error", "CREATING", "ZONE_RESOURCE_POOL_EXHAUSTED", "No resources!"),
"none-creating-zonal_resource_pool_exhausted_error",
buildManagedInstanceWithCurrentActionAndErrorResponsePart("europe-west1-b", "none-creating-zonal_resource_pool_exhausted_error", "CREATING", "ZONE_RESOURCE_POOL_EXHAUSTED", "No resources!"),
cloudprovider.InstanceCreating,
cloudprovider.OutOfResourcesErrorClass,
ErrorCodeStockout,
ErrorCodeResourcePoolExhausted,
"No resources!",
},
{
"none-creating-zonal_stockout_error_with_details",
buildManagedInstanceWithCurrentActionAndErrorResponsePart("europe-west1-b", "none-creating-zonal_stockout_error_with_details", "CREATING", "ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS", "No resources!"),
"none-creating-zonal_resource_pool_exhausted_error_with_details",
buildManagedInstanceWithCurrentActionAndErrorResponsePart("europe-west1-b", "none-creating-zonal_resource_pool_exhausted_error_with_details", "CREATING", "ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS", "No resources!"),
cloudprovider.InstanceCreating,
cloudprovider.OutOfResourcesErrorClass,
ErrorCodeStockout,
ErrorCodeResourcePoolExhausted,
"No resources!",
},
{
"running-creating-stockout_error",
buildRunningManagedInstanceWithCurrentActionAndErrorResponsePart("europe-west1-b", "running-creating-stockout_error", "CREATING", "RESOURCE_POOL_EXHAUSTED", "No resources!"),
"running-creating-resource_pool_exhausted_error",
buildRunningManagedInstanceWithCurrentActionAndErrorResponsePart("europe-west1-b", "running-creating-resource_pool_exhausted_error", "CREATING", "RESOURCE_POOL_EXHAUSTED", "No resources!"),
cloudprovider.InstanceCreating,
cloudprovider.OutOfResourcesErrorClass,
ErrorCodeStockout,
ErrorCodeResourcePoolExhausted,
"No resources!",
},
{
Expand Down
6 changes: 3 additions & 3 deletions cluster-autoscaler/core/static_autoscaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ func TestStaticAutoscalerInstaceCreationErrors(t *testing.T) {
State: cloudprovider.InstanceCreating,
ErrorInfo: &cloudprovider.InstanceErrorInfo{
ErrorClass: cloudprovider.OutOfResourcesErrorClass,
ErrorCode: "STOCKOUT",
ErrorCode: "RESOURCE_POOL_EXHAUSTED",
},
},
},
Expand All @@ -1164,7 +1164,7 @@ func TestStaticAutoscalerInstaceCreationErrors(t *testing.T) {
State: cloudprovider.InstanceCreating,
ErrorInfo: &cloudprovider.InstanceErrorInfo{
ErrorClass: cloudprovider.OutOfResourcesErrorClass,
ErrorCode: "STOCKOUT",
ErrorCode: "RESOURCE_POOL_EXHAUSTED",
},
},
},
Expand Down Expand Up @@ -1238,7 +1238,7 @@ func TestStaticAutoscalerInstaceCreationErrors(t *testing.T) {
return names["A3"] && names["A4"] && names["A5"] && names["A6"]
}))

// TODO assert that scaleup was failed (separately for QUOTA and STOCKOUT)
// TODO assert that scaleup was failed (separately for QUOTA and RESOURCE_POOL_EXHAUSTED)

clusterState.RefreshCloudProviderNodeInstancesCache()

Expand Down

0 comments on commit 8871f17

Please sign in to comment.