Skip to content

Commit 65e2174

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 65e2174

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

controllers/openstackserver_controller_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ var listDefaultPorts = func(r *recorders) {
119119

120120
var listDefaultPortsWithID = func(r *recorders) {
121121
r.network.ListPort(ports.ListOpts{
122-
Name: openStackServerName + "-0",
123-
ID: portUUID,
124-
NetworkID: networkUUID,
122+
ID: portUUID,
125123
}).Return([]ports.Port{
126124
{
127125
ID: portUUID,

pkg/cloud/services/networking/port.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ 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
162+
} else {
163+
opts.Name = portSpec.Name
164+
opts.NetworkID = portSpec.NetworkID
165165
}
166166

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

0 commit comments

Comments
 (0)