Skip to content

Commit

Permalink
fix setting primary nic in scalesets
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Lieberman committed Jul 15, 2022
1 parent 24b09a8 commit 2723c89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions azure/services/scalesets/scalesets.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ func (s *Service) buildVMSSFromSpec(ctx context.Context, vmssSpec azure.ScaleSet
// Create any remaining private IPConfigs
for j := 0; j < n.PrivateIPConfigs-n.PublicIPConfigs; j++ {
ipconfig := compute.VirtualMachineScaleSetIPConfiguration{
Name: to.StringPtr(fmt.Sprintf("private-ipConfig%v", j)),
Name: to.StringPtr(fmt.Sprintf("private-ipConfig-%v", j)),
VirtualMachineScaleSetIPConfigurationProperties: &compute.VirtualMachineScaleSetIPConfigurationProperties{
PrivateIPAddressVersion: compute.IPVersionIPv4,
Subnet: &compute.APIEntityReference{
Expand All @@ -532,14 +532,14 @@ func (s *Service) buildVMSSFromSpec(ctx context.Context, vmssSpec azure.ScaleSet
}
if i == 0 {
ipconfigs[0].LoadBalancerBackendAddressPools = &backendAddressPools
nicConfig.VirtualMachineScaleSetNetworkConfigurationProperties.Primary = to.BoolPtr(true)
}
ipconfigs[0].Primary = to.BoolPtr(true)
nicConfig.VirtualMachineScaleSetNetworkConfigurationProperties.IPConfigurations = &ipconfigs
}
}
nicConfigs = append(nicConfigs, nicConfig)
}
nicConfigs[0].VirtualMachineScaleSetNetworkConfigurationProperties.Primary = to.BoolPtr(true)
vmss.VirtualMachineScaleSetProperties.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations = &nicConfigs
} else {
// Set default interface configuration if no custom ones are specified
Expand Down
6 changes: 3 additions & 3 deletions azure/services/scalesets/scalesets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,12 @@ func TestReconcileVMSS(t *testing.T) {
(*netConfigs)[0].Name = to.StringPtr("my-vmss-0")
(*netConfigs)[0].EnableIPForwarding = nil
nic1IPConfigs := (*netConfigs)[0].IPConfigurations
(*nic1IPConfigs)[0].Name = to.StringPtr("private-ipConfig0")
(*nic1IPConfigs)[0].Name = to.StringPtr("private-ipConfig-0")
(*nic1IPConfigs)[0].PrivateIPAddressVersion = compute.IPVersionIPv4
(*netConfigs)[0].EnableAcceleratedNetworking = to.BoolPtr(true)
vmssIPConfigs := []compute.VirtualMachineScaleSetIPConfiguration{
{
Name: to.StringPtr("private-ipConfig0"),
Name: to.StringPtr("private-ipConfig-0"),
VirtualMachineScaleSetIPConfigurationProperties: &compute.VirtualMachineScaleSetIPConfigurationProperties{
Primary: to.BoolPtr(true),
PrivateIPAddressVersion: compute.IPVersionIPv4,
Expand All @@ -303,7 +303,7 @@ func TestReconcileVMSS(t *testing.T) {
},
},
{
Name: to.StringPtr("private-ipConfig1"),
Name: to.StringPtr("private-ipConfig-1"),
VirtualMachineScaleSetIPConfigurationProperties: &compute.VirtualMachineScaleSetIPConfigurationProperties{
Primary: to.BoolPtr(false),
PrivateIPAddressVersion: compute.IPVersionIPv4,
Expand Down

0 comments on commit 2723c89

Please sign in to comment.