Skip to content

Commit

Permalink
Merge pull request #5 from newrelic-forks/troubleshoot-subnets
Browse files Browse the repository at this point in the history
chore: check network interface earlier
  • Loading branch information
mytunguyen authored Jul 12, 2022
2 parents 6567927 + a362d56 commit 89f0f71
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions azure/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ func (m *MachineScope) GetVMImage(ctx context.Context) (*infrav1.Image, error) {
// Note: this logic exists only for purposes of ensuring backwards compatibility for old clusters created without the `subnetName` field being
// set, and should be removed in the future when this field is no longer optional.
func (m *MachineScope) SetSubnetName() error {
if m.AzureMachine.Spec.SubnetName == "" {
if m.AzureMachine.Spec.SubnetName == "" && len(m.AzureMachine.Spec.NetworkInterfaces) == 0 {
subnetName := ""
subnets := m.Subnets()
var subnetCount int
Expand All @@ -716,7 +716,7 @@ func (m *MachineScope) SetSubnetName() error {
subnetName = subnet.Name
}
}
if (subnetCount == 0 || subnetCount > 1 || subnetName == "") && len(m.AzureMachine.Spec.NetworkInterfaces) == 0 {
if subnetCount == 0 || subnetCount > 1 || subnetName == "" {
return errors.New("a subnet name must be specified when no subnets are specified or more than 1 subnet of the same role exist")
}

Expand Down
4 changes: 2 additions & 2 deletions azure/scope/machinepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,12 +629,12 @@ func (m *MachinePoolScope) getDeploymentStrategy() machinepool.TypedDeleteSelect
// Note: this logic exists only for purposes of ensuring backwards compatibility for old clusters created without the `subnetName` field being
// set, and should be removed in the future when this field is no longer optional.
func (m *MachinePoolScope) SetSubnetName() error {
if m.AzureMachinePool.Spec.Template.SubnetName == "" {
if m.AzureMachinePool.Spec.Template.SubnetName == "" && len(m.AzureMachinePool.Spec.Template.NetworkInterfaces) == 0 {
subnetName := ""
for _, subnet := range m.NodeSubnets() {
subnetName = subnet.Name
}
if (len(m.NodeSubnets()) == 0 || len(m.NodeSubnets()) > 1 || subnetName == "") && len(m.AzureMachinePool.Spec.Template.NetworkInterfaces) == 0 {
if len(m.NodeSubnets()) == 0 || len(m.NodeSubnets()) > 1 || subnetName == "" {
return errors.New("a subnet name must be specified when no subnets are specified or more than 1 subnet of role 'node' exist")
}

Expand Down

0 comments on commit 89f0f71

Please sign in to comment.