Skip to content

Commit

Permalink
ocp: consider missing namespace in network name
Browse files Browse the repository at this point in the history
The namespace may be missing from the network name, in this case we need
to use the VM's namespace

Signed-off-by: Benny Zlotnik <[email protected]>
  • Loading branch information
bennyz authored and ahadas committed Sep 18, 2023
1 parent ea39abb commit f792230
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/controller/plan/adapter/ocp/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,16 @@ func (r *Validator) NetworksMapped(vmRef ref.Ref) (ok bool, err error) {
return false, err
}
} else if net.Multus != nil {
namespace := strings.Split(net.Multus.NetworkName, "/")[0]
name := strings.Split(net.Multus.NetworkName, "/")[1]
var namespace, name string

if !strings.Contains(net.Multus.NetworkName, "/") {
namespace = vmRef.Namespace
name = net.Multus.NetworkName
} else {
splitName := strings.Split(net.Multus.NetworkName, "/")
namespace, name = splitName[0], splitName[1]
}

_, found := r.plan.Referenced.Map.Network.FindNetworkByNameAndNamespace(namespace, name)
if !found {
err = liberr.Wrap(
Expand Down

0 comments on commit f792230

Please sign in to comment.