Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support preconditions for Delete request #545

Merged
merged 4 commits into from
Sep 29, 2024

Conversation

marshtompsxd
Copy link
Collaborator

@marshtompsxd marshtompsxd commented Sep 28, 2024

This PR introduces preconditions of Kubernetes delete requests. The preconditions contain a uid and a resource version. When handling the delete request, the API server checks whether the object's uid and resource version match the ones provided by the request and returns Conflict error if not. Kubernetes implements this feature here: https://github.com/kubernetes/kubernetes/blob/v1.30.0/staging/src/k8s.io/apiserver/pkg/storage/interfaces.go#L140-L153. The preconditions is optional. Introducing preconditions mainly requires changes to the API server model (modeling the uid and resource version checking) and the shim layer (passing the preconditions to kube).

This PR also fixes some of the lemmas that are broken due to preconditions.

Having preconditions allows us to use more restrictive deletion. This is useful to ensure no interference between controllers that manage pods --- when a controller decides to delete a pod that the controller believes belongs to itself, the controller should pass to the preconditions the resource version of the pod it observes. When API server handles the delete request, if the pod happens to be owned by a different controller, then the deletion will be invalidated (because the resource version must have already changed since the controller's observation) so that the controller won't interfere with the new owner of the pod.

@marshtompsxd marshtompsxd changed the title Support preconditions for Delete request Support preconditions for Delete request Sep 29, 2024
@marshtompsxd marshtompsxd added this pull request to the merge queue Sep 29, 2024
Merged via the queue into main with commit 52e8753 Sep 29, 2024
16 checks passed
@marshtompsxd marshtompsxd deleted the xudong/delete-precondition branch October 21, 2024 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant