Skip to content

fix: validate v1beta1 CloneSet progress deadline#2465

Open
immanuwell wants to merge 1 commit into
openkruise:masterfrom
immanuwell:fix-cloneset-v1beta1-progress-deadline
Open

fix: validate v1beta1 CloneSet progress deadline#2465
immanuwell wants to merge 1 commit into
openkruise:masterfrom
immanuwell:fix-cloneset-v1beta1-progress-deadline

Conversation

@immanuwell

Copy link
Copy Markdown

I. Describe what this PR does

Adds the missing v1beta1 CloneSet validation for spec.progressDeadlineSeconds.

v1alpha1 already rejects negative values, and values <= minReadySeconds except MaxInt32. v1beta1 missed that check. Tiny parity fix, nothing fancy.

II. Does this pull request fix one issue?

NONE

III. Describe how to verify it

The added test reproduces the old bug: invalid v1beta1 values like -1, or 10 with minReadySeconds: 10, got no spec.progressDeadlineSeconds error. Pretty easy to miss tbh.

go test ./pkg/webhook/cloneset/validating -run TestValidateCloneSetV1beta1ProgressDeadlineSeconds -count=1
go test ./pkg/webhook/cloneset/... -count=1
git diff --check HEAD~1..HEAD

IV. Special notes for reviews

No matching issue found. Closest context is #2225, which added the v1beta1 CloneSet path.

Signed-off-by: immanuwell <pchpr.00@list.ru>
Copilot AI review requested due to automatic review settings May 22, 2026 04:41
@kruise-bot kruise-bot requested review from Fei-Guo and furykerry May 22, 2026 04:41
@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

Copy link
Copy Markdown

Welcome @immanuwell! It looks like this is your first PR to openkruise/kruise 🎉

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

Adds missing validation for spec.progressDeadlineSeconds in the v1beta1 CloneSet validating webhook to match existing v1alpha1 behavior, and introduces a focused unit test to prevent regressions.

Changes:

  • Add v1beta1 validation to reject negative progressDeadlineSeconds and values <= minReadySeconds (except MaxInt32).
  • Add a new unit test covering valid/invalid progressDeadlineSeconds combinations for v1beta1 CloneSet validation.

Reviewed changes

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

File Description
pkg/webhook/cloneset/validating/validation.go Adds v1beta1 progressDeadlineSeconds validation parity with v1alpha1.
pkg/webhook/cloneset/validating/validation_test.go Adds a unit test ensuring v1beta1 validation rejects invalid progressDeadlineSeconds values.

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

if spec.ProgressDeadlineSeconds != nil {
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(*spec.ProgressDeadlineSeconds), fldPath.Child("progressDeadlineSeconds"))...)
if *spec.ProgressDeadlineSeconds != math.MaxInt32 && *spec.ProgressDeadlineSeconds <= spec.MinReadySeconds {
allErrs = append(allErrs, field.Invalid(fldPath.Child("progressDeadlineSeconds"), spec.ProgressDeadlineSeconds, "must be greater than minReadySeconds"))
Comment on lines +853 to +862
hasError := false
for _, err := range errs {
if err.Field == "spec.progressDeadlineSeconds" {
hasError = true
break
}
}
if hasError != tt.expectError {
t.Errorf("expected progressDeadlineSeconds error: %v, got errors: %v", tt.expectError, errs)
}
@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.15%. Comparing base (271a9e2) to head (52c64f2).
⚠️ Report is 19 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2465      +/-   ##
==========================================
+ Coverage   49.08%   49.15%   +0.07%     
==========================================
  Files         325      325              
  Lines       28112    28116       +4     
==========================================
+ Hits        13798    13820      +22     
+ Misses      12745    12714      -31     
- Partials     1569     1582      +13     
Flag Coverage Δ
unittests 49.15% <100.00%> (+0.07%) ⬆️

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.

3 participants