From 0236221b313b69696ca68aeddae461fe2a38f080 Mon Sep 17 00:00:00 2001 From: Matthew Arnold Date: Thu, 7 Nov 2024 11:42:47 -0500 Subject: [PATCH 1/2] MTV-1645 Change default network annotation. Importer pod can get stuck creating if the wrong annotation is set. Signed-off-by: Matthew Arnold --- pkg/controller/plan/kubevirt.go | 2 +- pkg/lib-volume-populator/populator-machinery/controller.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/controller/plan/kubevirt.go b/pkg/controller/plan/kubevirt.go index d3b1fb8d0..21236d97d 100644 --- a/pkg/controller/plan/kubevirt.go +++ b/pkg/controller/plan/kubevirt.go @@ -54,7 +54,7 @@ import ( // Annotations const ( // Transfer network annotation (value=network-attachment-definition name) - AnnDefaultNetwork = "v1.multus-cni.io/default-network" + AnnDefaultNetwork = "k8s.v1.cni.cncf.io/networks" // Contains validations for a Kubevirt VM. Needs to be removed when // creating a VM from a template. AnnKubevirtValidations = "vm.kubevirt.io/validations" diff --git a/pkg/lib-volume-populator/populator-machinery/controller.go b/pkg/lib-volume-populator/populator-machinery/controller.go index d075b7170..55353e8e8 100644 --- a/pkg/lib-volume-populator/populator-machinery/controller.go +++ b/pkg/lib-volume-populator/populator-machinery/controller.go @@ -75,7 +75,7 @@ const ( reasonPodFinished = "PopulatorFinished" reasonPVCCreationError = "PopulatorPVCCreationError" reasonPopulatorProgress = "PopulatorProgress" - AnnDefaultNetwork = "v1.multus-cni.io/default-network" + AnnDefaultNetwork = "k8s.v1.cni.cncf.io/networks" AnnPopulatorReCreations = "recreations" qemuGroup = 107 From 72dbd8ffbf60c5ee57249644e074ed34f41b569c Mon Sep 17 00:00:00 2001 From: Matthew Arnold Date: Mon, 11 Nov 2024 09:48:06 -0500 Subject: [PATCH 2/2] Rename transfer network annotation. Signed-off-by: Matthew Arnold --- pkg/controller/plan/kubevirt.go | 6 +++--- pkg/lib-volume-populator/populator-machinery/controller.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/controller/plan/kubevirt.go b/pkg/controller/plan/kubevirt.go index 21236d97d..0d5be1f30 100644 --- a/pkg/controller/plan/kubevirt.go +++ b/pkg/controller/plan/kubevirt.go @@ -54,7 +54,7 @@ import ( // Annotations const ( // Transfer network annotation (value=network-attachment-definition name) - AnnDefaultNetwork = "k8s.v1.cni.cncf.io/networks" + AnnTransferNetwork = "k8s.v1.cni.cncf.io/networks" // Contains validations for a Kubevirt VM. Needs to be removed when // creating a VM from a template. AnnKubevirtValidations = "vm.kubevirt.io/validations" @@ -1227,7 +1227,7 @@ func (r *KubeVirt) dataVolumes(vm *plan.VMStatus, secret *core.Secret, configMap annotations[planbase.AnnRetainAfterCompletion] = "true" } if r.Plan.Spec.TransferNetwork != nil { - annotations[AnnDefaultNetwork] = path.Join( + annotations[AnnTransferNetwork] = path.Join( r.Plan.Spec.TransferNetwork.Namespace, r.Plan.Spec.TransferNetwork.Name) } if r.Plan.Spec.Warm || !r.Destination.Provider.IsHost() || r.Plan.IsSourceProviderOCP() { @@ -1757,7 +1757,7 @@ func (r *KubeVirt) guestConversionPod(vm *plan.VMStatus, vmVolumes []cnv.Volume, // pod annotations annotations := map[string]string{} if r.Plan.Spec.TransferNetwork != nil { - annotations[AnnDefaultNetwork] = path.Join( + annotations[AnnTransferNetwork] = path.Join( r.Plan.Spec.TransferNetwork.Namespace, r.Plan.Spec.TransferNetwork.Name) } // pod diff --git a/pkg/lib-volume-populator/populator-machinery/controller.go b/pkg/lib-volume-populator/populator-machinery/controller.go index 55353e8e8..9d6f0acbc 100644 --- a/pkg/lib-volume-populator/populator-machinery/controller.go +++ b/pkg/lib-volume-populator/populator-machinery/controller.go @@ -75,7 +75,7 @@ const ( reasonPodFinished = "PopulatorFinished" reasonPVCCreationError = "PopulatorPVCCreationError" reasonPopulatorProgress = "PopulatorProgress" - AnnDefaultNetwork = "k8s.v1.cni.cncf.io/networks" + AnnTransferNetwork = "k8s.v1.cni.cncf.io/networks" AnnPopulatorReCreations = "recreations" qemuGroup = 107 @@ -594,7 +594,7 @@ func (c *controller) syncPvc(ctx context.Context, key, pvcNamespace, pvcName str annotations := make(map[string]string) if found { // Join the transfer network namespace and name - annotations[AnnDefaultNetwork] = fmt.Sprintf("%s/%s", transferNetwork["namespace"], transferNetwork["name"]) + annotations[AnnTransferNetwork] = fmt.Sprintf("%s/%s", transferNetwork["namespace"], transferNetwork["name"]) } migration, found, err := unstructured.NestedString(crInstance.Object, "metadata", "labels", "migration") if err != nil {