Skip to content

Respect metadata env refs in PUB resize checks#2501

Open
Jayant-kernel wants to merge 1 commit into
openkruise:masterfrom
Jayant-kernel:codex/fix-pub-resize-metadata-env
Open

Respect metadata env refs in PUB resize checks#2501
Jayant-kernel wants to merge 1 commit into
openkruise:masterfrom
Jayant-kernel:codex/fix-pub-resize-metadata-env

Conversation

@Jayant-kernel

Copy link
Copy Markdown

Ⅰ. Describe what this PR does

Teach PodUnavailableBudget in-place resize checks to reject a resize as harmless when Pod labels or annotations changed and a container reads the changed key through downward API env.

This fills the existing TODO in CanResizeInplace and keeps PUB from treating this kind of update as safe when the metadata value can affect the running container environment.

Ⅱ. Does this pull request fix one issue?

Related to #1192

Ⅲ. Describe how to verify it

Added TestCanResizeInplace cases for:

  • referenced label changed
  • unrelated label changed
  • referenced annotation changed

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 veophi for approval by writing /assign @veophi 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/L size/L: 100-499 label Jun 28, 2026
@Jayant-kernel Jayant-kernel marked this pull request as ready for review June 28, 2026 20:29
Copilot AI review requested due to automatic review settings June 28, 2026 20:29
@kruise-bot kruise-bot requested review from FillZpp and veophi June 28, 2026 20:29

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 updates PodUnavailableBudget’s in-place resize safety check to treat label/annotation changes as potentially disruptive when those metadata keys are referenced by containers via downward-API env vars, aligning PUB’s “harmless resize” decision with metadata-driven env behavior. It also adds unit tests covering referenced vs unrelated metadata changes during a resize.

Changes:

  • Add metadata-change detection in CanResizeInplace for downward-API env references to labels/annotations.
  • Reuse pkg/util/containermeta helpers to detect env references to metadata.labels['key'] / metadata.annotations['key'].
  • Extend TestCanResizeInplace with cases for referenced label/annotation changes and an unrelated-label change.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/control/pubcontrol/pub_control.go Adds a metadata/env reference check to PUB in-place resize gating logic.
pkg/control/pubcontrol/pub_control_test.go Adds unit test cases validating the new metadata/env reference behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +125 to +128
if isChangedMetadataReferencedByEnv(oldPod, newPod) {
klog.V(3).InfoS("Pod metadata referenced by env changed, and maybe cause unavailability", "pod", klog.KObj(newPod))
return false
}
@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.93%. Comparing base (c9ada9a) to head (c0f1f22).

Files with missing lines Patch % Lines
pkg/control/pubcontrol/pub_control.go 84.00% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2501      +/-   ##
==========================================
+ Coverage   49.91%   49.93%   +0.02%     
==========================================
  Files         325      325              
  Lines       28437    28462      +25     
==========================================
+ Hits        14194    14213      +19     
- Misses      12588    12591       +3     
- Partials     1655     1658       +3     
Flag Coverage Δ
unittests 49.93% <84.00%> (+0.02%) ⬆️

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.

Signed-off-by: Jayant <212013719+Jayant-kernel@users.noreply.github.com>
@Jayant-kernel Jayant-kernel force-pushed the codex/fix-pub-resize-metadata-env branch from 940e53a to c0f1f22 Compare June 28, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L size/L: 100-499

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants