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

commit: use race-free RemoveNames instead of SetNames for pruning names #4190

Merged
merged 1 commit into from
Aug 19, 2022

Conversation

flouthoc
Copy link
Collaborator

PR containers/storage#1153 added a dedicated API
to remove names assigned to image so use RemoveNames
instead of racy SetNames.

How to verify
  • Refer to newly added integration test.
Reproduce on local using
printf 'from quay.io/jitesoft/alpine:latest\nrun for i in $(seq 0 10000); do touch /$i; done\n' >Containerfile && for i in `seq 1 25`; do ./buildah build --squash --iidfile id.$i --timestamp 0 . & done; wait; ls -al

Closes: containers/podman#15162

@flouthoc flouthoc changed the title commit: use race-free RemoveNames instead of SetNames commit: use race-free RemoveNames instead of SetNames for pruning names Aug 17, 2022
@flouthoc
Copy link
Collaborator Author

The test passes on my local I wonder what did i do wrong here that it is failing on CI. @edsantiago Could help me by providing any hints ?

My local output

++ time bats --tap . --filter "performing parallel commits"
1..1
ok 1 build: test race in updating image name while performing parallel commits

real	0m34.193s
user	2m13.625s
sys	1m22.299s

@flouthoc
Copy link
Collaborator Author

flouthoc commented Aug 17, 2022

Assuming its the wildcard causing issues in CI, so applying this

diff --git a/tests/bud.bats b/tests/bud.bats
index 562414e4..70fc9146 100644
--- a/tests/bud.bats
+++ b/tests/bud.bats
@@ -402,7 +402,9 @@ _EOF
   # even if some of the individual builds fail! Our actual test is below.
   wait
   # Number of output bytes must be always same, which confirms that there is no race.
-  test $(cat ${TEST_SCRATCH_DIR}/id*|wc -c) = 1775
+  for i in $(seq --format '%02g' 1 $count); do
+      test $(cat ${TEST_SCRATCH_DIR}/id.$i|wc -c) = 71
+  done
   # clean all images built for this test
   run_buildah rmi --all -f
 }

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

@flouthoc flouthoc force-pushed the race-free-commit branch 2 times, most recently from 640360e to d895517 Compare August 17, 2022 11:18
tests/bud.bats Outdated
wait
# Number of output bytes must be always same, which confirms that there is no race.
for i in $(seq --format '%02g' 1 $count); do
test $(cat ${TEST_SCRATCH_DIR}/id.$i|wc -c) = 71
Copy link
Member

Choose a reason for hiding this comment

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

Please do not use test. Do not ever use test. That gives no information whatsoever to the poor person trying to debug a test failure. Please use assert.

Copy link
Member

Choose a reason for hiding this comment

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

So, going back to the first question, you can rewrite it the first way as

    assert "$(cat ${TEST_SCRATCH_DIR}/id.* | wc -c)" = 1775 "Total chars in all id.* files"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks @edsantiago , Amended, I'll wait and hope CI goes green now ( passes on my local )

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 17, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: edsantiago, 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

@rhatdan
Copy link
Member

rhatdan commented Aug 17, 2022

/lgtm
/hold

tests/bud.bats Outdated Show resolved Hide resolved
@edsantiago
Copy link
Member

I see no fixes for all the other failures...?

@flouthoc
Copy link
Collaborator Author

I see no fixes for all the other failures...?

@edsantiago ackd, I'll check other failing tests now.

@flouthoc
Copy link
Collaborator Author

I see no fixes for all the other failures...?

I think this should be good now. :)

@edsantiago
Copy link
Member

LGTM and tests are green

@flouthoc
Copy link
Collaborator Author

@containers/buildah-maintainers @nalind @rhatdan PTAL

@TomSweeneyRedHat
Copy link
Member

LGTM

@TomSweeneyRedHat
Copy link
Member

/lgtm

PR containers/storage#1153 added a dedicated API
to remove names assigned image so use `RemoveNames` instead of racy
`SetNames`.

How to verify
```console
printf 'from quay.io/jitesoft/alpine:latest\nrun for i in $(seq 0 10000); do touch /$i; done\n' >Containerfile && for i in `seq 1 25`; do ./buildah build --squash --iidfile id.$i --timestamp 0 . & done; wait; ls -al
```

* Refer to newly added integration test.

Closes: containers/podman#15162

Signed-off-by: Aditya R <[email protected]>
@openshift-ci openshift-ci bot removed the lgtm label Aug 19, 2022
@flouthoc
Copy link
Collaborator Author

New changes are detected. LGTM label has been removed.

Rebased cause merge bot was stuck.

@edsantiago
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Aug 19, 2022
@openshift-merge-robot openshift-merge-robot merged commit c5e11e3 into containers:main Aug 19, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 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.

--iidfile can write just sha256: string, without the actual image id
6 participants