From 5fcda406ed0a8afe24599a105ae353a2fed091d7 Mon Sep 17 00:00:00 2001 From: Dmitry Lopatin Date: Fri, 3 Apr 2026 11:31:23 +0300 Subject: [PATCH] fix(vm): disconnecting Main network This fixes a bug where disabling the Main network did not remove the cilium annotation from KVVMI. Signed-off-by: Dmitry Lopatin --- .../pkg/controller/kvbuilder/kvvm.go | 11 +++++++++++ .../pkg/controller/kvbuilder/kvvm_utils.go | 2 ++ 2 files changed, 13 insertions(+) diff --git a/images/virtualization-artifact/pkg/controller/kvbuilder/kvvm.go b/images/virtualization-artifact/pkg/controller/kvbuilder/kvvm.go index 33ce9d7e02..5ef04f9ed9 100644 --- a/images/virtualization-artifact/pkg/controller/kvbuilder/kvvm.go +++ b/images/virtualization-artifact/pkg/controller/kvbuilder/kvvm.go @@ -119,6 +119,17 @@ func (b *KVVM) SetKVVMIAnnotation(annoKey, annoValue string) { b.Resource.Spec.Template.ObjectMeta.SetAnnotations(anno) } +func (b *KVVM) RemoveKVVMIAnnotation(annoKey string) { + anno := b.Resource.Spec.Template.ObjectMeta.GetAnnotations() + if anno == nil { + return + } + + delete(anno, annoKey) + + b.Resource.Spec.Template.ObjectMeta.SetAnnotations(anno) +} + func (b *KVVM) SetCPUModel(class *v1alpha2.VirtualMachineClass) error { if b.Resource.Spec.Template.Spec.Domain.CPU == nil { b.Resource.Spec.Template.Spec.Domain.CPU = &virtv1.CPU{} diff --git a/images/virtualization-artifact/pkg/controller/kvbuilder/kvvm_utils.go b/images/virtualization-artifact/pkg/controller/kvbuilder/kvvm_utils.go index 8e09166b0d..594a6d7bdb 100644 --- a/images/virtualization-artifact/pkg/controller/kvbuilder/kvvm_utils.go +++ b/images/virtualization-artifact/pkg/controller/kvbuilder/kvvm_utils.go @@ -290,6 +290,8 @@ func ApplyVirtualMachineSpec( if ipAddress != "" { // Set ip address cni request annotation. kvvm.SetKVVMIAnnotation(netmanager.AnnoIPAddressCNIRequest, ipAddress) + } else { + kvvm.RemoveKVVMIAnnotation(netmanager.AnnoIPAddressCNIRequest) } // Set live migration annotation.