From d0712b3bdac6da92c236eda0268a98760763a99d Mon Sep 17 00:00:00 2001 From: Liran Rotenberg Date: Sun, 14 Apr 2024 17:48:07 +0300 Subject: [PATCH] Skip querying preference if OS is empty We may have VM without OS set. In such case we get an empty string from the map. This patch will prevent querying and erroring when we hit this case. Signed-off-by: Liran Rotenberg --- pkg/controller/plan/kubevirt.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/controller/plan/kubevirt.go b/pkg/controller/plan/kubevirt.go index f04c1300c..56539a0d2 100644 --- a/pkg/controller/plan/kubevirt.go +++ b/pkg/controller/plan/kubevirt.go @@ -1270,6 +1270,10 @@ func (r *KubeVirt) vmPreference(vm *plan.VMStatus) (virtualMachine *cnv.VirtualM if err != nil { return } + if preferenceName == "" { + err = liberr.New("couldn't find a corresponding preference", "vm", vm) + return + } preferenceName, kind, err := r.getPreference(vm, preferenceName) if err != nil {