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

feat: Add checks for Metadata, AcceleratedNetworking and etcdDiskSizeGB on Azure Stack to fail fast. #1564

Merged
merged 3 commits into from Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 0 deletions pkg/api/vlabs/const.go
Expand Up @@ -134,6 +134,8 @@ const (
const (
// AzureStackCloud is a const string reference identifier for Azure Stack cloud
AzureStackCloud = "AzureStackCloud"
// MaxAzureStackManagedDiskSize is max etcd disk size supported on AzureStackCloud
MaxAzureStackManagedDiskSize = 1023
CecileRobertMichon marked this conversation as resolved.
Show resolved Hide resolved
)

const (
Expand Down
21 changes: 20 additions & 1 deletion pkg/api/vlabs/validate.go
Expand Up @@ -9,6 +9,7 @@ import (
"net"
"net/url"
"regexp"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -296,6 +297,22 @@ func (a *Properties) ValidateOrchestratorProfile(isUpdate bool) error {
if o.KubernetesConfig.MaximumLoadBalancerRuleCount < 0 {
return errors.New("maximumLoadBalancerRuleCount shouldn't be less than 0")
}

if a.IsAzureStackCloud() {
if to.Bool(o.KubernetesConfig.UseInstanceMetadata) {
return errors.New("useInstanceMetadata shouldn't be set to true as feature not yet supported on Azure Stack")
}

if o.KubernetesConfig.EtcdDiskSizeGB != "" {
etcdDiskSizeGB, err := strconv.Atoi(o.KubernetesConfig.EtcdDiskSizeGB)
if err != nil {
return errors.Errorf("could not convert EtcdDiskSizeGB to int")
}
if etcdDiskSizeGB > MaxAzureStackManagedDiskSize {
return errors.Errorf("EtcdDiskSizeGB max size supported on Azure Stack is %d", MaxAzureStackManagedDiskSize)
}
}
}
}
default:
return errors.Errorf("OrchestratorProfile has unknown orchestrator: %s", o.OrchestratorType)
Expand Down Expand Up @@ -428,7 +445,9 @@ func (a *Properties) validateAgentPoolProfiles(isUpdate bool) error {
}

if to.Bool(agentPoolProfile.AcceleratedNetworkingEnabled) || to.Bool(agentPoolProfile.AcceleratedNetworkingEnabledWindows) {
if e := validatePoolAcceleratedNetworking(agentPoolProfile.VMSize); e != nil {
if a.IsAzureStackCloud() {
return errors.Errorf("AcceleratedNetworkingEnabled or AcceleratedNetworkingEnabledWindows shouldn't be set to true as feature is not yet supported on Azure Stack")
} else if e := validatePoolAcceleratedNetworking(agentPoolProfile.VMSize); e != nil {
return e
}
}
Expand Down
127 changes: 126 additions & 1 deletion pkg/api/vlabs/validate_test.go
Expand Up @@ -2898,6 +2898,121 @@ func TestValidateLocation(t *testing.T) {
},
expectedErr: errors.New("missing ContainerService Location"),
},
{
name: "AzureStack UseInstanceMetadata is true",
location: "local",
propertiesnil: false,
cs: &ContainerService{
Location: "local",
Properties: &Properties{
CustomCloudProfile: &CustomCloudProfile{
PortalURL: "https://portal.local.cotoso.com",
},
OrchestratorProfile: &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: "1.11.10",
KubernetesConfig: &KubernetesConfig{
UseInstanceMetadata: to.BoolPtr(trueVal),
},
},
},
},
expectedErr: errors.New("useInstanceMetadata shouldn't be set to true as feature not yet supported on Azure Stack"),
},
{
name: "AzureStack EtcdDiskSizeGB is 1024",
location: "local",
propertiesnil: false,
cs: &ContainerService{
Location: "local",
Properties: &Properties{
CustomCloudProfile: &CustomCloudProfile{
PortalURL: "https://portal.local.cotoso.com",
},
OrchestratorProfile: &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: "1.11.10",
KubernetesConfig: &KubernetesConfig{
EtcdDiskSizeGB: "1024",
},
},
},
},
expectedErr: errors.Errorf("EtcdDiskSizeGB max size supported on Azure Stack is %d", MaxAzureStackManagedDiskSize),
},
{
name: "AzureStack EtcdDiskSizeGB is 1024",
location: "local",
propertiesnil: false,
cs: &ContainerService{
Location: "local",
Properties: &Properties{
CustomCloudProfile: &CustomCloudProfile{
PortalURL: "https://portal.local.cotoso.com",
},
OrchestratorProfile: &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: "1.11.10",
KubernetesConfig: &KubernetesConfig{
EtcdDiskSizeGB: "1024GB",
},
},
},
},
expectedErr: errors.New("could not convert EtcdDiskSizeGB to int"),
},
{
name: "AzureStack AcceleratedNetworking is true",
location: "local",
propertiesnil: false,
cs: &ContainerService{
Location: "local",
Properties: &Properties{
CustomCloudProfile: &CustomCloudProfile{
PortalURL: "https://portal.local.cotoso.com",
},
OrchestratorProfile: &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: "1.11.10",
},
AgentPoolProfiles: []*AgentPoolProfile{
{
Name: "testpool",
Count: 1,
VMSize: "Standard_D2_v2",
AcceleratedNetworkingEnabled: to.BoolPtr(trueVal),
},
},
},
},
expectedErr: errors.New("AcceleratedNetworkingEnabled or AcceleratedNetworkingEnabledWindows shouldn't be set to true as feature is not yet supported on Azure Stack"),
},
{
name: "AzureStack AcceleratedNetworking is true",
location: "local",
propertiesnil: false,
cs: &ContainerService{
Location: "local",
Properties: &Properties{
CustomCloudProfile: &CustomCloudProfile{
PortalURL: "https://portal.local.cotoso.com",
},
OrchestratorProfile: &OrchestratorProfile{
OrchestratorType: Kubernetes,
OrchestratorVersion: "1.11.10",
},
AgentPoolProfiles: []*AgentPoolProfile{
{
Name: "testpool",
Count: 1,
VMSize: "Standard_D2_v2",
AcceleratedNetworkingEnabledWindows: to.BoolPtr(trueVal),
},
},
},
},
expectedErr: errors.New("AcceleratedNetworkingEnabled or AcceleratedNetworkingEnabledWindows shouldn't be set to true as feature is not yet supported on Azure Stack"),
},
}

for _, test := range tests {
Expand All @@ -2907,7 +3022,17 @@ func TestValidateLocation(t *testing.T) {
cs := getK8sDefaultContainerService(true)
cs.Location = test.cs.Location
if test.cs.Properties != nil {
cs.Properties.CustomCloudProfile = test.cs.Properties.CustomCloudProfile
if test.cs.Properties.CustomCloudProfile != nil {
cs.Properties.CustomCloudProfile = test.cs.Properties.CustomCloudProfile
}

if test.cs.Properties.OrchestratorProfile != nil {
cs.Properties.OrchestratorProfile = test.cs.Properties.OrchestratorProfile
}

if test.cs.Properties.AgentPoolProfiles != nil {
cs.Properties.AgentPoolProfiles = test.cs.Properties.AgentPoolProfiles
}
}

if test.propertiesnil {
Expand Down