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

[WIP] imagebuildah: prevent race cause c/storage does not persist names with layers. #3794

Closed
wants to merge 1 commit into from

Conversation

flouthoc
Copy link
Collaborator

@flouthoc flouthoc commented Feb 22, 2022

When running concurrent builds references to layers are changed and
c/storage does not accounts for names so use ID where possible.

Builds fail with image not known.

Reproducer

#!/bin/bash
x=1
sudo ./podman rmi -af
rm -f log*.*
sudo ./podman build -t first . &> logfirst.log
while [ $x -le 30 ]
do
  echo "$x times"
  sudo ./podman build --log-level debug -t $x . &> log$x.log &
  x=$(( $x + 1 ))
#  sleep 1
done

Dockerfile

FROM quay.io/jitesoft/alpine

Note:

This PR is just for discussion to confirm if we can do better solutions or not. I believe underlying problem still persists either in c/image or c/storage. See bz 2055487

When running concurrent builds references to layers are changed and
c/storage does not accounts for names so use ID where possible.

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]

Signed-off-by: Aditya R <[email protected]>
@flouthoc
Copy link
Collaborator Author

@giuseppe @nalind PTAL. I am sure something could be done at c/storage to fix rootcause as well but this should also fix the mentioned issue in the PR and original BZ.

Issue is easy to reporduce with podman or buildah build --layers for some reason i don't see this with buildah build --layers very often however race is easily reproduce-able in podman.

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 22, 2022

[APPROVALNOTIFIER] This PR is APPROVED

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

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

img, err = is.Transport.GetStoreImage(b.store, dest)
logrus.Debugf("assigned names %v to image %q", img.Names, img.ID)

_, img, err = util.FindImage(b.store, "", b.systemContext, imageID)
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this the same line that was called in 747?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rhatdan It is called again after we perform tagging of current name and any additionalTags if they were present. So we can return a success message for each one of them.

Copy link
Member

Choose a reason for hiding this comment

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

Is this still a draft or ready to merge?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll just test it with few more edge cases just to be sure and waiting for @nalind to also take a quick look.

}
logrus.Debugf("assigned names %v to image %q", img.Names, img.ID)

b.additionalTags = append(b.additionalTags, dest.DockerReference().String())
Copy link
Member

Choose a reason for hiding this comment

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

That name was assigned to the image when it was committed, wasn't it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@nalind There seems be a race in c/storage and layers don't have name as the property while they get stored, so in concurrent build somehow the reference for name gets altered by other builds using the same blob.

I can drop this particular line if its bothering and add a tight locking while tagging as well. But motivation behind this was just a additional safety check, this might not be needed. I'll verify and remove this if its not needed.

@flouthoc
Copy link
Collaborator Author

flouthoc commented Feb 23, 2022

We might not need this PR anymore, rootcause will be fixed in c/storage here: containers/storage#1153 and I'll close this PR once we fix c/common as well.

@flouthoc
Copy link
Collaborator Author

flouthoc commented Mar 2, 2022

This PR is not needed after containers/image#1480 and containers/storage#1153

@flouthoc flouthoc closed this Mar 2, 2022
flouthoc added a commit to flouthoc/podman that referenced this pull request Mar 3, 2022
Invoking parallel/concurrent builds from podman race against each other
following behviour was fixed in
containers/storage#1153 and containers/image#1480

Test verifies if following bug is fixed in new race-free API or not.
Read more about this issue, see bz 2055487 for more details.

More details here: containers/buildah#3794 and containers#13339

Co-authored-by: Ed Santiago <[email protected]>
Signed-off-by: Aditya R <[email protected]>
flouthoc added a commit to flouthoc/podman that referenced this pull request Apr 6, 2022
Invoking parallel/concurrent builds from podman race against each other
following behviour was fixed in
containers/storage#1153 and containers/image#1480

Test verifies if following bug is fixed in new race-free API or not.
Read more about this issue, see bz 2055487 for more details.

More details here: containers/buildah#3794 and containers#13339

Co-authored-by: Ed Santiago <[email protected]>
Signed-off-by: Aditya R <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants