Skip to content

Add logic to verify that a previous in-place update has finished before triggering a new one to prevent conflicts or race conditions#2455

Open
ajatshatru01 wants to merge 1 commit into
openkruise:masterfrom
ajatshatru01:inplace_update
Open

Add logic to verify that a previous in-place update has finished before triggering a new one to prevent conflicts or race conditions#2455
ajatshatru01 wants to merge 1 commit into
openkruise:masterfrom
ajatshatru01:inplace_update

Conversation

@ajatshatru01

Copy link
Copy Markdown

Ⅰ. Describe what this PR does

In inplace_update.go (line 319), Update now fetches the latest Pod and calls CheckPodUpdateCompleted before starting a new in-place update. If the previous update is still in grace period, has pending batches, unchanged image IDs, or incomplete resource updates, it returns an error instead of overwriting the in-place update state.

Added regression coverage in inplace_update_test.go (line 259) for both cases:

  • incomplete previous update blocks the new update and leaves the Pod unchanged

  • completed previous update allows the new revision/image update

Ⅱ. Does this pull request fix one issue?

It resolves the TODO in pkg/util/inplaceupdate/inplace_update.go Line 322

Ⅲ. Describe how to verify it

go test ./pkg/util/inplaceupdate/...

Ⅳ. Special notes for reviews

…re triggering a new one to prevent conflicts or race conditions
Copilot AI review requested due to automatic review settings May 14, 2026 10:42
@kruise-bot
kruise-bot requested review from Fei-Guo and zmberg May 14, 2026 10:42
@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 @ajatshatru01! 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 a pre-update completion check to avoid starting a new in-place Pod update while a previous one is still in progress.

Changes:

  • Fetches the Pod before in-place update and calls CheckPodUpdateCompleted.
  • Returns an error when a previous in-place update is still incomplete.
  • Adds regression tests for blocked and allowed follow-up updates.

Reviewed changes

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

File Description
pkg/util/inplaceupdate/inplace_update.go Adds the previous-update completion check before applying a new in-place update.
pkg/util/inplaceupdate/inplace_update_test.go Adds test coverage for incomplete vs completed previous in-place updates.

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

Comment on lines +326 to +327
if err = opts.CheckPodUpdateCompleted(latestPod); err != nil {
return UpdateResult{InPlaceUpdate: true, UpdateErr: fmt.Errorf("previous in-place update has not completed: %w", err)}
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