Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
[BUG] orchestratorVersion should not get changed for ACS scale apiVer…
Browse files Browse the repository at this point in the history
…sion 2017-07-01 (#4346)
  • Loading branch information
Cecile Robert-Michon committed Dec 5, 2018
1 parent 7dbd73b commit 637285f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pkg/api/apiloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (a *Apiloader) LoadContainerService(
if e := containerService.Properties.Validate(isUpdate); validate && e != nil {
return nil, e
}
unversioned := ConvertV20170701ContainerService(containerService)
unversioned := ConvertV20170701ContainerService(containerService, isUpdate)
if curOrchVersion != "" &&
(containerService.Properties.OrchestratorProfile == nil ||
containerService.Properties.OrchestratorProfile.OrchestratorVersion == "") {
Expand Down
9 changes: 9 additions & 0 deletions pkg/api/apiloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ func TestLoadContainerServiceFromFile(t *testing.T) {
t.Errorf("Failed to set orcherstator version to windows default when it is not set in the json API v20170131, got %s but expected %s", containerService.Properties.OrchestratorProfile.OrchestratorVersion, common.GetDefaultKubernetesVersion(true))
}

// Test ACS scale scenario
existingContainerService.Properties.OrchestratorProfile.OrchestratorVersion = "1.8.12"
containerService, _, err = apiloader.LoadContainerServiceFromFile("../acsengine/testdata/v20170701/kubernetes.json", true, true, existingContainerService)
if err != nil {
t.Error(err.Error())
}
if containerService.Properties.OrchestratorProfile.OrchestratorVersion != "1.8.12" {
t.Errorf("Failed to set orcherstator version when it is set in the json, expected 1.8.12 but got %s", containerService.Properties.OrchestratorProfile.OrchestratorVersion)
}
}

func TestLoadContainerServiceForAgentPoolOnlyCluster(t *testing.T) {
Expand Down
15 changes: 9 additions & 6 deletions pkg/api/convertertoapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func ConvertV20170131ContainerService(v20170131 *v20170131.ContainerService) *Co
}

// ConvertV20170701ContainerService converts a v20170701 ContainerService to an unversioned ContainerService
func ConvertV20170701ContainerService(v20170701 *v20170701.ContainerService) *ContainerService {
func ConvertV20170701ContainerService(v20170701 *v20170701.ContainerService, isUpdate bool) *ContainerService {
c := &ContainerService{}
c.ID = v20170701.ID
c.Location = helpers.NormalizeAzureRegion(v20170701.Location)
Expand All @@ -94,7 +94,7 @@ func ConvertV20170701ContainerService(v20170701 *v20170701.ContainerService) *Co
}
c.Type = v20170701.Type
c.Properties = &Properties{}
convertV20170701Properties(v20170701.Properties, c.Properties)
convertV20170701Properties(v20170701.Properties, c.Properties, isUpdate)
return c
}

Expand Down Expand Up @@ -300,12 +300,12 @@ func convertV20170131Properties(v20170131 *v20170131.Properties, api *Properties
}
}

func convertV20170701Properties(v20170701 *v20170701.Properties, api *Properties) {
func convertV20170701Properties(v20170701 *v20170701.Properties, api *Properties, isUpdate bool) {
api.ProvisioningState = ProvisioningState(v20170701.ProvisioningState)

if v20170701.OrchestratorProfile != nil {
api.OrchestratorProfile = &OrchestratorProfile{}
convertV20170701OrchestratorProfile(v20170701.OrchestratorProfile, api.OrchestratorProfile, v20170701.HasWindows())
convertV20170701OrchestratorProfile(v20170701.OrchestratorProfile, api.OrchestratorProfile, isUpdate, v20170701.HasWindows())
}
if v20170701.MasterProfile != nil {
api.MasterProfile = &MasterProfile{}
Expand Down Expand Up @@ -564,7 +564,7 @@ func convertV20170131OrchestratorProfile(v20170131 *v20170131.OrchestratorProfil
}
}

func convertV20170701OrchestratorProfile(v20170701cs *v20170701.OrchestratorProfile, api *OrchestratorProfile, hasWindows bool) {
func convertV20170701OrchestratorProfile(v20170701cs *v20170701.OrchestratorProfile, api *OrchestratorProfile, isUpdate, hasWindows bool) {
if v20170701cs.OrchestratorType == v20170701.DockerCE {
api.OrchestratorType = SwarmMode
} else {
Expand All @@ -573,7 +573,10 @@ func convertV20170701OrchestratorProfile(v20170701cs *v20170701.OrchestratorProf

switch api.OrchestratorType {
case Kubernetes:
api.OrchestratorVersion = common.GetSupportedKubernetesVersion(v20170701cs.OrchestratorVersion, hasWindows)
api.OrchestratorVersion = common.RationalizeReleaseAndVersion(Kubernetes, "", v20170701cs.OrchestratorVersion, isUpdate, hasWindows)
if api.OrchestratorVersion == "" {
api.OrchestratorVersion = common.GetDefaultKubernetesVersion(hasWindows)
}
case DCOS:
switch v20170701cs.OrchestratorVersion {
case common.DCOSVersion1Dot10Dot0, common.DCOSVersion1Dot9Dot0, common.DCOSVersion1Dot8Dot8:
Expand Down
8 changes: 4 additions & 4 deletions pkg/api/convertertoapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestOrchestratorVersion(t *testing.T) {
},
},
}
cs := ConvertV20170701ContainerService(v20170701cs)
cs := ConvertV20170701ContainerService(v20170701cs, false)
if cs.Properties.OrchestratorProfile.OrchestratorVersion != common.GetDefaultKubernetesVersion(false) {
t.Fatalf("incorrect OrchestratorVersion '%s'", cs.Properties.OrchestratorProfile.OrchestratorVersion)
}
Expand All @@ -97,12 +97,12 @@ func TestOrchestratorVersion(t *testing.T) {
Properties: &v20170701.Properties{
OrchestratorProfile: &v20170701.OrchestratorProfile{
OrchestratorType: v20170701.Kubernetes,
OrchestratorVersion: "1.7.15",
OrchestratorVersion: "1.7.14",
},
},
}
cs = ConvertV20170701ContainerService(v20170701cs)
if cs.Properties.OrchestratorProfile.OrchestratorVersion != "1.7.15" {
cs = ConvertV20170701ContainerService(v20170701cs, true)
if cs.Properties.OrchestratorProfile.OrchestratorVersion != "1.7.14" {
t.Fatalf("incorrect OrchestratorVersion '%s'", cs.Properties.OrchestratorProfile.OrchestratorVersion)
}
// test vlabs
Expand Down

0 comments on commit 637285f

Please sign in to comment.