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

Commit

Permalink
Activate Accelerated Networking per default (#3449)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienstroheker authored and jackfrancis committed Jul 16, 2018
1 parent d9a4c62 commit bc738c6
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 2 deletions.
8 changes: 8 additions & 0 deletions pkg/acsengine/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,14 @@ func setAgentNetworkDefaults(a *api.Properties) {
profile.OSType = api.Linux
}

// Accelerated Networking is supported on most general purpose and compute-optimized instance sizes with 2 or more vCPUs.
// These supported series are: D/DSv2 and F/Fs // All the others are not supported
// On instances that support hyperthreading, Accelerated Networking is supported on VM instances with 4 or more vCPUs.
// Supported series are: D/DSv3, E/ESv3, Fsv2, and Ms/Mms.
if profile.AcceleratedNetworkingEnabled == nil {
profile.AcceleratedNetworkingEnabled = helpers.PointerToBool(helpers.AcceleratedNetworkingSupported(profile.VMSize))
}

// don't default Distro for OpenShift
if !a.OrchestratorProfile.IsOpenShift() {
// Set default Distro to Ubuntu
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ type AgentPoolProfile struct {
IPAddressCount int `json:"ipAddressCount,omitempty"`
Distro Distro `json:"distro,omitempty"`
Role AgentPoolProfileRole `json:"role,omitempty"`
AcceleratedNetworkingEnabled bool `json:"acceleratedNetworkingEnabled,omitempty"`
AcceleratedNetworkingEnabled *bool `json:"acceleratedNetworkingEnabled,omitempty"`
FQDN string `json:"fqdn,omitempty"`
CustomNodeLabels map[string]string `json:"customNodeLabels,omitempty"`
PreprovisionExtension *Extension `json:"preProvisionExtension"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/vlabs/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ type AgentPoolProfile struct {
KubernetesConfig *KubernetesConfig `json:"kubernetesConfig,omitempty"`
ImageRef *ImageReference `json:"imageReference,omitempty"`
Role AgentPoolProfileRole `json:"role,omitempty"`
AcceleratedNetworkingEnabled bool `json:"acceleratedNetworkingEnabled,omitempty"`
AcceleratedNetworkingEnabled *bool `json:"acceleratedNetworkingEnabled,omitempty"`

// subnet is internal
subnet string
Expand Down
13 changes: 13 additions & 0 deletions pkg/api/vlabs/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@ func (a *Properties) validateAgentPoolProfiles() error {
return e
}

if helpers.IsTrueBoolPointer(agentPoolProfile.AcceleratedNetworkingEnabled) {
if e := validatePoolAcceleratedNetworking(agentPoolProfile.VMSize); e != nil {
return e
}
}

if e := agentPoolProfile.validateOrchestratorSpecificProperties(a.OrchestratorProfile.OrchestratorType); e != nil {
return e
}
Expand Down Expand Up @@ -1127,6 +1133,13 @@ func validatePoolOSType(os OSType) error {
return nil
}

func validatePoolAcceleratedNetworking(VMSize string) error {
if !helpers.AcceleratedNetworkingSupported(VMSize) {
return fmt.Errorf("The AgentPoolProfile.vmsize does not support AgentPoolProfile.acceleratedNetworking")
}
return nil
}

func validateUniquePorts(ports []int, name string) error {
portMap := make(map[int]bool)
for _, port := range ports {
Expand Down
32 changes: 32 additions & 0 deletions pkg/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,35 @@ func CreateSSH(rg io.Reader, s *i18n.Translator) (privateKey *rsa.PrivateKey, pu

return privateKey, authorizedKey, nil
}

// AcceleratedNetworkingSupported check if the VmSKU support the Accelerated Networking
func AcceleratedNetworkingSupported(sku string) bool {
if strings.Contains(sku, "Standard_A") {
return false
}
if strings.Contains(sku, "Standard_B") {
return false
}
if strings.Contains(sku, "Standard_G") {
return false
}
if strings.Contains(sku, "Standard_H") {
return false
}
if strings.Contains(sku, "Standard_L") {
return false
}
if strings.Contains(sku, "Standard_N") {
return false
}
if strings.EqualFold(sku, "Standard_D1") || strings.Contains(sku, "Standard_D1_") {
return false
}
if strings.EqualFold(sku, "Standard_DS1") || strings.Contains(sku, "Standard_DS1_") {
return false
}
if strings.EqualFold(sku, "Standard_F1") || strings.EqualFold(sku, "Standard_F1s") {
return false
}
return true
}
55 changes: 55 additions & 0 deletions pkg/helpers/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,58 @@ EPDesL0rH+3s1CKpgkhYdbJ675GFoGoq+X21QaqsdvoXmmuJF9qq9Tq+JaWloUNq
t.Fatalf("Public Key did not match expected format/value")
}
}

func TestAcceleratedNetworkingSupported(t *testing.T) {
cases := []struct {
input string
expectedResult bool
}{
{
input: "Standard_A1",
expectedResult: false,
},
{
input: "Standard_G4",
expectedResult: false,
},
{
input: "Standard_B3",
expectedResult: false,
},
{
input: "Standard_D1_v2",
expectedResult: false,
},
{
input: "Standard_L3",
expectedResult: false,
},
{
input: "Standard_NC6",
expectedResult: false,
},
{
input: "Standard_G4",
expectedResult: false,
},
{
input: "Standard_D2_v2",
expectedResult: true,
},
{
input: "Standard_DS2_v2",
expectedResult: true,
},
{
input: "",
expectedResult: true,
},
}

for _, c := range cases {
result := AcceleratedNetworkingSupported(c.input)
if c.expectedResult != result {
t.Fatalf("AcceleratedNetworkingSupported returned unexpected result: expected %t but got %t", c.expectedResult, result)
}
}
}

0 comments on commit bc738c6

Please sign in to comment.