Skip to content

Fix NodePodProbe nil labels panic#2500

Open
Jayant-kernel wants to merge 1 commit into
openkruise:masterfrom
Jayant-kernel:codex/fix-nodepodprobe-nil-labels
Open

Fix NodePodProbe nil labels panic#2500
Jayant-kernel wants to merge 1 commit into
openkruise:masterfrom
Jayant-kernel:codex/fix-nodepodprobe-nil-labels

Conversation

@Jayant-kernel

@Jayant-kernel Jayant-kernel commented Jun 28, 2026

Copy link
Copy Markdown

Ⅰ. PR does

Initialize podClone.Labels before applying labels from PodProbeMarker policies in NodePodProbe.

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

@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 fei-guo for approval by writing /assign @fei-guo 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 Jun 28, 2026
@Jayant-kernel Jayant-kernel marked this pull request as ready for review June 28, 2026 20:18
Copilot AI review requested due to automatic review settings June 28, 2026 20:18

Copilot AI 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.

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.Labels to 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.

@Jayant-kernel Jayant-kernel force-pushed the codex/fix-nodepodprobe-nil-labels branch 2 times, most recently from 9fa1b36 to 847a162 Compare June 28, 2026 21:21
Signed-off-by: Jayant <212013719+Jayant-kernel@users.noreply.github.com>
@Jayant-kernel Jayant-kernel force-pushed the codex/fix-nodepodprobe-nil-labels branch from 847a162 to bcc5f3d Compare June 29, 2026 07:00
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.06%. Comparing base (c9ada9a) to head (bcc5f3d).

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     
Flag Coverage Δ
unittests 50.06% <100.00%> (+0.15%) ⬆️

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M size/M: 30-99

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] NodePodProbe can panic when marker policy adds labels to a pod without labels

3 participants