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

Commit

Permalink
feat: Add checks for Metadata, AcceleratedNetworking and etcdDiskSize…
Browse files Browse the repository at this point in the history
…GB on Azure Stack to fail fast. (#1564)

* Validate different settings on Azure Stack.

* Adding empty check for EtcdDiskSizeGB case.

* Added one more unit test for invalid value of etcdisksize.
  • Loading branch information
rjaini authored and acs-bot committed Jul 3, 2019
1 parent 97aab87 commit d17ea6e
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pkg/api/vlabs/const.go
Original file line number Diff line number Diff line change
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
)

const (
Expand Down
21 changes: 20 additions & 1 deletion pkg/api/vlabs/validate.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -3006,6 +3006,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 @@ -3015,7 +3130,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

0 comments on commit d17ea6e

Please sign in to comment.