Skip to content

Commit b734ccb

Browse files
committed
OpenStack: fix controlPlanePort validation
When the controlPlanePort has no network defined, we attempt to validate the network using the empty name and id, this results in multiple networks found, which breaks the pre-flight validation resulting in it being skipped. This commit fixed the issue, by only running validation on that field if it has content defined.
1 parent ef713aa commit b734ccb

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

pkg/asset/installconfig/openstack/validation/cloudinfo.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ func (ci *CloudInfo) collectInfo(ic *types.InstallConfig, opts *clientconfig.Cli
185185
if err != nil {
186186
return err
187187
}
188-
ci.ControlPlanePortNetwork, err = ci.getNetwork(controlPlanePort.Network.Name, controlPlanePort.Network.ID)
188+
189+
ci.ControlPlanePortNetwork, err = ci.getNetwork(controlPlanePort)
189190
if err != nil {
190191
return err
191192
}
@@ -317,10 +318,18 @@ func (ci *CloudInfo) getNetworkByName(networkName string) (*networks.Network, er
317318
return network, nil
318319
}
319320

320-
func (ci *CloudInfo) getNetwork(networkName, networkID string) (*networks.Network, error) {
321-
opts := networks.ListOpts{
322-
ID: networkID,
323-
Name: networkName,
321+
func (ci *CloudInfo) getNetwork(controlPlanePort *openstack.PortTarget) (*networks.Network, error) {
322+
networkName := controlPlanePort.Network.Name
323+
networkID := controlPlanePort.Network.ID
324+
if networkName == "" && networkID == "" {
325+
return nil, nil
326+
}
327+
opts := networks.ListOpts{}
328+
if networkID != "" {
329+
opts.ID = controlPlanePort.Network.ID
330+
}
331+
if networkName != "" {
332+
opts.Name = controlPlanePort.Network.Name
324333
}
325334
allPages, err := networks.List(ci.clients.networkClient, opts).AllPages()
326335
if err != nil {

0 commit comments

Comments
 (0)