Skip to content

fix(nodepodprobe): safely initialize Labels map when patching pod probe status - #2530

Open
vishalmore90 wants to merge 1 commit into
openkruise:masterfrom
vishalmore90:fix-issue-2527
Open

vishalmore90 wants to merge 1 commit into
openkruise:masterfrom
vishalmore90:fix-issue-2527

Conversation

@vishalmore90

Copy link
Copy Markdown
Contributor

Ⅰ. Describe what this PR does

This PR fixes a bug in the NodePodProbe controller where it panics with a nil pointer dereference when a PodProbeMarker has a policy that adds labels to a pod, and the target pod has no existing labels (pod.Labels == nil).

The controller safely guarded against nil Annotations, but did not have the same check for Labels. This PR adds the same initialization check for Labels to prevent the panic.

Ⅱ. Does this pull request fix one issue?

fixes #2527

Ⅲ. Describe how to verify it

To reproduce the issue and verify the fix:

  1. Create a pod with absolutely no labels.
  2. Create a PodProbeMarker targeting this pod (using operator: DoesNotExist for a dummy label) with a MarkerPolicy that adds a label on success.
  3. Observe the kruise-manager controller logs. Without this fix, the controller encounters a panic crash-loop. With this fix, the controller applies the labels without issue.

Ⅳ. Special notes for reviews

NONE

@kruise-bot
kruise-bot requested review from Fei-Guo and furykerry August 6, 2026 16:52
@kruise-bot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign furykerry for approval by writing /assign @furykerry in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kruise-bot kruise-bot added the size/M size/M: 30-99 label Aug 6, 2026
@vishalmore90
vishalmore90 force-pushed the fix-issue-2527 branch 2 times, most recently from a2a3f25 to 052e69d Compare August 6, 2026 17:17
@kruise-bot kruise-bot added size/XS size/XS: 0-9 and removed size/M size/M: 30-99 labels Aug 6, 2026
@codecov

codecov Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.26%. Comparing base (68dc260) to head (8639c84).

Files with missing lines Patch % Lines
...ntroller/nodepodprobe/node_pod_probe_controller.go 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2530      +/-   ##
==========================================
- Coverage   50.31%   50.26%   -0.06%     
==========================================
  Files         325      325              
  Lines       28499    28501       +2     
==========================================
- Hits        14340    14325      -15     
- Misses      12472    12486      +14     
- Partials     1687     1690       +3     
Flag Coverage Δ
unittests 50.26% <0.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…be status

Signed-off-by: vishal <httpsvishal07@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS size/XS: 0-9

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] NodePodProbe controller panics with nil pointer dereference when setting labels on a Pod with no existing labels

2 participants