Skip to content

Commit

Permalink
added additional check for multiple LANs of the same name
Browse files Browse the repository at this point in the history
  • Loading branch information
lubedacht committed Jan 15, 2024
1 parent e74e0a8 commit 1abb85d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions internal/service/cloud/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,27 @@ func (s *Service) GetLAN() (*sdk.Lan, error) {
return nil, fmt.Errorf("could not list LANs in datacenter %s: %w", s.dataCenterID(), err)
}

expectedName := s.LANName()
var (
expectedName = s.LANName()
lanCount = 0
foundLAN *sdk.Lan
)

for _, l := range *lans.Items {
if l.Properties.HasName() && *l.Properties.Name == expectedName {
return &l, nil
l := l
foundLAN = &l
lanCount++
}

// If there are multiple LANs with the same name, we should return an error.
// Our logic won't be able to proceed as we cannot select the correct lan.
if lanCount > 1 {
return nil, fmt.Errorf("found multiple LANs with the name: %s", expectedName)
}
}
return nil, nil

return foundLAN, nil
}

// ReconcileLANDeletion ensures there's no cluster LAN available, requesting for deletion (if no other resource
Expand Down

0 comments on commit 1abb85d

Please sign in to comment.