Add logic to verify that a previous in-place update has finished before triggering a new one to prevent conflicts or race conditions#2455
Conversation
…re triggering a new one to prevent conflicts or race conditions
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @ajatshatru01! It looks like this is your first PR to openkruise/kruise 🎉 |
There was a problem hiding this comment.
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.
| if err = opts.CheckPodUpdateCompleted(latestPod); err != nil { | ||
| return UpdateResult{InPlaceUpdate: true, UpdateErr: fmt.Errorf("previous in-place update has not completed: %w", err)} |
Ⅰ. 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