From 1ffcab78de4fac975a477c14ad80467beb97f9d4 Mon Sep 17 00:00:00 2001 From: Dmitry Lopatin <93423466+LopatinDmitr@users.noreply.github.com> Date: Thu, 16 May 2024 12:14:24 +0300 Subject: [PATCH] fix(vm): add value of the guest os info - fix adding value of the guest os info from VMI to VM - fix bug with sticking 'Message' in 'Status' for VM Signed-off-by: Dmitry Lopatin --- crds/virtualmachine.yaml | 1 + .../virtualization-artifact/pkg/controller/vm_reconciler.go | 4 ++-- .../pkg/controller/vm_reconciler_state.go | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crds/virtualmachine.yaml b/crds/virtualmachine.yaml index a942b04b9..35dfca7c8 100644 --- a/crds/virtualmachine.yaml +++ b/crds/virtualmachine.yaml @@ -910,6 +910,7 @@ spec: properties: guestOSInfo: type: object + x-kubernetes-preserve-unknown-fields: true description: | Guest OS information obtained from the QEMU Guest Agent. The agent must be pre-installed. diff --git a/images/virtualization-artifact/pkg/controller/vm_reconciler.go b/images/virtualization-artifact/pkg/controller/vm_reconciler.go index 692e69014..d438f30a0 100644 --- a/images/virtualization-artifact/pkg/controller/vm_reconciler.go +++ b/images/virtualization-artifact/pkg/controller/vm_reconciler.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "os" + "reflect" "strings" "time" @@ -96,7 +97,7 @@ func (r *VMReconciler) SetupController(_ context.Context, mgr manager.Manager, c UpdateFunc: func(e event.UpdateEvent) bool { oldVM := e.ObjectOld.(*virtv1.VirtualMachineInstance) newVM := e.ObjectNew.(*virtv1.VirtualMachineInstance) - return oldVM.Status.Phase != newVM.Status.Phase + return !reflect.DeepEqual(oldVM.Status, newVM.Status) }, }, ); err != nil { @@ -319,7 +320,6 @@ func (r *VMReconciler) UpdateStatus(_ context.Context, _ reconcile.Request, stat case state.vmIsStarting(): state.VM.Changed().Status.Phase = virtv2.MachineStarting case state.vmIsRunning(): - // TODO We need to rerun this block because KVVMI status fields may be updated with a delay. state.VM.Changed().Status.Phase = virtv2.MachineRunning state.VM.Changed().Status.GuestOSInfo = state.KVVMI.Status.GuestOSInfo state.VM.Changed().Status.Node = state.KVVMI.Status.NodeName diff --git a/images/virtualization-artifact/pkg/controller/vm_reconciler_state.go b/images/virtualization-artifact/pkg/controller/vm_reconciler_state.go index e00827272..5c1ed3c89 100644 --- a/images/virtualization-artifact/pkg/controller/vm_reconciler_state.go +++ b/images/virtualization-artifact/pkg/controller/vm_reconciler_state.go @@ -207,7 +207,6 @@ func (state *VMReconcilerState) Reload(ctx context.Context, req reconcile.Reques state.VMDByName = vmdByName state.VMIByName = vmiByName state.CVMIByName = cvmiByName - state.StatusMessage = state.VM.Current().Status.Message state.RestartAwaitingChanges = state.VM.Current().Status.RestartAwaitingChanges return nil