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

ignore ENOENT errors when parsing .d files #2696

Merged
merged 3 commits into from
Jan 27, 2025
Merged

Conversation

Luap99
Copy link
Member

@Luap99 Luap99 commented Jan 27, 2025

There is a expected race condition between listing files and actually opening them. Between that time the file might have been removed already. This is not really a real error so we should just ignore it as otherwise flakes will happen in the wild.

See the first commit for a real flake, the other two ones I have not observed but I thought I might as well fix it for all .d readers. Are there other files I missed?

As always listing files in a dir to then read them is racy as the file
might have been removed in the meantime. Thus we must ignore ENOENT
errors when the file is opened.

This is not just a theoretical problem, the reason I am here is because
it caused a flake in the podman CI[1]:
... open /etc/containers/registries.d/podman-test-only-temporary-addition.yaml: no such file or directory

[1] https://api.cirrus-ci.com/v1/artifact/task/6673405799301120/html/int-podman-fedora-40-root-host-boltdb.log.html#t--Podman-push-podman-push-to-local-registry-with-authorization--1

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
As always listing files in a dir to then read them is racy as the file
might have been removed in the meantime. Thus we must ignore ENOENT
errors when the file is opened.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
As always listing files in a dir to then read them is racy as the file
might have been removed in the meantime. Thus we must ignore ENOENT
errors when the file is opened.

Now here the code already did not cause an hard error but it will cause
a spurious warning in such case. There is really no need to log that as
it can cause flakes for podman.

Now there is the case here for .cert and .key files where both files
must be present for a valid config. Ignoring ENOENT there seems wrong as
it would hide a common misconfiguration where only one of the files
exists. That mean the race can still cause a failure when these files
are removed from the dir.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
@rhatdan
Copy link
Member

rhatdan commented Jan 27, 2025

LGTM

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Thanks!

(I’m not sure this will quite fix the Podman flake — there is still a race between creating the /etc/containers/registries.d/podman-test-only-temporary-addition.yaml file and actually writing data to it, IIRC cp is defined not to use the atomic Rename() approach — but in general, with Podman running potentially in system services, it would be hard for users to coordinate config file changes so that they reliably never interfere with a running c/image code; so I agree this is a good improvement in any case.)

@mtrmac mtrmac merged commit 7f0e59d into containers:main Jan 27, 2025
10 checks passed
@Luap99 Luap99 deleted the ENOENT branch January 27, 2025 21:01
@Luap99
Copy link
Member Author

Luap99 commented Jan 28, 2025

I’m not sure this will quite fix the Podman flake — there is still a race between creating the /etc/containers/registries.d/podman-test-only-temporary-addition.yaml file and actually writing data to it

Ah right, I didn't consider the possibility of the partial file there. That is certainly something that needs fixing in the podman suite long term.

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.

None yet

3 participants