From 8396c7e73cbf6b68078969604ac49f402125c1b0 Mon Sep 17 00:00:00 2001 From: Aleksandra Gacek Date: Wed, 15 Jun 2022 11:53:20 +0200 Subject: [PATCH] Handle gracefully empty arch in kube env. --- cluster-autoscaler/cloudprovider/gce/templates.go | 2 ++ cluster-autoscaler/cloudprovider/gce/templates_test.go | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/cluster-autoscaler/cloudprovider/gce/templates.go b/cluster-autoscaler/cloudprovider/gce/templates.go index 868deeb5582..39150064b49 100644 --- a/cluster-autoscaler/cloudprovider/gce/templates.go +++ b/cluster-autoscaler/cloudprovider/gce/templates.go @@ -598,6 +598,8 @@ func ToSystemArchitecture(arch string) SystemArchitecture { return Arm64 case string(Amd64): return Amd64 + case "": + return DefaultArch default: return UnknownArch } diff --git a/cluster-autoscaler/cloudprovider/gce/templates_test.go b/cluster-autoscaler/cloudprovider/gce/templates_test.go index 6033d5f4bb1..fe1c6fb187a 100644 --- a/cluster-autoscaler/cloudprovider/gce/templates_test.go +++ b/cluster-autoscaler/cloudprovider/gce/templates_test.go @@ -170,6 +170,15 @@ func TestBuildNodeFromTemplateSetsResources(t *testing.T) { attachedLocalSSDCount: 4, expectedErr: false, }, + { + scenario: "handle empty arch gracefully", + kubeEnv: "AUTOSCALER_ENV_VARS: os_distribution=cos;arch=;os=linux;ephemeral_storage_local_ssd_count=2\n", + physicalCpu: 8, + physicalMemory: 200 * units.MiB, + ephemeralStorageLocalSSDCount: 2, + attachedLocalSSDCount: 4, + expectedErr: false, + }, { scenario: "ephemeral storage on local SSDs with kube-reserved", kubeEnv: "AUTOSCALER_ENV_VARS: kube_reserved=cpu=0,memory=0,ephemeral-storage=10Gi;os_distribution=cos;os=linux;ephemeral_storage_local_ssd_count=2\n",