Skip to content

Commit e8eeaef

Browse files
authored
fix(vm): disconnecting Main network (#2185)
This fixes a bug where disabling the Main network did not remove the cilium annotation from KVVMI. Signed-off-by: Dmitry Lopatin <dmitry.lopatin@flant.com>
1 parent 15d51ef commit e8eeaef

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

images/virtualization-artifact/pkg/controller/kvbuilder/kvvm.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ func (b *KVVM) SetKVVMIAnnotation(annoKey, annoValue string) {
119119
b.Resource.Spec.Template.ObjectMeta.SetAnnotations(anno)
120120
}
121121

122+
func (b *KVVM) RemoveKVVMIAnnotation(annoKey string) {
123+
anno := b.Resource.Spec.Template.ObjectMeta.GetAnnotations()
124+
if anno == nil {
125+
return
126+
}
127+
128+
delete(anno, annoKey)
129+
130+
b.Resource.Spec.Template.ObjectMeta.SetAnnotations(anno)
131+
}
132+
122133
func (b *KVVM) SetCPUModel(class *v1alpha2.VirtualMachineClass) error {
123134
if b.Resource.Spec.Template.Spec.Domain.CPU == nil {
124135
b.Resource.Spec.Template.Spec.Domain.CPU = &virtv1.CPU{}

images/virtualization-artifact/pkg/controller/kvbuilder/kvvm_utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ func ApplyVirtualMachineSpec(
290290
if ipAddress != "" {
291291
// Set ip address cni request annotation.
292292
kvvm.SetKVVMIAnnotation(netmanager.AnnoIPAddressCNIRequest, ipAddress)
293+
} else {
294+
kvvm.RemoveKVVMIAnnotation(netmanager.AnnoIPAddressCNIRequest)
293295
}
294296

295297
// Set live migration annotation.

0 commit comments

Comments
 (0)