Skip to content

Conversation

@mikemccracken
Copy link
Contributor

@mikemccracken mikemccracken commented Dec 9, 2025

What type of PR is this?

bug... fix!

Which issue does this PR fix:

#645

In situations where concurrent stacker runs are happening on a system, and they are building containers with the same name, and they are being done inside a mount namespace,
and the path name given as the roots dir is the same, but the actual mounted volume is different,
then both stackers will be able to acquire the file lock at $rootdir/.lock, and will go ahead and start containers named $name, which will then race to set up the lxc control socket, which is named after the container name and the rootfs path, which are both the same here.

What does this PR do / Why do we need it:

The fix is to add some randomness to the lxc container name, which ensures that the socket won't clash. This does not affect other uses of the image name in the code, which will still use the un-randomized name.

Testing done on this change:

Manual testing, plus the PR adds concurrent.bats to catch regressions.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mikemccracken
Copy link
Contributor Author

replaces #651

@mikemccracken mikemccracken force-pushed the 2025.11.24/main/uniquify-container-names-2 branch from 450b031 to 69f86db Compare December 9, 2025 19:38
@codecov
Copy link

codecov bot commented Dec 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.83%. Comparing base (ad24357) to head (cf95fd0).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #746      +/-   ##
==========================================
+ Coverage   51.67%   51.83%   +0.16%     
==========================================
  Files          59       59              
  Lines        6491     6492       +1     
==========================================
+ Hits         3354     3365      +11     
+ Misses       2489     2483       -6     
+ Partials      648      644       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mikemccracken mikemccracken marked this pull request as ready for review December 9, 2025 22:08
@mikemccracken mikemccracken changed the title fix: uniquify container names part deux fix: uniquify container names Dec 9, 2025
@rchincha rchincha requested a review from Copilot December 10, 2025 17:09

This comment was marked as spam.

@rchincha
Copy link
Contributor

@mikemccracken there are some copilot reviews, pls take a look.

@mikemccracken mikemccracken force-pushed the 2025.11.24/main/uniquify-container-names-2 branch from 69f86db to 5544203 Compare December 10, 2025 23:03
Currently, if:
concurrent stacker runs are happening on a system,
and they are building containers with the same name,
and they are being done inside a mount namespace,
and the path name given as the roots dir is the same,
but the actual mounted volume is different,

then both stackers will be able to acquire the file lock at
$rootdir/.lock, and will go ahead and start containers named $name,
which will then race to set up the lxc control socket, which is named
after the container name and the rootfs path, which are both the same
here.

This fix adds a UUID to the container name, which ensures the sockets do
not clash.

Adds a test 'concurrent.bats' to test this, and includes some other test
changes to make it easier to run tests locally with a cached copy of the
base images.

Signed-off-by: Michael McCracken <[email protected]>
should be able to re-run 'make download-tools' and not have it fail

Signed-off-by: Michael McCracken <[email protected]>
When debugging tests, if you comment out the cleanup in helpers, you end
up with a bunch of stackertest- dirs which really gum up the output of
search tools while you work, so ignore those dirs.

Signed-off-by: Michael McCracken <[email protected]>
We do this elsewhere, should have had this in from the start

Signed-off-by: Michael McCracken <[email protected]>
@mikemccracken mikemccracken force-pushed the 2025.11.24/main/uniquify-container-names-2 branch from 5544203 to cf95fd0 Compare December 11, 2025 20:14
@rchincha
Copy link
Contributor

lgtm

Will this need a minor release after merge?

@mikemccracken
Copy link
Contributor Author

mikemccracken commented Dec 12, 2025 via email

@rchincha rchincha merged commit c25c905 into project-stacker:main Dec 12, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants