Skip to content

tests-integration: Serialize the install-config writer against readers - #2520

Merged
cgwalters merged 1 commit into
bootc-dev:mainfrom
cgwalters-forge:bot/printconfig-race
Oct 1, 2026
Merged

cgwalters merged 1 commit into
bootc-dev:mainfrom
cgwalters-forge:bot/printconfig-race

Conversation

@cgwalters-bot

@cgwalters-bot cgwalters-bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

The install config container integration test flakes with error: Loading configuration: No such file or directory (os error 2) (seen on the sealed leg of #2500, and in a fork run on 2026-09-24). libtest runs the container tests as concurrent threads, and printconfig --all creates then removes /run/bootc/install/10-test.toml, which bootc install print-configuration in the install config test can find in its directory scan and then fail to open (or read half-written).

Per review this is fixed only in the tests: a shared RwLock in container.rs, taken for writing by the test that writes install config and for reading by the one that reads it. A std::sync::RwLock is enough since all the container tests are threads of one bootc-integration-tests process.

Testing, on a 16-core devspace with BOOTC_base=quay.io/fedora/fedora-bootc:44:

  • just validate passed; just test-container passed (unit tests and all 10 container integration tests), and just test-container-integration passed 5/5 more runs.
  • Running just the two config tests concurrently (bootc-integration-tests container --test-threads=2 config) 300 times failed 0 times, but so did the same on unpatched main, so the race window is too narrow to reproduce directly that way.
  • So, with a throwaway probe making install config poll for the writer's 10-test.toml for 200ms before reading: with the lock it never saw it (0/200 runs); with the writer taking the lock for reading instead of writing it saw it in 200/200.

The Signed-off-by: Colin Walters <walters@verbum.org> on this commit (f4264de) was kept from cgwalters's approval of the review draft (cgwalters-forge#24 (review)) through the rework he asked for in #2520 (review) (dropping the product-code commit and switching to a RwLock).

Generated-by: https://github.com/cgwalters/#llms

Comment thread crates/lib/src/install/config.rs Outdated
/// Read a configuration fragment found by a directory scan, returning `None`
/// if it was removed since the scan: `/run` and `/etc` are writable, so a
/// fragment can vanish while we're loading, and that shouldn't be fatal.
fn read_fragment(path: &std::path::Path) -> Result<Option<String>> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No, we should only fix the tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Dropped the config.rs commit; the PR is now test-only (f4264de, your sign-off kept).

/// Serializes the tests that read the install config against the one that
/// adds a fragment to /run/bootc/install, since libtest runs them concurrently
/// and the other readers would otherwise see its temporary config.
static INSTALL_CONFIG_LOCK: Mutex<()> = Mutex::new(());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the test that writes config needs to be mutually exclusive with the others, don't we want a RWLock?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, now a std::sync::RwLock (the container tests are threads of one process): printconfig --all takes it for writing, install config for reading. A probe that polls for the fragment in the reader saw it 0/200 runs with this and 200/200 without exclusion; details in the PR body. @cgwalters, ready for another look.

@cgwalters-bot cgwalters-bot changed the title install/config: Skip config fragments that vanish while loading tests-integration: Serialize the install-config writer against readers Oct 1, 2026
libtest runs the container tests concurrently as threads of one
process, and "printconfig --all" writes and then removes a fragment in
/run/bootc/install that "install config" can pick up while scanning the
same directory. That made "install config" flake with a bare "No such
file or directory" when the fragment vanished between the scan and the
read, and it could also see the fragment half-written or get the wrong
config.

This is a race between the tests, so fix it there: the test that writes
config takes a write lock and the ones that read it take a read lock.

Generated-by: AI
Signed-off-by: Colin Walters <walters@verbum.org>
@cgwalters-bot

Copy link
Copy Markdown
Contributor Author

Rebased onto main; 1 commit, no content change.

Generated-by: https://github.com/cgwalters/#llms

@cgwalters
cgwalters merged commit 637a5ff into bootc-dev:main Oct 1, 2026
92 of 95 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/install Issues related to `bootc install`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants