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

Rationalize AvailabilityProfile default #3065

Merged
merged 10 commits into from May 29, 2018
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/clusterdefinition.md
Expand Up @@ -440,7 +440,7 @@ A cluster can have 0 to 12 agent pool profiles. Agent Pool Profiles are used for

|Name|Required|Description|
|---|---|---|
|availabilityProfile|no|Supported values are `VirtualMachineScaleSets` (default) and `AvailabilitySet`. For Kubernetes clusters before version 1.10, use `AvailabilitySet`. Otherwise, you should use `VirtualMachineScaleSets`|
|availabilityProfile|no|Supported values are `VirtualMachineScaleSets` (default, except for Kubernetes clusters before version 1.10) and `AvailabilitySet`.|
|count|yes|Describes the node count|
|scaleSetPriority|no|Supported values are `Regular` (default) and `Low`. Only applies to clusters with availabilityProfile `VirtualMachineScaleSets`. Enables the usage of [Low-priority VMs on Scale Sets](https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-use-low-priority).|
|scaleSetEvictionPolicy|no|Supported values are `Delete` (default) and `Deallocate`. Only applies to clusters with availabilityProfile of `VirtualMachineScaleSets` and scaleSetPriority of `Low`.|
Expand Down
3 changes: 1 addition & 2 deletions examples/kubernetes.json
Expand Up @@ -13,8 +13,7 @@
{
"name": "agentpool1",
"count": 2,
"vmSize": "Standard_D2_v2",
"availabilityProfile": "AvailabilitySet"
"vmSize": "Standard_D2_v2"
}
],
"linuxProfile": {
Expand Down
3 changes: 3 additions & 0 deletions pkg/acsengine/defaults.go
Expand Up @@ -756,6 +756,9 @@ func setStorageDefaults(a *api.Properties) {
}
if len(profile.AvailabilityProfile) == 0 {
profile.AvailabilityProfile = api.VirtualMachineScaleSets
if a.OrchestratorProfile.OrchestratorType == api.Kubernetes && !common.IsKubernetesVersionGe(a.OrchestratorProfile.OrchestratorVersion, "1.10.0") {
profile.AvailabilityProfile = api.AvailabilitySet
}
}
if len(profile.ScaleSetEvictionPolicy) == 0 && profile.ScaleSetPriority == api.ScaleSetPriorityLow {
profile.ScaleSetEvictionPolicy = api.ScaleSetEvictionPolicyDelete
Expand Down
14 changes: 14 additions & 0 deletions pkg/acsengine/defaults_test.go
Expand Up @@ -479,6 +479,20 @@ func TestStorageProfile(t *testing.T) {
t.Fatalf("MasterProfile.StorageProfile did not have the expected configuration, got %s, expected %s",
properties.OrchestratorProfile.KubernetesConfig.PrivateCluster.JumpboxProfile.StorageProfile, api.ManagedDisks)
}
if !properties.AgentPoolProfiles[0].IsAvailabilitySets() {
t.Fatalf("AgentPoolProfile[0].AvailabilityProfile did not have the expected configuration, got %s, expected %s",
properties.AgentPoolProfiles[0].AvailabilityProfile, api.AvailabilitySet)
}

mockCS = getMockBaseContainerService("1.10.0")
properties = mockCS.Properties
properties.OrchestratorProfile.OrchestratorType = "Kubernetes"
SetPropertiesDefaults(&mockCS, false)
if !properties.AgentPoolProfiles[0].IsVirtualMachineScaleSets() {
t.Fatalf("AgentPoolProfile[0].AvailabilityProfile did not have the expected configuration, got %s, expected %s",
properties.AgentPoolProfiles[0].AvailabilityProfile, api.VirtualMachineScaleSets)
}

}

func TestAgentPoolProfile(t *testing.T) {
Expand Down
26 changes: 5 additions & 21 deletions pkg/api/vlabs/validate.go
Expand Up @@ -587,8 +587,8 @@ func (a *Properties) Validate(isUpdate bool) error {
}
}

// validation for VMSS for Kubernetes
if a.OrchestratorProfile.OrchestratorType == Kubernetes && (agentPoolProfile.AvailabilityProfile == VirtualMachineScaleSets || len(agentPoolProfile.AvailabilityProfile) == 0) {
// validation for VMSS with Kubernetes
if a.OrchestratorProfile.OrchestratorType == Kubernetes && agentPoolProfile.AvailabilityProfile == VirtualMachineScaleSets {
version := common.RationalizeReleaseAndVersion(
a.OrchestratorProfile.OrchestratorType,
a.OrchestratorProfile.OrchestratorRelease,
Expand All @@ -611,25 +611,9 @@ func (a *Properties) Validate(isUpdate bool) error {
return fmt.Errorf("VirtualMachineScaleSets are only available in Kubernetes version %s or greater; unable to validate for Kubernetes version %s",
minVersion, version)
}
}

// validation for instanceMetadata using VMSS on Kubernetes
if a.OrchestratorProfile.OrchestratorType == Kubernetes && (agentPoolProfile.AvailabilityProfile == VirtualMachineScaleSets || len(agentPoolProfile.AvailabilityProfile) == 0) {
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 validation was duplicated

version := common.RationalizeReleaseAndVersion(
a.OrchestratorProfile.OrchestratorType,
a.OrchestratorProfile.OrchestratorRelease,
a.OrchestratorProfile.OrchestratorVersion,
false)
if version == "" {
return fmt.Errorf("the following user supplied OrchestratorProfile configuration is not supported: OrchestratorType: %s, OrchestratorRelease: %s, OrchestratorVersion: %s. Please check supported Release or Version for this build of acs-engine", a.OrchestratorProfile.OrchestratorType, a.OrchestratorProfile.OrchestratorRelease, a.OrchestratorProfile.OrchestratorVersion)
}

sv, err := semver.NewVersion(version)
if err != nil {
return fmt.Errorf("could not validate version %s", version)
}
minVersion := "1.10.2"
cons, err := semver.NewConstraint("<" + minVersion)
// validation for instanceMetadata using VMSS with Kubernetes
minVersion = "1.10.2"
cons, err = semver.NewConstraint("<" + minVersion)
if err != nil {
return fmt.Errorf("could not apply semver constraint < %s against version %s", minVersion, version)
}
Expand Down