Skip to content

Detect VMI guest-agent availability before quiesce, with explicit user override - #218

Merged
openshift-merge-bot[bot] merged 4 commits into
oadp-devfrom
copilot/detect-vmi-guest-agent-availability
Sep 4, 2026
Merged

openshift-merge-bot[bot] merged 4 commits into
oadp-devfrom
copilot/detect-vmi-guest-agent-availability

Conversation

Copilot AI commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

KubeVirt datamover backups always attempted to quiesce the guest filesystem, producing noisy freeze-failure warnings on VMs without a QEMU guest agent (e.g. Cirros test VMs). The controller now makes the quiesce decision from the VM's guest-agent status instead of requiring workload-specific annotations.

Guest-agent detection

  • Added common.IsGuestAgentConnected(vmi): reports whether VirtualMachineInstance.Status.Conditions[type=AgentConnected].Status == True.
  • Added determineSkipQuiesce in the DataUpload controller: fetches the VM's VMI and sets VirtualMachineBackup.Spec.SkipQuiesce accordingly. If the VMI can't be fetched, defaults to skip-quiesce (crash-consistent) as the safe fallback.

Explicit user override

  • New kubevirt-datamover.io/quiesce annotation on DataUpload: "true" forces quiesce, "false" forces skip-quiesce, regardless of guest-agent state. Any other value (or unset) falls back to auto-detection. The override always takes precedence.
metadata:
  annotations:
    kubevirt-datamover.io/quiesce: "false"  # force crash-consistent backup

Wiring & permissions

  • ensureVMBackup now threads the resolved skipQuiesce value into the created VirtualMachineBackup spec.
  • Added RBAC for get;list;watch on virtualmachineinstances; config/rbac/role.yaml regenerated via make manifests.

Documentation

  • README documents the default auto-detection behavior and override annotation, with precedence rules.

@openshift-ci

openshift-ci Bot commented Sep 1, 2026

Copy link
Copy Markdown

Hi @Copilot. Thanks for your PR.

I'm waiting for a migtools member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copilot AI and others added 2 commits September 1, 2026 21:30
Co-authored-by: kaovilai <11228024+kaovilai@users.noreply.github.com>
Co-authored-by: kaovilai <11228024+kaovilai@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve quiesce behavior based on VMI guest-agent availability Detect VMI guest-agent availability before quiesce, with explicit user override Sep 1, 2026
Copilot AI requested a review from kaovilai September 1, 2026 21:35
@kaovilai
kaovilai marked this pull request as ready for review September 2, 2026 17:09
@openshift-ci
openshift-ci Bot requested a review from sseago September 2, 2026 17:10
}

vmi := &kubevirtcorev1.VirtualMachineInstance{}
if err := r.Get(ctx, types.NamespacedName{Name: vmRef.Name, Namespace: vmRef.Namespace}, vmi); err != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use r.APIReader for this lookup when it is configured, with the cached client as a fallback? This is a one-shot safety decision, and a stale cached VMI can still report AgentConnected=True after the agent has disconnected. That would create SkipQuiesce=false and reintroduce the freeze warning this PR is meant to avoid. The controller already uses APIReader for fresh VMB status reads.

Comment thread config/rbac/role.yaml
- apiGroups:
- kubevirt.io
resources:
- virtualmachineinstances

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please propagate this new virtualmachineinstances permission to the OADP Operator manifests as part of this change. The controller is deployed through OADP Operator, which vendors this RBAC into config/kubevirt-datamover-controller_rbac/role.yaml and the bundle CSV. Without updating that copy, OADP deployments will not have permission to read VMIs and will always fall back to skip-quiesce.

},
}

tests := []struct {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add cases for an invalid or "auto" annotation value and for explicit "false" when the VMI is missing? These are documented behaviors and are especially relevant to the plugin integration, where absent/auto means automatic detection and false must remain an explicit override.

Comment thread pkg/common/constants.go Outdated
// controller quiesces only when the VM's VirtualMachineInstance
// reports status.conditions[type=AgentConnected].status == "True".
// This override always takes precedence over automatic detection.
AnnotationQuiesce = "kubevirt-datamover.io/quiesce"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets stick with SkipQuiesce, since that's the name of the VMBackup spec field. So across this PR, s/AnnotationQuiesce/AnnotationSkipQuiesce/, change the value to "kubevirt-datamover.io/skipQuiesce, with the appropriate s/false/true/ wherever needed.

// backup failure from attempting to quiesce a VM whose agent state is
// unknown.
func (r *KubeVirtDataUploadReconciler) determineSkipQuiesce(ctx context.Context, logger logr.Logger, du *velerov2alpha1.DataUpload, vmRef *common.VMReference) bool {
if raw, ok := du.Annotations[common.AnnotationQuiesce]; ok {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SkipQuiesce

if raw, ok := du.Annotations[common.AnnotationQuiesce]; ok {
if override, err := strconv.ParseBool(raw); err == nil {
logger.Info("Quiesce explicitly overridden via annotation", "quiesce", override)
return !override

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/!overrride/override/

- Rename AnnotationQuiesce -> AnnotationSkipQuiesce, matching the
  VirtualMachineBackup.Spec.SkipQuiesce field name, with inverted
  semantics: "true" forces skip-quiesce, "false" forces quiesce.
- Use r.APIReader (uncached) for the VMI lookup when configured, since
  this is a one-shot safety decision and a stale cached VMI can still
  report AgentConnected=True after the agent disconnected.
- Fix double-negative typo (!override -> override) that fell out of
  the rename.
- Add test coverage for invalid/"auto" annotation values and an
  explicit force-quiesce override when no VMI exists.

Signed-off-by: Tiger Kaovilai <passawit.kaovilai@gmail.com>
@sseago

sseago commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

/lgtm

@openshift-ci

openshift-ci Bot commented Sep 3, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Copilot, shubham-pampattiwar, sseago

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [shubham-pampattiwar,sseago]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot
openshift-merge-bot Bot merged commit 02fe1a7 into oadp-dev Sep 4, 2026
12 checks passed
@openshift-merge-bot
openshift-merge-bot Bot deleted the copilot/detect-vmi-guest-agent-availability branch September 4, 2026 01:12
openshift-merge-bot Bot pushed a commit to openshift/oadp-operator that referenced this pull request Sep 4, 2026
kubevirt-datamover-controller PR migtools/kubevirt-datamover-controller#218
adds a virtualmachineinstances get/list/watch permission needed for its
guest-agent-based quiesce detection. Propagate it here so OADP-deployed
controllers actually have it, instead of always falling back to
skip-quiesce.

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
@sseago

sseago commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

/cherry-pick oadp-1.6

@openshift-cherrypick-robot

Copy link
Copy Markdown

@sseago: #218 failed to apply on top of branch "oadp-1.6":

Patch is empty.
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To record the empty patch as an empty commit, run "git am --allow-empty".
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"

Details

In response to this:

/cherry-pick oadp-1.6

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

openshift-merge-bot Bot pushed a commit to openshift/oadp-operator that referenced this pull request Sep 4, 2026
kubevirt-datamover-controller PR migtools/kubevirt-datamover-controller#218
adds a virtualmachineinstances get/list/watch permission needed for its
guest-agent-based quiesce detection. Propagate it here so OADP-deployed
controllers actually have it, instead of always falling back to
skip-quiesce.

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
openshift-merge-bot Bot pushed a commit that referenced this pull request Sep 4, 2026
- Rename AnnotationQuiesce -> AnnotationSkipQuiesce, matching the
  VirtualMachineBackup.Spec.SkipQuiesce field name, with inverted
  semantics: "true" forces skip-quiesce, "false" forces quiesce.
- Use r.APIReader (uncached) for the VMI lookup when configured, since
  this is a one-shot safety decision and a stale cached VMI can still
  report AgentConnected=True after the agent disconnected.
- Fix double-negative typo (!override -> override) that fell out of
  the rename.
- Add test coverage for invalid/"auto" annotation values and an
  explicit force-quiesce override when no VMI exists.

Signed-off-by: Tiger Kaovilai <passawit.kaovilai@gmail.com>
msfrucht pushed a commit to msfrucht/oadp-operator that referenced this pull request Sep 9, 2026
kubevirt-datamover-controller PR migtools/kubevirt-datamover-controller#218
adds a virtualmachineinstances get/list/watch permission needed for its
guest-agent-based quiesce detection. Propagate it here so OADP-deployed
controllers actually have it, instead of always falling back to
skip-quiesce.

Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect VMI guest-agent availability before quiesce and support user override

5 participants