From 7b499aa4c90b30655654dd772559a079de359463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Osipiuk?= Date: Tue, 12 Nov 2019 14:36:05 +0100 Subject: [PATCH] Rename STOCKOUT to RESOURCE_POOL_EXHAUSTED We came into conclusion that using STOCKOUT as error code is too specific. Migrating to more general term RESOURCE_POOL_EXHAUSTED. --- .../gce/autoscaling_gce_client.go | 11 +++++---- .../cloudprovider/gce/gce_manager_test.go | 24 +++++++++---------- .../core/static_autoscaler_test.go | 6 ++--- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go b/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go index 8ebd217f7ce4..1d0a65beaa52 100644 --- a/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go +++ b/cluster-autoscaler/cloudprovider/gce/autoscaling_gce_client.go @@ -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" @@ -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 @@ -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" } diff --git a/cluster-autoscaler/cloudprovider/gce/gce_manager_test.go b/cluster-autoscaler/cloudprovider/gce/gce_manager_test.go index 56e690187310..aa45eec5dbdb 100644 --- a/cluster-autoscaler/cloudprovider/gce/gce_manager_test.go +++ b/cluster-autoscaler/cloudprovider/gce/gce_manager_test.go @@ -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!", }, { diff --git a/cluster-autoscaler/core/static_autoscaler_test.go b/cluster-autoscaler/core/static_autoscaler_test.go index d9d248c7e4da..05d78337bdd5 100644 --- a/cluster-autoscaler/core/static_autoscaler_test.go +++ b/cluster-autoscaler/core/static_autoscaler_test.go @@ -1154,7 +1154,7 @@ func TestStaticAutoscalerInstaceCreationErrors(t *testing.T) { State: cloudprovider.InstanceCreating, ErrorInfo: &cloudprovider.InstanceErrorInfo{ ErrorClass: cloudprovider.OutOfResourcesErrorClass, - ErrorCode: "STOCKOUT", + ErrorCode: "RESOURCE_POOL_EXHAUSTED", }, }, }, @@ -1164,7 +1164,7 @@ func TestStaticAutoscalerInstaceCreationErrors(t *testing.T) { State: cloudprovider.InstanceCreating, ErrorInfo: &cloudprovider.InstanceErrorInfo{ ErrorClass: cloudprovider.OutOfResourcesErrorClass, - ErrorCode: "STOCKOUT", + ErrorCode: "RESOURCE_POOL_EXHAUSTED", }, }, }, @@ -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()