Repository navigation
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Container Operations
Cherry-pick Operations
Branch Management
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
AI Features
Security Checks
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
PR Summary by QodoTrigger inventory refresh and improve resource creation safety
AI Description
Merge Risk
|
Code Review by Qodo
1.
|
0e0d930 to
239a09b
Compare
|
Clean rebase detected — no code changes compared to previous head ( |
|
/qodo The following review comments were reviewed and a decision was made:
|
Your latest message reads as a status update rather than a question, so here is where the three findings stand. All three are marked resolved in commit
If you want a re-review of the new |
|
Code review by qodo was updated up to the latest commit 3fb07f3 |
|
/qodo The following review comments were reviewed and a decision was made:
|
|
/qodo Please re-evaluate all remaining sticky findings against the current code. |
The current diff appears to address finding 1 ( What
Caveats
|
None of the four sticky findings is still active. The catalog already marks all of them
I haven't removed anything from the published report, and I haven't dismissed any findings. You only asked me to re-evaluate them, and they are already closed. If you want the report cleaned up further, tell me to dismiss them by title and I'll do it. Only the PR author can dismiss. |
|
Clean rebase detected — no code changes compared to previous head ( |
krcmarik
left a comment
There was a problem hiding this comment.
Code Review
Found 3 issue(s) in this PR:
🔴 Critical Issues (1)
| File | Line | Issue |
|---|---|---|
utilities/provider_inventory.py |
365 | Forced refresh + 3x timeout masks the inventory defects this check exists to cat |
⚠️ Warnings (2)
| File | Line | Issue |
|---|---|---|
utilities/provider_inventory.py |
371 | One-shot refresh has no recovery path |
utilities/resources.py |
24 | on_conflict="fail" is dead code and the two conflict-path comments contradict |
Review generated by Claude Code
| last_inventory_macs = {mac.lower() for nic in vm.get("nics") or [] if (mac := nic.get("mac"))} | ||
| return last_inventory_macs == live_macs | ||
|
|
||
| # The provider inventory refreshes on its own cadence (minutes for vSphere), so polling |
There was a problem hiding this comment.
[CRITICAL] Forced refresh + 3x timeout masks the inventory defects this check exists to catch
The justification comment ("The provider inventory refreshes on its own cadence (minutes for vSphere)") is asserted as fact but cites no ticket, measurement, or upstream reference - and it is contradicted by the code itself:
- The function's own (unchanged) docstring says "vCenter finalizes them almost immediately, but inventory can briefly lag". Both statements cannot be true.
- The code polls first and only refreshes on failure, implicitly conceding that polling does converge.
- By the time this runs,
wait_for_cloned_vms_in_forklift_inventoryhas already confirmed the cloned VM exists in inventory - with stale (pre-clone) MACs. That is not "slow inventory"; that is inventory serving inconsistent data for an object it already lists: exactly the condition this convergence check was built to detect. Making it self-heal means the suite can no longer surface it.
vSphere inventory is expected to update near real-time; if it does not, that is a product bug that should be filed upstream and referenced here, not worked around client-side. As merged, a forklift regression in vSphere inventory updates would pass green across the whole suite because every test force-refreshes past the stale window - end users without the workaround get stale-MAC migrations.
Note the sibling functions that force refresh (wait_for_added_nics_in_forklift_inventory, wait_for_shared_rdm_disk_in_forklift_inventory) do so for live reconfigurations of an already-inventoried VM - a categorically different, documented case, so they are not precedent for this one.
Please either back the "minutes" claim with evidence (upstream issue / measured refresh interval) and reconcile the docstring, or drop the forced refresh and the 60s->180s timeout and file the inventory bug instead.
There was a problem hiding this comment.
Thanks — you're right on the substance, and the "minutes" sentence was an unbacked inference on my side. Reworked in 304f342:
Evidence instead of the claim. The measured behaviour is stale data for an object inventory already lists, not slow discovery: CI #22 / #25 / #27 (tier0 vSphere) all failed with Inventory NIC MACs … did not converge after 60s/180s, inventory reporting 00:50:56:9d:73:f4 while live vCenter reported 00:50:56:9d:93:a7; same signature on both vCenters (10.6.46.248 vSphere 7.0.3, 10.6.46.250 vSphere 8.0.1). In every run wait_for_cloned_vms_in_forklift_inventory() had already confirmed the VM exists, so the cache was serving pre-clone MACs for a listed VM. The "refreshes on its own cadence (minutes)" wording is gone; the comment and the _wait_for_inventory_mac_convergence() docstring now state the same thing (eventually-consistent cache, observed stale window >180s).
Order inverted. The batch now refreshes before polling, so the code no longer implies that polling converges on its own.
Staleness is no longer silent. When cached MACs are stale the wait emits warnings.warn(...) with both MAC sets, so it shows up in the pytest warnings summary and in the code path, instead of being absorbed by a refresh.
Sibling helpers. Agreed — wait_for_added_nics_* / wait_for_shared_rdm_disk_* cover live reconfiguration of an already-inventoried VM, which is a different case; the comment no longer frames them as precedent and states why this one differs.
On filing upstream: a bug is being opened for "vSphere provider inventory serves stale NIC MACs for an already-inventoried cloned VM"; I'll link the ID here as soon as it exists. Meanwhile the warning names the symptom and both MAC sets, so a change in inventory behaviour stays visible.
I did keep the refresh (i.e. I did not take the "drop the refresh and the 60→180 bump" branch): dropping it returns the suite to failing class setup on this behaviour. The intent — don't hide it — is covered by the warning + the bug reference.
| if not _check_mac_convergence(): | ||
| if source_provider.ocp_resource is None: | ||
| raise ValueError("source_provider.ocp_resource is not set") | ||
| force_inventory_refresh(source_provider.ocp_resource) |
There was a problem hiding this comment.
[WARNING] One-shot refresh has no recovery path
The refresh fires at most once (only when the initial check fails) and the poll loop never re-triggers it. If that single refresh is lost - e.g. the collector snapshot races vCenter and commits stale MACs, or the controller is mid-reconcile for a previous trigger during the clone burst this PR cites as motivation - the only remaining convergence mechanism is the natural refresh cadence the PR itself declares insufficient. The test then burns the full window and fails with a misleading "MACs did not converge" error, since the inventory was never re-read after the lost refresh.
Worst case is also significant: force_inventory_refresh blocks up to 180s on the Ready condition, then the loop polls another 180s - up to ~6 minutes per VM, sequentially per cloned VM, under exactly the burst conditions the PR claims to fix.
If refreshes are needed here, consider triggering one refresh for the whole batch of clones before polling all VMs' MACs - that would also remove the need for the module-level _last_refresh_timestamp counter.
There was a problem hiding this comment.
Both points taken, implemented in 304f342:
- One refresh per clone burst.
wait_for_cloned_vms_in_forklift_inventory()now refreshes once for all cloned VMs before the per-VM waits (and those waits run withallow_refresh=False), so we no longer pay the provider-Ready wait once per clone. - Bounded re-trigger. Inside
_wait_for_inventory_mac_convergence()refreshes happen at offsets(0, 60, 120)seconds, so a refresh lost to a race (collector snapshot vs. controller reconcile) is retried rather than leaving us polling a cache nobody re-read. The failure message therefore now genuinely means "we re-read after refreshing and it still didn't converge". - Bounded refresh wait. The refresh in this path uses
_CONVERGENCE_REFRESH_READY_TIMEOUT = 60instead of 180, so the worst case is no longer 180s (Ready) + 180s (poll) per VM. - Module-level counter removed. The
_refreshvalue is derived from the provider's own current value (int(current) + 1when it is ahead ofnow, otherwisenow), which keeps it strictly increasing per provider without_last_refresh_timestamp— as you suggested.
| fixture_store: dict[str, Any], | ||
| resource: type[Resource], | ||
| test_name: str | None = None, | ||
| on_conflict: Literal["reuse", "fail"] = "reuse", |
There was a problem hiding this comment.
[WARNING] on_conflict="fail" is dead code and the two conflict-path comments contradict each other
Nothing in this PR (or the repo) passes on_conflict - every call site keeps the default "reuse", so the headline "safe resource creation" behavior is never exercised.
More importantly, the comments disagree with the default: the "fail" branch says "adopting foreign state would mean deleting it later", yet the default "reuse" path does exactly that - on ConflictError it waits, registers the pre-existing object in fixture_store["teardown"], and session teardown deletes it. Either that hazard is real (then the default is the bug, and the collision-prone call sites - e.g. the fixed-name plan-initial in resume_conversion.py or the get_or_create_namespace explicit-name path - should be converted to "fail"), or it is not (then the "fail" branch's comment is wrong).
As merged, the PR advertises a safety property it does not deliver at any call site. Suggest either wiring up the callers that need "fail" or dropping the parameter until a consumer exists.
There was a problem hiding this comment.
Agreed on both halves, and acted on the scope one: on_conflict is removed from this PR in 304f342 — nothing in the repo passes it yet, so it was dead code here.
It will come back in the toehold/copy-appliance PR (#835) together with its only consumer: create_provider_copy_appliance_template() creates a CopyApplianceTemplate with a fixed name (<provider>-copy-appliance-template), which is exactly the case where adopting (and later deleting) a pre-existing object is wrong. Nothing in #870 depends on it.
The contradiction will be resolved there as a stated position rather than leaving it implicit: reuse (default) keeps legacy behaviour — adopt the existing object and let session teardown delete it; fail is for callers that own a fixed name and must never delete foreign state. I'm not converting existing collision-prone call sites (e.g. get_or_create_namespace explicit-name path) in that PR — that changes behaviour for unrelated tests and deserves its own justification — but I'll open a follow-up for it if you think it's in scope.
Kept in this PR: the teardown-ordering fix (a teardown entry is recorded only once creation is confirmed, or after the adoption wait succeeds), which is independent of the conflict policy.
7a71104 to
304f342
Compare
|
Code review by qodo was updated up to the latest commit 304f342 |
|
/qodo The following review comments were reviewed and a decision was made:
|
|
Code review by qodo was updated up to the latest commit f68ae8d |
|
/qodo The following review comments were reviewed and a decision was made:
|
|
Code review by qodo was updated up to the latest commit fec2d35 |
Both review comments check out against the code in
Neither fix needs a follow-up from you. If you meant a different finding or a different question, tell me which one. |
- trigger the provider inventory refresh from the MAC convergence wait instead of polling a cache known to lag; one refresh is shared by the clone batch and retried at fixed offsets while any VM's MACs are still stale - make the _refresh trigger strictly monotonic per provider (it is second-granular, so same-second rewrites were silently ignored) - treat a null nics list as "not converged" and retry transient inventory reads for 30s; re-read after the last refresh and clamp the provider-Ready wait to the remaining convergence window - record a resource for teardown only once creation is confirmed, and fail fast when fixture_store has no base_resource_name - make K8S_NAME_MAX_LENGTH public
fec2d35 to
fb2b965
Compare
|
Clean rebase detected — no code changes compared to previous head ( |
What
Four harness fixes that are independent of any feature work, plus one constant rename. The first three address a real CI failure: run #27 (tier0 vSphere,
TestSharedDiskRhelMigration) errored at class setup withInventory NIC MACs … did not converge with live vCenter MACs after 180s, and raising the timeout from 60s to 180s changed nothing — the inventory refresh was never triggered, it was only hoped for.Changes
1. Trigger the inventory refresh instead of polling for one (
utilities/provider_inventory.py)_wait_for_inventory_mac_convergence()now takes the whole clone batch, refreshes the provider inventory when any VM's MACs are not already converged, then polls. The measured behaviour is stale data for an object inventory already lists, not slow discovery: CI runs #22/#25/#27 served pre-clone MACs for longer than 180s, so polling alone cannot converge.One refresh is shared by the batch (the provider-Ready wait is not paid once per VM) and repeated at offsets
0/60/120swhile any VM is still stale, so a refresh lost to a race between the collector snapshot and the controller reconcile is retried. Staleness is reported withwarnings.warn, so it appears in the run summary instead of being absorbed silently.2. Make the refresh token monotonic (
utilities/provider_inventory.py)_refreshis an opaque trigger the provider controller reconciles on — writing the same value again is a no-op — and it is second-granular.str(int(time.time()))meant two refreshes in the same second wrote the identical value, so the second request silently did nothing and its caller polled an inventory that was never refreshed. New_next_refresh_timestamp()returns a value strictly greater than the provider's current one, per provider, without module-level state.3. Keep the MAC wait resilient to transient inventory reads (
utilities/provider_inventory.py)nicscan be present-but-null while a refresh reconciles;vm.get("nics", [])evaluates toNonethere, so the wait now usesvm.get("nics") or []and treats that state as "not yet converged"._read_inventory_vm()inside aTimeoutSampler); a transientValueErrorfromget_vmor an API hiccup no longer aborts clone setup, which is what the previous sampler-based check guaranteed.4. Safe creation for callers that own a fixed name (
utilities/resources.py)Creation and the existence wait are now separate steps with different teardown ordering:
ConflictError→ recorded after it proves usable, so a failed wait leaves no teardown entry, and teardown never deletes an object this run did not create.store_resource_for_teardown()was extracted for that, andcreate_and_store_resource()now fails fast with a clearValueErrorwhenfixture_storecarries nobase_resource_nameinstead of a bareKeyError.5.
K8S_NAME_MAX_LENGTHis public (utilities/naming.py)Was
_K8S_NAME_MAX_LENGTH; modules that validate a fixed resource name against the Kubernetes limit should not duplicate the constant.Not in this PR
--toeholdoption, no appliance code, no test changes — these fixes were extracted from the copy-appliance work so they can land and be reviewed on their own merits.on_conflict: Literal["reuse", "fail"]option was prototyped here and dropped: nothing in the repository would pass it, so it was dead code. It comes back in WIP: feat: toehold (copy appliance) transfer path as a --toehold run toggle (VIRTSTRAT-757) #835 together with its only consumer (create_provider_copy_appliance_template()creates a fixed-nameCopyApplianceTemplate).Testing
pre-commit run --all-files— all hooks pass.tests/cold/test_mtv_cold_migration.py::TestSanityColdMtvMigration— sanity that nothing else changed (clone → plan → migrate → check).tests/shared_disk/test_shared_disk_rhel_migration.py::TestSharedDiskRhelMigration— the class that failed in Collect logs for failed tests #27; the run should now logInventory NIC MACs are stale for cloned VM(s) …; refreshing the provider inventory on demand, then converge — and neverdid not converge.