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

[release-0.19] 🐛 Fakeclient: Fix TOCTOU races #2992

Conversation

k8s-infra-cherrypick-robot

This is an automated cherry-pick of #2980

/assign alvaroaleman

The fake client currently has a number of time of check time of use
races, where it fetches an object to determine what to do in a mutating
operation. The problem is that the object might change in between
fetching it and doing the mutating operation. Most notably, this
happens when:
* Patching is done in parallel. Only one of the patches will succeed,
  the other ones will fail with a conflict
* Updates of objects that allow unconditional updates: All updates will
  succeed, but not all of them will increment the resource version (i.E
  dirty writes for the RV)
* An update for an object that allows createOnUpdate races with a create
  or delete
* A DeleteAllOf call races with Delete calls
* A scale update races with a normal update

This change:
* Adds tests for all of these cases
* Fixes them by adding a lock around the write operations, including
  their read part, if any
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 19, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 19, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: cc66a637acaf4017f90bf2811e65034d5f4332e1

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, k8s-infra-cherrypick-robot

The full list of commands accepted by this bot can be found here.

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 19, 2024
@k8s-ci-robot k8s-ci-robot merged commit 013f46f into kubernetes-sigs:release-0.19 Oct 19, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants