From c0b127a6f480d7d34546aedca02e505f99d8e81b Mon Sep 17 00:00:00 2001 From: Jack Francis Date: Tue, 22 Sep 2020 13:53:50 -0700 Subject: [PATCH] don't change val during upgrade/scale --- pkg/api/defaults.go | 3 ++- pkg/api/defaults_test.go | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pkg/api/defaults.go b/pkg/api/defaults.go index 53ec599fdcc..2e508a7eff3 100644 --- a/pkg/api/defaults.go +++ b/pkg/api/defaults.go @@ -177,7 +177,8 @@ func (cs *ContainerService) setOrchestratorDefaults(isUpgrade, isScale bool) { } } - if !cs.Properties.IsHostedMasterProfile() && + if !isUpgrade && !isScale && + !cs.Properties.IsHostedMasterProfile() && !cs.Properties.IsCustomCloudProfile() && !cs.Properties.MasterProfile.IsVirtualMachineScaleSets() && o.KubernetesConfig.UseManagedIdentity == nil { diff --git a/pkg/api/defaults_test.go b/pkg/api/defaults_test.go index 5237c134054..acd0a99b036 100644 --- a/pkg/api/defaults_test.go +++ b/pkg/api/defaults_test.go @@ -815,6 +815,24 @@ func TestDefaultUseManagedIdentity(t *testing.T) { t.Errorf("expected UseManagedIdentity to be false by default in VMSS control plane context, instead got %t", to.Bool(mockCS.Properties.OrchestratorProfile.KubernetesConfig.UseManagedIdentity)) } + isUpgrade = true + isScale = false + mockCS = getMockBaseContainerService("1.18.8") + mockCS.Properties.OrchestratorProfile.OrchestratorType = Kubernetes + mockCS.setOrchestratorDefaults(isUpgrade, isScale) + if mockCS.Properties.OrchestratorProfile.KubernetesConfig.UseManagedIdentity != nil { + t.Errorf("expected UseManagedIdentity to be unchanged by default in upgrade context, instead got %t", to.Bool(mockCS.Properties.OrchestratorProfile.KubernetesConfig.UseManagedIdentity)) + } + + isUpgrade = false + isScale = true + mockCS = getMockBaseContainerService("1.18.8") + mockCS.Properties.OrchestratorProfile.OrchestratorType = Kubernetes + mockCS.setOrchestratorDefaults(isUpgrade, isScale) + if mockCS.Properties.OrchestratorProfile.KubernetesConfig.UseManagedIdentity != nil { + t.Errorf("expected UseManagedIdentity to be unchanged by default in scale context, instead got %t", to.Bool(mockCS.Properties.OrchestratorProfile.KubernetesConfig.UseManagedIdentity)) + } + mockCS = getMockBaseContainerService("1.18.8") mockCS.Properties.OrchestratorProfile.OrchestratorType = Kubernetes mockCS.Properties.OrchestratorProfile.KubernetesConfig.UseManagedIdentity = to.BoolPtr(false)