From 2592738262977e49e3f73c09fcb31da199ede070 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, 10 insertions(+), 1 deletion(-) diff --git a/cluster-autoscaler/cloudprovider/gce/templates.go b/cluster-autoscaler/cloudprovider/gce/templates.go index 868deeb5582d..2e40d39ee00a 100644 --- a/cluster-autoscaler/cloudprovider/gce/templates.go +++ b/cluster-autoscaler/cloudprovider/gce/templates.go @@ -599,7 +599,7 @@ func ToSystemArchitecture(arch string) SystemArchitecture { case string(Amd64): return Amd64 default: - return UnknownArch + return DefaultArch } } diff --git a/cluster-autoscaler/cloudprovider/gce/templates_test.go b/cluster-autoscaler/cloudprovider/gce/templates_test.go index 6033d5f4bb1a..fe1c6fb187a7 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",