Skip to content

Commit f22baab

Browse files
committed
Search by either port ID or name/network
When port ID is available we should just search by the ID and not combine name and network of the port.
1 parent 504d8d6 commit f22baab

File tree

1 file changed

+5
-4
lines changed
  • pkg/cloud/services/networking

1 file changed

+5
-4
lines changed

pkg/cloud/services/networking/port.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,14 @@ func (s *Service) ensurePortTagsAndTrunk(port *ports.Port, eventObject runtime.O
156156
// and that the port has suitable tags and trunk. If the PortStatus is already known,
157157
// use the ID when filtering for existing ports.
158158
func (s *Service) EnsurePort(eventObject runtime.Object, portSpec *infrav1.ResolvedPortSpec, portStatus infrav1.PortStatus) (*ports.Port, error) {
159-
opts := ports.ListOpts{
160-
Name: portSpec.Name,
161-
NetworkID: portSpec.NetworkID,
162-
}
159+
opts := ports.ListOpts{}
163160
if portStatus.ID != "" {
164161
opts.ID = portStatus.ID
165162
}
163+
else {
164+
opts.Name = portSpec.Name
165+
opts.NetworkID = portSpec.NetworkID
166+
}
166167

167168
existingPorts, err := s.client.ListPort(opts)
168169
if err != nil {

0 commit comments

Comments
 (0)