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

feat: add "get-versions --azure-env" flag to list custom clouds supported versions #3394

Merged
merged 9 commits into from
Jun 4, 2020

Conversation

haofan-ms
Copy link
Contributor

@haofan-ms haofan-ms commented Jun 3, 2020

Reason for Change:

The aks-engine get-versions command only shows Azure supported versions.
The --azure-env flag will allow users to pass a target custom cloud like Azure Stack and get back supported versions on that target cloud.

Usage: aks-engine get-versions --azure-env AzureStackCloud

Requirements:

Notes:

@acs-bot acs-bot added the size/XL label Jun 3, 2020
@jadarsie
Copy link
Member

jadarsie commented Jun 3, 2020

Will take a look

@jadarsie jadarsie closed this Jun 3, 2020
@jadarsie jadarsie reopened this Jun 3, 2020
@@ -198,37 +198,99 @@ var AllKubernetesSupportedVersions = map[string]bool{
"1.19.0-beta.0": true,
}

// AllKubernetesSupportedVersionsOnAzureStack is a whitelist map of all supported Kubernetes version strings on Azure Stack
// The bool value indicates if creating new clusters with this version is allowed
var AllKubernetesSupportedVersionsOnAzureStack = map[string]bool{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you be maintaining these version support lists going forward? In practice, this means when the AKS Engine project moves versions forward for public cloud, Azure Stack won't get that support. That seems sane, just want to clarify.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct

Copy link
Member

@jadarsie jadarsie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass

@@ -44,6 +45,7 @@ func newGetVersionsCmd() *cobra.Command {
gvc.orchestrator = "Kubernetes" // orchestrator is always Kubernetes
f.StringVar(&gvc.version, "version", "", "Kubernetes version (optional)")
f.BoolVar(&gvc.windows, "windows", false, "Kubernetes cluster with Windows nodes (optional)")
f.StringVar(&gvc.azureEnv, "azureEnv", "", "The target Azure cloud (default is 'AzurePublicCloud')")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep it consistent with the deploy command by calling this flag azure-env

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially it was set to be like that, but that failed with a linter check error because of the "-" so I have to change it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean this ... (&gvc.azureEnv, "azure-env", ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

@@ -44,6 +45,7 @@ func newGetVersionsCmd() *cobra.Command {
gvc.orchestrator = "Kubernetes" // orchestrator is always Kubernetes
f.StringVar(&gvc.version, "version", "", "Kubernetes version (optional)")
f.BoolVar(&gvc.windows, "windows", false, "Kubernetes cluster with Windows nodes (optional)")
f.StringVar(&gvc.azureEnv, "azureEnv", "", "The target Azure cloud (default is 'AzurePublicCloud')")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The third param is the default value, pass AzurePublicCloud please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

@@ -44,6 +45,7 @@ func newGetVersionsCmd() *cobra.Command {
gvc.orchestrator = "Kubernetes" // orchestrator is always Kubernetes
f.StringVar(&gvc.version, "version", "", "Kubernetes version (optional)")
f.BoolVar(&gvc.windows, "windows", false, "Kubernetes cluster with Windows nodes (optional)")
f.StringVar(&gvc.azureEnv, "azureEnv", "", "The target Azure cloud (default is 'AzurePublicCloud')")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to add (default is 'AzurePublicCloud') at the end, the command package takes care of that if you pass a default value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

@@ -145,6 +145,7 @@ func (a *Apiloader) LoadContainerServiceForAgentPoolOnlyCluster(
hasExistingCS := existingContainerService != nil
IsSSHAutoGenerated := false
hasWindows := false
onAzureStack := false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think variable name isAzureStack would align better with the code base

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

@@ -8,46 +8,72 @@ import (
)

func Test_GetAllSupportedKubernetesVersions(t *testing.T) {
responseFromGetter := GetAllSupportedKubernetesVersions(true, false)
responseFromGetter := GetAllSupportedKubernetesVersions(true, false, false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing a const (notAzureStack or similar) instead of bool false can possibly improve readability

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

Comment on lines 63 to 83
func isVersionSupported(csOrch *OrchestratorProfile, onAzureStack bool) bool {
supported := false
for _, version := range versionsMap[csOrch.OrchestratorType] {
if onAzureStack {
for _, version := range versionsMapAzureStack[csOrch.OrchestratorType] {

if version == csOrch.OrchestratorVersion {
supported = true
break
if version == csOrch.OrchestratorVersion {
supported = true
break
}
}
} else {
for _, version := range versionsMap[csOrch.OrchestratorType] {

if version == csOrch.OrchestratorVersion {
supported = true
break
}
}
}
return supported
}
Copy link
Member

@jadarsie jadarsie Jun 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be easier to read

supported := false
versions := versionsMap[csOrch.OrchestratorType]
if onAzureStack {
	versions = versionsMapAzureStack[csOrch.OrchestratorType]
} 
for _, version := range versions {
	if version == csOrch.OrchestratorVersion {
		supported = true
		break
	}
}
return supported

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

var err error
onAzureStack := (azureEnv == "AzureStackCloud")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code base usually does a case insensitive comparison for cloud names

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

@@ -207,7 +225,7 @@ func getKubernetesAvailableUpgradeVersions(orchestratorVersion string, supported

}

func dcosInfo(csOrch *OrchestratorProfile, hasWindows bool) ([]*OrchestratorVersionProfile, error) {
func dcosInfo(csOrch *OrchestratorProfile, hasWindows bool, onAzureStack bool) ([]*OrchestratorVersionProfile, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onAzureStack not used in function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because kubernetesInfo, dcosInfo, swarmInfo, dockerceInfo are in the orchestratorsFunc, and they have to follow the structure of orchestratorsFunc (https://github.com/Azure/aks-engine/blob/master/pkg/api/orchestrators.go#L16). Similarly, the hasWindows variable is also not used in these functions, but have to exist.

@@ -255,7 +273,7 @@ func dcosUpgrades(csOrch *OrchestratorProfile) []*OrchestratorProfile {
return ret
}

func swarmInfo(csOrch *OrchestratorProfile, hasWindows bool) ([]*OrchestratorVersionProfile, error) {
func swarmInfo(csOrch *OrchestratorProfile, hasWindows bool, onAzureStack bool) ([]*OrchestratorVersionProfile, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@@ -280,7 +298,7 @@ func swarmInfo(csOrch *OrchestratorProfile, hasWindows bool) ([]*OrchestratorVer
}, nil
}

func dockerceInfo(csOrch *OrchestratorProfile, hasWindows bool) ([]*OrchestratorVersionProfile, error) {
func dockerceInfo(csOrch *OrchestratorProfile, hasWindows bool, onAzureStack bool) ([]*OrchestratorVersionProfile, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

"1.15.12": true,
"1.16.8": false,
"1.16.9": true,
"1.16.10": false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v1.16.10 and v1.17.6 should be true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

"1.16.8": false,
"1.16.9": true,
"1.17.4": false,
"1.17.5": true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add v1.16.10 and v1.17.6

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

"1.15.10": false,
"1.15.11": true,
"1.15.12": true,
"1.16.8": false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 1.16.8? do not think we ever supported that one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way I determine the supported versions is based on the Windows k8s binary URLs (https://github.com/Azure/aks-engine/blob/master/vhd/packer/configure-windows-vhd.ps1#L86-L94) and Linux k8s binaries (https://github.com/Azure/aks-engine/blob/master/vhd/packer/install-dependencies.sh#L349-L364). That may not be the best way, I will update.

@acs-bot acs-bot added size/L and removed size/XL labels Jun 3, 2020
@codecov
Copy link

codecov bot commented Jun 4, 2020

Codecov Report

Merging #3394 into master will increase coverage by 0.23%.
The diff coverage is 86.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3394      +/-   ##
==========================================
+ Coverage   72.96%   73.20%   +0.23%     
==========================================
  Files         147      147              
  Lines       24978    24967      -11     
==========================================
+ Hits        18226    18276      +50     
+ Misses       5624     5562      -62     
- Partials     1128     1129       +1     
Impacted Files Coverage Δ
pkg/api/common/const.go 40.00% <ø> (ø)
pkg/api/apiloader.go 61.57% <20.00%> (+0.20%) ⬆️
pkg/api/vlabs/validate.go 80.22% <80.00%> (-0.15%) ⬇️
pkg/api/orchestrators.go 62.26% <82.35%> (+0.68%) ⬆️
cmd/get_versions.go 95.34% <100.00%> (+0.11%) ⬆️
cmd/upgrade.go 44.32% <100.00%> (ø)
pkg/api/common/versions.go 96.84% <100.00%> (+0.29%) ⬆️
pkg/api/convertertoagentpoolonlyapi.go 89.93% <100.00%> (ø)
pkg/api/convertertoapi.go 93.52% <100.00%> (+0.35%) ⬆️
pkg/api/defaults.go 92.58% <100.00%> (ø)
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f52cd34...4233e49. Read the comment docs.

@jadarsie jadarsie changed the title chore: update get-versions for Azure Stack feat: add --azure-env flag to get-versions to list custom clouds supported version Jun 4, 2020
@jadarsie jadarsie changed the title feat: add --azure-env flag to get-versions to list custom clouds supported version feat: add "get-versions --azure-env" flag to list custom clouds supported versions Jun 4, 2020
@jadarsie
Copy link
Member

jadarsie commented Jun 4, 2020

/lgtm

Copy link
Member

@jackfrancis jackfrancis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

running some pan-version sanity checks, thank you @haofan-ms!

@acs-bot
Copy link

acs-bot commented Jun 4, 2020

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: haofan-ms, jackfrancis, jadarsie

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mboersma mboersma added this to In progress in backlog via automation Jun 4, 2020
@jackfrancis jackfrancis merged commit aa2973a into Azure:master Jun 4, 2020
backlog automation moved this from In progress to Done Jun 4, 2020
@haofan-ms haofan-ms deleted the update-get-versions branch August 11, 2020 05:07
penggu pushed a commit to penggu/aks-engine that referenced this pull request Oct 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
backlog
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants