Fix NodePodProbe nil labels panic#2500
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
This PR fixes a panic in the NodePodProbe controller when applying PodProbeMarker marker labels onto a Pod whose metadata.labels is nil. It does so by initializing podClone.Labels before writing probe-derived labels, and adds a regression unit test to cover the nil-labels scenario.
Changes:
- Initialize
podClone.Labelsto an empty map when nil before applying marker policy labels. - Add a unit test that updates probe status for a Pod with nil labels and asserts the marker label is applied.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/controller/nodepodprobe/node_pod_probe_controller.go | Initializes podClone.Labels to prevent nil-map assignment panic when applying marker labels. |
| pkg/controller/nodepodprobe/node_pod_probe_controller_test.go | Adds regression coverage for updating a Pod with nil labels when a marker policy adds a label. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9fa1b36 to
847a162
Compare
Signed-off-by: Jayant <212013719+Jayant-kernel@users.noreply.github.com>
847a162 to
bcc5f3d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2500 +/- ##
==========================================
+ Coverage 49.91% 50.06% +0.15%
==========================================
Files 325 325
Lines 28437 28439 +2
==========================================
+ Hits 14194 14239 +45
+ Misses 12588 12528 -60
- Partials 1655 1672 +17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Ⅰ. PR does
Initialize
podClone.Labelsbefore applying labels fromPodProbeMarkerpolicies inNodePodProbe.This prevents a panic when the target Pod has nil labels and a marker policy adds a label. A regression test covers updating a Pod with nil labels from a successful probe state.
Ⅱ. pull request fix one issue?
fixes #2499
Ⅲ. verify it
Added
TestUpdatePodProbeStatusInitializesNilLabels.Not run locally because Go tooling is not installed in this environment.
Ⅳ. Special notes for reviews
NONE