Skip to content

Commit 69485bb

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 69485bb

File tree

1 file changed

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

1 file changed

+8
-5
lines changed

pkg/cloud/services/networking/port.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,15 @@ 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-
}
163159
if portStatus.ID != "" {
164-
opts.ID = portStatus.ID
160+
opts := ports.ListOpts{
161+
ID: portStatus.ID,
162+
}
163+
} else {
164+
opts := ports.ListOpts{
165+
Name: portSpec.Name,
166+
NetworkID: portSpec.NetworkID,
167+
}
165168
}
166169

167170
existingPorts, err := s.client.ListPort(opts)

0 commit comments

Comments
 (0)