Skip to content

apps: fix a race in watch-appstream.py#23126

Open
allisonkarlitskaya wants to merge 1 commit intocockpit-project:mainfrom
allisonkarlitskaya:deflake
Open

apps: fix a race in watch-appstream.py#23126
allisonkarlitskaya wants to merge 1 commit intocockpit-project:mainfrom
allisonkarlitskaya:deflake

Conversation

@allisonkarlitskaya
Copy link
Copy Markdown
Member

We have a recursive directory-watching rig which uses inotify to watch for files in a directory and also supports situations where the directories don't exist to start with. We attempt to that that in TestApps.testBasic by deleting the directories and waiting for them to be created by appstream.

Unfortunately this code contains a race: if we find a directory missing, we register a watch for it and wait for it to appear. We don't check if the directory got created before our watch was established though, which means we could end up waiting forever. The test is also arranged in such a way that these two things happen at approximately the same time.

Let's double-check after establishing the watch: if the path exists, reset() the watch to start the process from the start. It's not the most elegant way to do this, but it should hopefully be rare.

This should hopefully solve one of our most common current flakes. Even if it doesn't, it's a bug that deserves to be fixed.

Assisted-by: Claude Opus 4.6

We have a recursive directory-watching rig which uses inotify to watch
for files in a directory and also supports situations where the
directories don't exist to start with.  We attempt to that that in
`TestApps.testBasic` by deleting the directories and waiting for them to
be created by appstream.

Unfortunately this code contains a race: if we find a directory missing,
we register a watch for it and wait for it to appear.  We don't check if
the directory got created before our watch was established though, which
means we could end up waiting forever.  The test is also arranged in
such a way that these two things happen at approximately the same time.

Let's double-check after establishing the watch: if the path exists,
reset() the watch to start the process from the start.  It's not the
most elegant way to do this, but it should hopefully be rare.

This should hopefully solve one of our most common current flakes.  Even
if it doesn't, it's a bug that deserves to be fixed.

Assisted-by: Claude Opus 4.6
Copy link
Copy Markdown
Member

@mvollmer mvollmer left a comment

Choose a reason for hiding this comment

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

Thanks, excellent!

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