Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ func (h *SyncKvvmHandler) syncKVVM(ctx context.Context, s state.VirtualMachineSt
if err != nil {
return false, fmt.Errorf("detect changes on the stopped internal virtual machine: %w", err)
}
if hasVMChanges {
hasVMClassChanges, err := h.detectVMClassSpecChanges(ctx, s)
if err != nil {
return false, fmt.Errorf("detect changes on the stopped internal virtual machine: %w", err)
}
if hasVMChanges || hasVMClassChanges {
err := h.updateKVVM(ctx, s)
if err != nil {
return false, fmt.Errorf("update stopped internal virtual machine: %w", err)
Expand Down Expand Up @@ -571,6 +575,21 @@ func (h *SyncKvvmHandler) detectVMSpecChanges(ctx context.Context, s state.Virtu
return currentKvvm.Annotations[annotations.AnnVMLastAppliedSpec] != newKvvm.Annotations[annotations.AnnVMLastAppliedSpec], nil
}

// detectVMClassSpecChanges returns true and no error if specification has changes.
func (h *SyncKvvmHandler) detectVMClassSpecChanges(ctx context.Context, s state.VirtualMachineState) (bool, error) {
currentKvvm, err := s.KVVM(ctx)
if err != nil {
return false, err
}

newKvvm, err := MakeKVVMFromVMSpec(ctx, s)
if err != nil {
return false, err
}

return currentKvvm.Annotations[annotations.AnnVMClassLastAppliedSpec] != newKvvm.Annotations[annotations.AnnVMClassLastAppliedSpec], nil
}

// canApplyChanges returns true if changes can be applied right now.
//
// Wait if changes are disruptive, and approval mode is manual, and VM is still running.
Expand Down
Loading