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

libimage, ManifestList: fslock and reload to provide race-free Add API #1090

Merged
merged 1 commit into from
Jul 15, 2022

Conversation

flouthoc
Copy link
Collaborator

@flouthoc flouthoc commented Jul 14, 2022

podman manifest add uses ManifestList.Add( but as of now Add( does
not locks while adding instances to the list thus causing race scenarios
where storage is not reloaded and overridden by another invocation of the
command.

Following problem is solved in two steps

  • Add -> LockByID: Acquire a fs lock by instance ID so other
    invocation waits until this invocation completes its write.
  • Add -> LockByID -> reload: Reload instance digests from storage
    just after acquiring lock to make sure we are not overriding any just
    written instance.

Reproducer: containers/podman#14667 (comment)

Closes: BZ#2105173
Closes: containers/podman#14667

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]
This needs integration tests so its hard to verify race in c/common CI

`podman manifest add` uses `ManifestList.Add(` but of now `Add(` does
not locks while adding instances to the list thus causing race scenarios
where storage is not reloaded and overrided by another invocation of the
command.

Following problem is solved in two steps

* Add -> LockByInstance: Acquire a fs lock by instance ID so other
  invocation waits until this invocation completes its write.
* Add -> LockByInstance -> reload: Reload instance digests from storage
  just after acquiring lock to make sure we are not overriding any just
written instance.

Reproducer: containers/podman#14667 (comment)

Closes: containers/podman#14667

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]
This needes integration tests so its hard to verify race in CI.

Signed-off-by: Aditya R <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented Jul 14, 2022

/approved
LGTM
@Luap99 @vrothberg @mheon PTAL

@mheon
Copy link
Member

mheon commented Jul 14, 2022

LGTM, but I'd like an ack from @vrothberg before we merge

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM, nice work, @flouthoc

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 15, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, vrothberg

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

@vrothberg
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jul 15, 2022
@openshift-ci openshift-ci bot merged commit 2ac10fa into containers:main Jul 15, 2022
@flouthoc
Copy link
Collaborator Author

flouthoc commented Jul 15, 2022

Thanks, Syncing this to buildah and podman so i can update the BZ
Edit: Nvm i'll wait for containers/podman#14907 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"podman manifest add" is not concurrent safe
4 participants