Skip to content

B #8198: Check Domain not found in kvm/shutdown and destroy exit code - #8199

Open
trukhinyuri wants to merge 1 commit into
OpenNebula:masterfrom
trukhinyuri:fix-kvm-shutdown-dominfo-check
Open

trukhinyuri wants to merge 1 commit into
OpenNebula:masterfrom
trukhinyuri:fix-kvm-shutdown-dominfo-check

Conversation

@trukhinyuri

Copy link
Copy Markdown
Contributor

Description

Fixes #8198.

  • In src/vmm_mad/remotes/kvm/shutdown, check DOMINFO_OUT for domain not found / failed to get domain / no domain with matching (or State: shut off) before and during retry $TIMEOUT monitor, rather than treating any non-zero virsh dominfo exit status (such as a transient libvirtd connection failure) as a shut-down domain.
  • In force_shutdown (src/mad/sh/scripts_common.sh), execute $command via exec_and_log "$command" "Could not destroy $deploy_id" when FORCE_DESTROY=yes so a failed virsh destroy after shutdown timeout is reported instead of silently ignored.

Branches to which this PR applies

  • master
  • one-7.0

  • Check this if this PR should not be squashed

… exit code

Ensure src/vmm_mad/remotes/kvm/shutdown only treats virsh dominfo
failures as an already-terminated domain when virsh reports that the
domain was not found (or is in 'shut off' state), rather than exiting 0
on transient libvirtd connection failures. Also check the exit status of
the destroy command in force_shutdown when FORCE_DESTROY=yes.

Signed-off-by: Iurii Trukhin <yuri@trukhin.com>
Copilot AI balanced review requested due to automatic review settings October 15, 2026 01:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Shutdown detection still accepts generic lookup failures and misses already-stopped domains during preflight.

2 open findings
What changed in this PR

This PR addresses #8198 by tightening KVM shutdown detection and reporting forced-destroy failures.

Changes:

  • Inspect domain-query output before shutdown and during polling.
  • Route forced destruction through exec_and_log to propagate failures.
File Description
src/​vmm_mad/​remotes/​kvm/​shutdown Adds diagnostic checks and shut-off-state detection during polling.
src/​mad/​sh/​scripts_common.sh Reports forced-destroy command failures.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

DOMINFO_OUT=$(LC_ALL=C virsh --connect $LIBVIRT_URI --readonly dominfo "$deploy_id" 2>&1)
DOMINFO_RC=$?
if [ $DOMINFO_RC -ne 0 ]; then
if echo "$DOMINFO_OUT" | grep -qiE "domain not found|failed to get domain|no domain with matching"; then
fi
error_message "Could not query domain $deploy_id: $DOMINFO_OUT"
exit 1
fi
@paczerny

paczerny commented Nov 2, 2026

Copy link
Copy Markdown
Member

Both expressions accept failed to get domain as confirmation that the domain is absent. Libvirt emits this generic message whenever domain lookup fails, without checking whether the cause is a missing domain or a connection failure. The failure this PR intends to fix therefore remains possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vmm/kvm/shutdown masks transient virsh dominfo errors and ignores force_shutdown destroy failure

3 participants