Skip to content

fix: wait for guest info to repopulate after add_nic reconfiguration - #865

Merged
myakove merged 2 commits into
RedHatQE:mainfrom
AmenB:fix/guest-info-after-add-nic
Nov 22, 2026
Merged

myakove merged 2 commits into
RedHatQE:mainfrom
AmenB:fix/guest-info-after-add-nic

Conversation

@AmenB

@AmenB AmenB commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

What

add_nic hot-adds a NIC to a powered-on vSphere clone. That reconfiguration makes vCenter reset the VM's guest info — guest.net and guest.guestFamily go empty until VMware Tools re-reports (~15s). Two problems followed from that:

  1. VMWareProvider.wait_for_vmware_guest_info() decided "guest info is ready" from powerState, guest.net and toolsStatus, but not guestFamily. It could therefore return while guestFamily was still empty — and guestFamily is what Guest Operations needs to identify the guest OS, so downstream IP-origin / NIC-name detection ran against stale data.
  2. The wait returns a bool on timeout and every caller ignored it. A timeout produced no error at all, just degraded data (visible only as the log line NIC ...: IP origin not available, followed by a Guest-Operations fallback).

Changes

  • libs/providers/vmware.py — add vm.guest.guestFamily to the readiness predicate, so the wait cannot return before Tools has repopulated the guest family.
  • utilities/vmware_guest_operations.py — new wait_guest_info_or_fail(): wraps the wait and raises ValueError naming the VM when it times out, instead of silently continuing.
  • conftest.py — route the two power-on waits and a new post-add_nic wait through wait_guest_info_or_fail(). The add_nic wait is skipped when the VM is powered off (a powered-off clone has no guest info to wait for and the wait would always time out).

Behaviour change to be aware of

A previously silent 120s wait timeout now surfaces as ValueError. That is intended (fail fast instead of using stale guest info), but it can appear on a host where Tools genuinely never reports — worth knowing when reading CI results.

Why it matters

Only tests with add_nic: true (multi-NIC / per-NIC NetworkMap scenarios) are exposed, and the race is timing-dependent: on an idle host Tools repopulates before the next read, so it passes; under parallel clones / loaded storage it does not, and the failure shows up as a wrong or missing NIC-name / static-IP assertion rather than anything pointing at guest info.

Testing

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@redhat-qe-bot1

Copy link
Copy Markdown

Report bugs in Issues

Welcome! 🎉

This pull request will be automatically processed with the following features:

🔄 Automatic Actions

  • Reviewer Assignment: Reviewers are automatically assigned based on the OWNERS file in the repository root
  • Size Labeling: PR size labels (XS, S, M, L, XL, XXL) are automatically applied based on changes
  • Issue Creation: Disabled for this repository
  • Branch Labeling: Branch-specific labels are applied to track the target branch
  • Auto-verification: Auto-verified users have their PRs automatically marked as verified
  • Labels: All label categories are enabled (default configuration)

📋 Available Commands

PR Status Management

  • /wip - Mark PR as work in progress (adds WIP: prefix to title)
  • /wip cancel - Remove work in progress status
  • /hold - Block PR merging (PR author or approvers)
  • /hold cancel - Unblock PR merging (PR author or approvers)
  • /verified - Mark PR as verified
  • /verified cancel - Remove verification status
  • /reprocess - Trigger complete PR workflow reprocessing (useful if webhook failed or configuration changed)
  • /regenerate-welcome - Regenerate this welcome message
  • /security-override - Set security check runs to pass (maintainers only)
  • /security-override cancel - Re-run security checks

Review & Approval

  • /lgtm - Approve changes (looks good to me)
  • /approve - Approve PR (approvers only)
  • /automerge - Enable automatic merging when all requirements are met (effective maintainers and approvers only)
  • /automerge cancel - Remove automerge label (effective maintainers and approvers only)
  • /assign-reviewers - Assign reviewers based on OWNERS file
  • /assign-reviewer @username - Assign specific reviewer
  • /check-can-merge - Check if PR meets merge requirements

Testing & Validation

  • /retest tox - Run Python test suite with tox
  • /retest build-container - Rebuild and test container image
  • /retest conventional-title - Validate commit message format
  • /retest all - Run all available tests

Container Operations

  • /build-and-push-container - Build and push container image (tagged with PR number)
    • Supports additional build arguments: /build-and-push-container --build-arg KEY=value

Cherry-pick Operations

  • /cherry-pick <branch> - Schedule cherry-pick to target branch when PR is merged
    • Multiple branches: /cherry-pick branch1 branch2 branch3
  • /cherry-pick-retry <branch> - Retry a failed cherry-pick (merged PRs only)

Branch Management

  • /rebase - Rebase this PR branch onto its base branch

Label Management

  • /<label-name> - Add a label to the PR
  • /<label-name> cancel - Remove a label from the PR

✅ Merge Requirements

This PR will be automatically approved when the following conditions are met:

  1. Approval: /approve from at least one approver
  2. Status Checks: All required status checks must pass
  3. No Blockers: No wip, hold, has-conflicts labels and PR must be mergeable (no conflicts)
  4. Verified: PR must be marked as verified

📊 Review Process

Approvers and Reviewers

Approvers:

  • krcmarik
  • myakove
  • solenoci

Reviewers:

  • krcmarik
  • myakove
  • solenoci
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
  • automerge
AI Features
  • Conventional Title: Mode: fix (EnMaaS/rits/deepseek-ai/DeepSeek-V4.1-Flash-1017)
  • Cherry-Pick Conflict Resolution: Enabled (EnMaaS/rits/deepseek-ai/DeepSeek-V4.1-Flash-1017)
Security Checks
  • Suspicious Path Detection: Monitors paths: .claude/, .vscode/, .cursor/, .devcontainer/, .pi/, .github/workflows/, .github/actions/
  • Committer Identity Check: Verifies last committer matches PR author
  • Mandatory: Security checks block merge (use /security-override to bypass — maintainers only)

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is removed on new commits unless the push is detected as a clean rebase
  • Cherry-picking: Cherry-pick labels are processed when the PR is merged
  • Container Builds: Container images are automatically tagged with the PR number
  • Permission Levels: Some commands require approver permissions
  • Auto-verified Users: Certain users have automatic verification and merge privileges

For more information, please refer to the project documentation or contact the maintainers.

@qodo-code-review

qodo-code-review Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Wait for vSphere guest info after NIC reconfiguration

🐞 Bug fix 🕐 20-40 Minutes

Grey Divider

AI Description

• Require guest family alongside network and Tools status before treating vSphere guest info as
 ready.
• Wait again after adding a NIC to a powered-on clone, before guest-dependent detection.
• Fail with a VM-specific error on timeout instead of continuing with stale data.
Merge Risk 🟡 Medium

Blast radius 🔴 High 💥 3 capabilities

  • 3 affected capabilities span independent functional scopes: VMware copy-offload migration preparation, VMware migration preparation and static-IP preservation, VMware shared-disk migration preparation.
  • The changed wait is called while preparing VMware source VMs and its result controls collection of guest IP-origin and NIC-name metadata used by the same migration preparation and later static-IP/NIC preservation checks.
  • The clone, skip-clone, and add-NIC paths are entry variants of this bounded migration feature, not independent capabilities.
  • This is a distinct migration preparation outcome: it powers on a source VM, waits for guest readiness, obtains an IP, and checks cloud-init before copy-offload processing.
  • It is not merely another implementation hop of static-IP metadata collection.
  • Shared-disk guest labeling is an independent bounded migration feature: it authenticates to the owner guest and labels disks before migration.
  • Its user-visible outcome differs from static-IP metadata collection and copy-offload cloud-init preparation, despite reuse of the VMware readiness helper.
Sources

utilities/copyoffload_migration.py[572-573]

        if not source_provider.wait_for_vmware_guest_info(provider_vm_api, timeout=1000):
            raise ValueError(f"Guest info not available for VM '{vm_name}'")

libs/providers/vmware.py[2557-2559]

                    # guestFamily is tools-populated and lags toolsStatus/net on fresh
                    # clones; guest operations depend on it to identify the guest OS.
                    and vm.guest.guestFamily

utilities/shared_disk.py[618-619]

    if not source_provider.wait_for_vmware_guest_info(owner_vm, timeout=_GUEST_TOOLS_READY_TIMEOUT):
        raise ValueError(f"VMware Tools not available on '{owner_name}' after power-on, cannot label shared disk")

conftest.py[1953-1958]

                        wait_guest_info_or_fail(
                            source_provider=source_provider,
                            provider_vm_api=provider_vm_api,
                            vm_name=vm["name"],
                            timeout=class_plan_config.get("guest_agent_timeout", 120),
                            required=plan.get("preserve_static_ips", False),
Behavioral complexity 🟡 Medium 🧩 Interacting branches, Compatibility cases

  • Before: readiness required the VM to be powered on with nonempty guest networking and toolsStatus toolsOk/toolsOld.
  • After: readiness also requires guestFamily, which is explicitly documented in the changed code as lagging toolsStatus/net after fresh clones.
  • New correctness conditions are that guestFamily must be repopulated before guest-OS-dependent operations, and that callers handle the timeout differently depending on required=True/False.
  • The helper introduces a compatibility distinction between static-IP-preserving preparation, best-effort preparation, and existing direct consumers that independently raise on False.
  • These are newly interacting readiness and caller-policy states; the underlying TimeoutSampler and guest metadata mechanisms remain unchanged.
  • The main uncertainty is runtime timing, not the existence of the new condition.
Sources

libs/providers/vmware.py[2557-2559]

                    # guestFamily is tools-populated and lags toolsStatus/net on fresh
                    # clones; guest operations depend on it to identify the guest OS.
                    and vm.guest.guestFamily

conftest.py[1953-1958]

                        wait_guest_info_or_fail(
                            source_provider=source_provider,
                            provider_vm_api=provider_vm_api,
                            vm_name=vm["name"],
                            timeout=class_plan_config.get("guest_agent_timeout", 120),
                            required=plan.get("preserve_static_ips", False),

utilities/copyoffload_migration.py[572-573]

        if not source_provider.wait_for_vmware_guest_info(provider_vm_api, timeout=1000):
            raise ValueError(f"Guest info not available for VM '{vm_name}'")

utilities/shared_disk.py[618-619]

    if not source_provider.wait_for_vmware_guest_info(owner_vm, timeout=_GUEST_TOOLS_READY_TIMEOUT):
        raise ValueError(f"VMware Tools not available on '{owner_name}' after power-on, cannot label shared disk")
Potential damage 🟡 Medium 🩹 Temporary loss

  • A false timeout on a preserve_static_ips plan prevents preparation and therefore prevents the migration test flow from reaching plan execution.
  • Recovery is normally a retry after VMware Tools republishes guestFamily, or correcting the guest-tools/runtime condition; reverting code removes the stricter predicate but does not repair any already-running external migration because the failure occurs before that operation.
  • No persistent state repair or compensation is indicated.
  • Reversible by waiting for guestFamily to be reported and rerunning preparation, or by restoring the prior readiness predicate.
  • The source does not show automatic retry after the helper raises, so retry/manual intervention is required.
Sources

libs/providers/vmware.py[2557-2559]

                    # guestFamily is tools-populated and lags toolsStatus/net on fresh
                    # clones; guest operations depend on it to identify the guest OS.
                    and vm.guest.guestFamily

conftest.py[1953-1958]

                        wait_guest_info_or_fail(
                            source_provider=source_provider,
                            provider_vm_api=provider_vm_api,
                            vm_name=vm["name"],
                            timeout=class_plan_config.get("guest_agent_timeout", 120),
                            required=plan.get("preserve_static_ips", False),
Assessed commit 654c76b
Diagram

graph TD
  Plan["Prepared plan"] --> Change["Power on or add NIC"] --> Powered{"VM powered on?"} --> Wait["Guest info wait"] --> Ready{"Net, Tools, family?"} --> Detect["Guest OS detection"]
  Powered -- "No" --> Detect
  Ready -- "Timeout" --> Fail["VM-named error"]
Loading
High-Level Assessment

Keep the readiness predicate in the provider and enforce its result at fixture call sites. This addresses both incomplete guest info and silent timeouts without making powered-off clones wait for data they cannot report.

Files changed (3) +56 / -5

Bug fix (3) +56 / -5
conftest.pyGuard power-on and post-NIC guest-info reads +26/-5

Guard power-on and post-NIC guest-info reads

• Routes both vSphere power-on waits through the fail-fast helper. Adds a wait after successful NIC addition when the VM is powered on, before guest-dependent detection.

conftest.py

vmware.pyRequire guest family for guest-info readiness +3/-0

Require guest family for guest-info readiness

• Extends the VMware Tools readiness predicate to require guestFamily as well as network data and Tools status.

libs/providers/vmware.py

vmware_guest_operations.pyRaise a VM-specific error when guest info times out +27/-0

Raise a VM-specific error when guest info times out

• Adds a wrapper that converts a false guest-info wait result into a ValueError naming the VM and timeout.

utilities/vmware_guest_operations.py

@qodo-code-review

qodo-code-review Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. New helper's VM parameter is untyped with no justification ✓ Resolved

Resolving commit: a45d740

Resolution reason
The commit changed the annotation of provider_vm_api from Any to vim.VirtualMachine in
wait_guest_info_or_fail and documented it as a powered-on VMware VM object, directly resolving the
untyped-parameter complaint. It also adds a required flag, which is an unrelated behavior change,
but the type fix itself is present. The fix differs from the suggested prompt only in not adding a
TYPE_CHECKING import, which is not shown in the diff.
Description
wait_guest_info_or_fail declares provider_vm_api: Any with no comment explaining why a precise
type cannot be used. The value is passed straight to source_provider.wait_for_vmware_guest_info,
whose parameter is annotated vm: vim.VirtualMachine, so the concrete type is inferable and Any
only weakens checking for callers. The same Any annotation will spread to later callers that copy
this helper's signature.

2. Best-effort migrations fail during setup ✓ Resolved

Resolving commit: a45d740

Resolution reason
Added a required flag to wait_guest_info_or_fail, defaulting to True; when False, timeout logs a
warning and continues. All three conftest.py callers pass required=plan.get("preserve_static_ips",
False), so non-static-IP plans proceed to the existing guest_info_unavailable fallback.
Description
wait_guest_info_or_fail() raises when the stricter guest-info check times out, even for plans with
preserve_static_ips disabled. If a powered-on vSphere guest reports networking and healthy Tools
but never reports guestFamily, preparation stops before collect_linux_guest_static_ip_metadata()
can use its existing guest_info_unavailable fallback; this affects both power-on waits and the new
post-NIC wait.

Grey Divider

Context sources
✅ Linked PRs:
  🌐 PR #835
✅ Compliance rules (platform): 93 rules
✅ Skills: remote-debugging
✅ Cross-repo context — repo relationships
Review mode: Auto: ⚖️ Balanced: Runtime timeout behavior spans multiple VMware paths; careful review warranted.

Grey Divider

Tip of the day
💡 Did you know, you can route each severity your way: inline, summary, both, or drop

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 654c76b

Results up to commit 9df2037 ⚖️ Balanced


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. New helper's VM parameter is untyped with no justification ✓ Resolved

Resolving commit: a45d740

Resolution reason
The commit changed the annotation of provider_vm_api from Any to vim.VirtualMachine in
wait_guest_info_or_fail and documented it as a powered-on VMware VM object, directly resolving the
untyped-parameter complaint. It also adds a required flag, which is an unrelated behavior change,
but the type fix itself is present. The fix differs from the suggested prompt only in not adding a
TYPE_CHECKING import, which is not shown in the diff.
Description
wait_guest_info_or_fail declares provider_vm_api: Any with no comment explaining why a precise
type cannot be used. The value is passed straight to source_provider.wait_for_vmware_guest_info,
whose parameter is annotated vm: vim.VirtualMachine, so the concrete type is inferable and Any
only weakens checking for callers. The same Any annotation will spread to later callers that copy
this helper's signature.

2. Best-effort migrations fail during setup ✓ Resolved

Resolving commit: a45d740

Resolution reason
Added a required flag to wait_guest_info_or_fail, defaulting to True; when False, timeout logs a
warning and continues. All three conftest.py callers pass required=plan.get("preserve_static_ips",
False), so non-static-IP plans proceed to the existing guest_info_unavailable fallback.
Description
wait_guest_info_or_fail() raises when the stricter guest-info check times out, even for plans with
preserve_static_ips disabled. If a powered-on vSphere guest reports networking and healthy Tools
but never reports guestFamily, preparation stops before collect_linux_guest_static_ip_metadata()
can use its existing guest_info_unavailable fallback; this affects both power-on waits and the new
post-NIC wait.

Grey Divider

Qodo Logo

Comment thread utilities/vmware_guest_operations.py Resolved
Comment thread conftest.py Resolved
@AmenB

AmenB commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

/qodo

The following review comments were reviewed and a decision was made:

utilities/vmware_guest_operations.py:1024 (qodo rule violation) — New helper's VM parameter is untyped with no justification

Addressed: addressed — fixed in a45d740: same fix as the line-1027 reply: wait_guest_info_or_fail takes provider_vm_api: vim.VirtualMachine, so callers keep full type checking.

conftest.py:2010 (qodo bug) — Best-effort migrations fail during setup

Addressed: addressed — fixed in a45d740: same fix as the line-2014 reply: required=plan.get("preserve_static_ips", False) gates the fail-fast, so only plans that need guest-OS metadata abort on a missing guestFamily.

@qodo-code-review

Copy link
Copy Markdown

The following review comments were reviewed and a decision was made:

utilities/vmware_guest_operations.py:1024 (qodo rule violation) — New helper's VM parameter is untyped with no justification

Addressed: addressed — fixed in a45d740: same fix as the line-1027 reply: wait_guest_info_or_fail takes provider_vm_api: vim.VirtualMachine, so callers keep full type checking.

conftest.py:2010 (qodo bug) — Best-effort migrations fail during setup

Addressed: addressed — fixed in a45d740: same fix as the line-2014 reply: required=plan.get("preserve_static_ips", False) gates the fail-fast, so only plans that need guest-OS metadata abort on a missing guestFamily.

Both review findings are resolved in commit a45d740, and the diff confirms the fixes:

  • finding 1 (untyped provider_vm_api in the new helper): wait_guest_info_or_fail now types the parameter as vim.VirtualMachine (utilities/vmware_guest_operations.py:1024-1027), so callers keep type checking.
  • finding 2 (best-effort migrations failing during setup): the helper has a required flag, and all three conftest.py callers pass required=plan.get("preserve_static_ips", False). Plans that don't preserve static IPs log a warning on timeout and continue to the existing guest_info_unavailable fallback (conftest.py:1841-1847, 1953-1959, 2011-2018).

The report lists no active findings. The required flag is an unrelated behavior change that the resolution note also mentions, so it is worth a look during the final review.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit a45d740

Wait for guest.guestFamily in wait_for_vmware_guest_info and fail fast
when the wait times out at the conftest call sites (power-on and add_nic
reconfiguration), so NIC checks and guest-operations detection see fresh
inventory data instead of stale guest info.
wait_guest_info_or_fail() previously raised on every guest-info timeout even
when the caller's metadata collection is best-effort. Add a required flag:
on timeout it raises only when required, otherwise it logs a warning and
returns.

All three conftest.py call sites pass required=plan.get("preserve_static_ips",
False), so static-IP preservation still fails fast while best-effort plans keep
the existing unavailable-guest-info fallback in
collect_linux_guest_static_ip_metadata(). Also type provider_vm_api as
vim.VirtualMachine instead of Any.
@AmenB

AmenB commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

/verified

@myakove

myakove commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

/lgtm
/approve

@myakove
myakove merged commit 6cd4267 into RedHatQE:main Nov 22, 2026
11 checks passed
@redhat-qe-bot1

Copy link
Copy Markdown

New container for ghcr.io/redhatqe/mtv-api-tests:latest published

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.

5 participants