Skip to content

Commit

Permalink
OpenStack: fix controlPlanePort validation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MaysaMacedo authored and openshift-cherrypick-robot committed Mar 4, 2024
1 parent b6c1765 commit c4a7386
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions pkg/asset/installconfig/openstack/validation/cloudinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ func (ci *CloudInfo) collectInfo(ic *types.InstallConfig, opts *clientconfig.Cli
if err != nil {
return err
}
ci.ControlPlanePortNetwork, err = ci.getNetwork(controlPlanePort.Network.Name, controlPlanePort.Network.ID)

ci.ControlPlanePortNetwork, err = ci.getNetwork(controlPlanePort)
if err != nil {
return err
}
Expand Down Expand Up @@ -317,10 +318,18 @@ func (ci *CloudInfo) getNetworkByName(networkName string) (*networks.Network, er
return network, nil
}

func (ci *CloudInfo) getNetwork(networkName, networkID string) (*networks.Network, error) {
opts := networks.ListOpts{
ID: networkID,
Name: networkName,
func (ci *CloudInfo) getNetwork(controlPlanePort *openstack.PortTarget) (*networks.Network, error) {
networkName := controlPlanePort.Network.Name
networkID := controlPlanePort.Network.ID
if networkName == "" && networkID == "" {
return nil, nil
}
opts := networks.ListOpts{}
if networkID != "" {
opts.ID = controlPlanePort.Network.ID
}
if networkName != "" {
opts.Name = controlPlanePort.Network.Name
}
allPages, err := networks.List(ci.clients.networkClient, opts).AllPages()
if err != nil {
Expand Down

0 comments on commit c4a7386

Please sign in to comment.