Skip to content

Update populator pod warning message#6947

Open
mnecas wants to merge 1 commit into
kubev2v:mainfrom
mnecas:update_popualtor_warning
Open

Update populator pod warning message#6947
mnecas wants to merge 1 commit into
kubev2v:mainfrom
mnecas:update_popualtor_warning

Conversation

@mnecas

@mnecas mnecas commented Jun 8, 2026

Copy link
Copy Markdown
Member

Issue: right now when the populator pod fials it shows the PV ID which is not much helpful when debugging. It's better to specify the pod namespace/name

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR refines populator pod failure detection in the migration controller. updatePopulatorCopyProgress now calls a new getFailedPopulatorPod helper that scopes pod lookup to the current VM and returns both the failed pod name and status, replacing the previous boolean-only check. Error messages now include specific pod and PVC identifiers.

Changes

Populator Pod Failure Detection

Layer / File(s) Summary
Enhanced populator pod failure detection with VM scoping
pkg/controller/plan/migration.go
The updatePopulatorCopyProgress call site invokes a new getFailedPopulatorPod(givenPvcId, vmID) helper returning pod name and failure status. The old isPopulatorPodFailed(givenPvcId) boolean-only check is replaced. The new helper retrieves populator pods for the VM, matches by PVC ID from pod name suffix, and returns the first failed pod or no failure. Error messages now include detailed pod and PVC identifiers.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A populator pod that faltered once,
Now shows its name with clearer stunts,
VM-scoped searches, errors bright,
Debugging dreams made crystal tight! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: updating the populator pod warning message to include more useful information (pod namespace/name instead of PV ID).
Description check ✅ Passed The description clearly explains the issue and the improvement being made - replacing unhelpful PV ID with pod namespace/name in the warning message.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
pkg/controller/plan/migration.go (1)

2125-2125: ⚡ Quick win

Add structured logging context for easier debugging.

The log message lacks identifying context (VM ID, PVC ID) that would help correlate this error with a specific migration when multiple VMs are migrating concurrently. As per coding guidelines, logs should provide context, and the structured logging learning recommends logging resource identity fields separately.

♻️ Proposed fix to add context
 	if err != nil {
-		r.Log.Error(err, "couldn't get the populator pods")
+		r.Log.Error(err, "couldn't get the populator pods", "vmID", vmID, "pvcID", givenPvcId)
 		// Treat retrieval errors as a failure condition so the caller surfaces them
 		return "", true
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/controller/plan/migration.go` at line 2125, Update the r.Log.Error call
that currently logs "couldn't get the populator pods" to include structured
context fields so the error can be correlated to a specific migration/VM/PVC;
e.g., call r.Log.Error(err, "couldn't get the populator pods", "vmID",
vm.GetName() or vmUID, "pvcID", pvc.GetName() or pvcUID, "migration",
migrationName/UID) using the VM, PVC or Migration identifier variables available
in scope so the log is emitted with separate key/value context rather than just
a freeform message.

Sources: Coding guidelines, Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/controller/plan/migration.go`:
- Around line 2123-2127: The code currently swallows errors from
r.kubevirt.getPopulatorPods (logged but function returns without propagating an
error), causing silent failures; change the enclosing function's return
signature to include an error (e.g., add err error) and when
r.kubevirt.getPopulatorPods returns an error, return that error to the caller
instead of returning only the zero-value failed flag; update all call sites (the
caller that checks failed at the previous location) to handle the new error
return and treat retrieval errors separately from "pod not failed" states so
RBAC/API-server errors are surfaced.

---

Nitpick comments:
In `@pkg/controller/plan/migration.go`:
- Line 2125: Update the r.Log.Error call that currently logs "couldn't get the
populator pods" to include structured context fields so the error can be
correlated to a specific migration/VM/PVC; e.g., call r.Log.Error(err, "couldn't
get the populator pods", "vmID", vm.GetName() or vmUID, "pvcID", pvc.GetName()
or pvcUID, "migration", migrationName/UID) using the VM, PVC or Migration
identifier variables available in scope so the log is emitted with separate
key/value context rather than just a freeform message.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 380e03e6-35f1-40eb-b068-931ea7f30463

📥 Commits

Reviewing files that changed from the base of the PR and between d189127 and 6a37701.

📒 Files selected for processing (1)
  • pkg/controller/plan/migration.go

Comment on lines +2123 to 2127
populatorPods, err := r.kubevirt.getPopulatorPods(vmID)
if err != nil {
r.Log.Error(err, "couldn't get the populator pods")
return false
return
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Silent failure when retrieving populator pods.

When getPopulatorPods returns an error, the function logs it but returns with failed=false (the zero value). The caller at line 2101 only raises an error when failed==true, so retrieval errors are silently ignored. This violates the "no silent failures" guideline and could mask critical issues such as RBAC failures or API server unavailability.

🛡️ Proposed fix to propagate retrieval errors
 func (r *Migration) getFailedPopulatorPod(givenPvcId string, vmID string) (podName string, failed bool) {
 	populatorPods, err := r.kubevirt.getPopulatorPods(vmID)
 	if err != nil {
 		r.Log.Error(err, "couldn't get the populator pods")
-		return
+		// Treat retrieval errors as a failure condition so the caller surfaces them
+		return "", true
 	}

Alternatively, change the signature to (podName string, failed bool, err error) and have the caller distinguish between retrieval errors and "pod not failed" states.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/controller/plan/migration.go` around lines 2123 - 2127, The code
currently swallows errors from r.kubevirt.getPopulatorPods (logged but function
returns without propagating an error), causing silent failures; change the
enclosing function's return signature to include an error (e.g., add err error)
and when r.kubevirt.getPopulatorPods returns an error, return that error to the
caller instead of returning only the zero-value failed flag; update all call
sites (the caller that checks failed at the previous location) to handle the new
error return and treat retrieval errors separately from "pod not failed" states
so RBAC/API-server errors are surfaced.

Source: Coding guidelines

Issue: right now when the populator pod fials it shows the PV ID which
is not much helpful when debugging. It's better to specify the pod
namespace/name

Signed-off-by: Martin Necas <mnecas@redhat.com>
@mnecas mnecas force-pushed the update_popualtor_warning branch from aaf09c6 to b107ba0 Compare June 8, 2026 11:54
@sonarqubecloud

sonarqubecloud Bot commented Jun 8, 2026

Copy link
Copy Markdown

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.

1 participant