diff --git a/aks-node-controller/parser/helper.go b/aks-node-controller/parser/helper.go index 58e7b2c3edc..7201d85bc06 100644 --- a/aks-node-controller/parser/helper.go +++ b/aks-node-controller/parser/helper.go @@ -145,12 +145,12 @@ func getKubenetTemplate() string { } // getContainerdConfig returns the base64 encoded containerd config depending on whether the node is with GPU or not. -func getContainerdConfig(aksnodeconfig *aksnodeconfigv1.Configuration, isGPU bool) string { +func getContainerdConfig(aksnodeconfig *aksnodeconfigv1.Configuration, noGPU bool) string { if aksnodeconfig == nil { return "" } - containerdConfig, err := containerdConfigFromAKSNodeConfig(aksnodeconfig, isGPU) + containerdConfig, err := containerdConfigFromAKSNodeConfig(aksnodeconfig, noGPU) if err != nil { return fmt.Sprintf("error getting containerd config from node bootstrap variables: %v", err) } @@ -158,14 +158,14 @@ func getContainerdConfig(aksnodeconfig *aksnodeconfigv1.Configuration, isGPU boo return base64.StdEncoding.EncodeToString([]byte(containerdConfig)) } -func containerdConfigFromAKSNodeConfig(aksnodeconfig *aksnodeconfigv1.Configuration, isGPU bool) (string, error) { +func containerdConfigFromAKSNodeConfig(aksnodeconfig *aksnodeconfigv1.Configuration, noGPU bool) (string, error) { if aksnodeconfig == nil { return "", fmt.Errorf("AKSNodeConfig is nil") } // the containerd config template is different based on whether the node is with GPU or not. _template := containerdConfigTemplate - if !isGPU { + if noGPU { _template = containerdConfigNoGPUTemplate } diff --git a/aks-node-controller/parser/helper_test.go b/aks-node-controller/parser/helper_test.go index b3e7f769282..859ccc153b7 100644 --- a/aks-node-controller/parser/helper_test.go +++ b/aks-node-controller/parser/helper_test.go @@ -249,6 +249,7 @@ func Test_createSortedKeyValueInt32Pairs(t *testing.T) { func Test_getContainerdConfig(t *testing.T) { type args struct { aksnodeconfig *aksnodeconfigv1.Configuration + noGpu bool } tests := []struct { name string @@ -284,7 +285,7 @@ oom_score = 0 `)), }, { - name: "Containerd Configurations with Nvidia GPU enabled", + name: "Containerd Configurations with bool noGpu set to false", args: args{ aksnodeconfig: &aksnodeconfigv1.Configuration{ NeedsCgroupv2: ToPtr(true), @@ -292,6 +293,7 @@ oom_score = 0 EnableNvidia: ToPtr(true), }, }, + noGpu: false, }, want: base64.StdEncoding.EncodeToString([]byte(`version = 2 oom_score = 0 @@ -315,11 +317,12 @@ oom_score = 0 `)), }, { - name: "Containerd Configurations with Nvidia GPU disabled", + name: "Containerd Configurations with bool noGpu set to true", args: args{ aksnodeconfig: &aksnodeconfigv1.Configuration{ NeedsCgroupv2: ToPtr(true), }, + noGpu: true, }, want: base64.StdEncoding.EncodeToString([]byte(`version = 2 oom_score = 0 @@ -345,7 +348,7 @@ oom_score = 0 } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := getContainerdConfig(tt.args.aksnodeconfig, true); got != tt.want { + if got := getContainerdConfig(tt.args.aksnodeconfig, tt.args.noGpu); got != tt.want { t.Errorf("getContainerdConfig() = %v, want %v", got, tt.want) } })