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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Use non blocking file locking for flock library #1605

Merged
merged 1 commit into from Jul 27, 2021

Conversation

vincepri
Copy link
Member

@vincepri vincepri commented Jul 27, 2021

Signed-off-by: Vince Prignano vincepri@vmware.com

Fixes #1599

@k8s-ci-robot k8s-ci-robot added 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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 27, 2021
@vincepri vincepri force-pushed the flock-nb branch 2 times, most recently from aea8d8e to ef91bc3 Compare July 27, 2021 19:22
return unix.Flock(fd, unix.LOCK_EX)
err = unix.Flock(fd, unix.LOCK_NB|unix.LOCK_EX)
if errors.Is(err, unix.EWOULDBLOCK) { // This condition requires LOCK_NB.
return errors.Wrapf(ErrAlreadyLocked, "cannot lock file %q", path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, can we just use the stdlib wrapping (fmt.Errorf("cannot lock file %q: %w", path, err)?

Copy link
Member Author

@vincepri vincepri Jul 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fmt.Errorf wouldn't wrap things properly, and we can't use errors.Is on the other side

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err what? If you wrap using fmt.Errorf("%w", err), errors.Is should absolutely work

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, I didn't know that was the case, fixed.

@vincepri vincepri force-pushed the flock-nb branch 2 times, most recently from 965003c to c439bb6 Compare July 27, 2021 20:49
Signed-off-by: Vince Prignano <vincepri@vmware.com>
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 27, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, vincepri

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:
  • OWNERS [alvaroaleman,vincepri]

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 merged commit 3203c07 into kubernetes-sigs:master Jul 27, 2021
@k8s-ci-robot k8s-ci-robot added this to the v0.10.x milestone Jul 27, 2021
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parallel envtests getting stuck in flock
3 participants