Repository navigation
Make stage resource deletion idempotent - #1820
kubernetes-prow[bot] merged 3 commits into
Conversation
👷 Deploy request for k8s-kwok pending review.Visit the deploys page to approve it
|
|
|
|
Welcome @vaibhav61! |
|
Hi @vaibhav61. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Signed-off-by: Vaibhav Mishra <37236922+vaibhav61@users.noreply.github.com>
9c772c9 to
c699831
Compare
|
@wzshiming, could you review this fix and authorize CI with |
|
/ok-to-test |
Signed-off-by: Vaibhav Mishra <37236922+vaibhav61@users.noreply.github.com>
|
@wzshiming, all tests on the latest commit are now passing, including Benchmark and the Prow end-to-end checks. Could you take a look when you have a chance? Thank you for authorizing CI! |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the idempotent stage-deletion change.
No open issues 🎉
What changed in this PR
Makes KWOK stage deletion idempotent: deleting an already-absent pod, node, or generic Stage resource succeeds instead of reporting a failed stage.
Changes:
- Treat API
NotFoundresponses as successful deletion across all three controllers. - Preserve other deletion errors and existing delete options.
- Add regression tests for repeated deletion, error propagation, and delete preconditions.
| File | Description |
|---|---|
| pkg/kwok/controllers/stage_controller.go | Accepts NotFound when deleting generic Stage resources. |
| pkg/kwok/controllers/pod_controller.go | Accepts NotFound when deleting pods. |
| pkg/kwok/controllers/node_controller.go | Accepts NotFound when deleting nodes. |
| pkg/kwok/controllers/delete_resource_test.go | Tests idempotent deletion, preserved errors, and delete options. |
Review effort: Balanced
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vaibhav61, wzshiming The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug
What this PR does / why we need it:
We encountered this while testing KEDA autoscaling with KWOK simulating the workload pods. The experiment used 20,000 Deployments, each with a ScaledObject and HPA. We changed a shared Prometheus metric to run three scale-up/scale-down cycles, moving the simulated pod population from 20,000 to 40,000 and back to 20,000, to measure how quickly the system converged.
While investigating scaling latency, bounded KWOK log captures contained 2,021 distinct pod-deletion error lines reporting NotFound: the target pod was already absent when the deletion stage tried to delete it. All scaling cycles completed successfully. These counts describe the captured logs, not a full-run total, and do not establish which component deleted each pod first or that these errors caused the scaling delay.
A queued deletion stage can execute after its target has already been deleted, for example by another controller or an earlier deletion attempt. The desired outcome is already satisfied, so this PR treats an API NotFound response as successful deletion for pods, nodes, and generic Stage resources. Other API errors remain visible, and delete options are preserved.
This prevents an already-satisfied deletion from producing a failed-stage error. It does not change retry policy or claim a throughput improvement.
Which issue(s) this PR fixes:
No linked issue.
Special notes for your reviewer:
Regression coverage exercises deletion twice against client-go object trackers and verifies that permission errors, conflicts, and timeouts remain failures. The repeated-delete cases fail on the base revision with NotFound on attempt 2. Validation:
make unit-testpasses (go test -race ./pkg/...; 45 packages with tests).git diff --checkpass.go vet ./pkg/kwok/controllersreports a pre-existing lostcancel warning instages_manager.go:101,128. The same command on the clean base commit produces identical output.No live cluster changes are required to reproduce the regression.
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: