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

buildah fails when REGISTRY_AUTH_FILE doesn't exist #3259

Closed
rcny opened this issue May 26, 2021 · 9 comments · Fixed by #3274
Closed

buildah fails when REGISTRY_AUTH_FILE doesn't exist #3259

rcny opened this issue May 26, 2021 · 9 comments · Fixed by #3274

Comments

@rcny
Copy link

rcny commented May 26, 2021

Hello!

Setting REGISTRY_AUTH_FILE to a non-existent file will result in buildah failing to operate with public registries:

[root@dd836c415cc3 /]# env REGISTRY_AUTH_FILE=/tmp/non_existent_creds.json buildah pull docker.io/library/hello-world
error checking authfile path /tmp/non_existent_creds.json: stat /tmp/non_existent_creds.json: no such file or directory

Is this a feature or a bug?

Currently I resolve it with e.g. env REGISTRY_AUTH_FILE= buildah pull docker.io/library/hello-world for specific commands. Can't remove REGISTRY_AUTH_FILE at all because of #3216.

Running 1.20.1 from current quay.io/buildah/stable image.

@rhatdan
Copy link
Member

rhatdan commented May 26, 2021

I am thinking this is a bug.

We should only check for the existence of the authfile if the user specifies it.

@vrothberg
Copy link
Member

I consider setting the env var as user-specified input (i.e., the counterpart of --authfile).

rhatdan added a commit to rhatdan/buildah that referenced this issue May 26, 2021
This allows us to have a REGISTRY_AUTH_FILE and only fail when
the authfile is specified to be used.  If the user specifies it
that means he intends to use it.

Fixes: containers#3259

Signed-off-by: Daniel J Walsh <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented May 26, 2021

The thing is we do not need to fail until the user actually attempts to use the file, in that case.

@rhatdan
Copy link
Member

rhatdan commented May 26, 2021

For example the use case that this user was hitting was having it set within a container image, and only used when needed. We would fail all the time.

rhatdan added a commit to rhatdan/buildah that referenced this issue May 26, 2021
This allows us to have a REGISTRY_AUTH_FILE and only fail when
the authfile is specified to be used.  If the user specifies it
that means he intends to use it.

Fixes: containers#3259

Signed-off-by: Daniel J Walsh <[email protected]>
@TriplEight
Copy link

I'm having the same issue with buildah logout, even when it wasn't logged in anywhere:

buildah logout --all
error checking authfile path /tmp/registry_auth.json: stat /tmp/registry_auth.json: no such file or directory

@TriplEight
Copy link

and with the workaround I'm getting the other misleading output:

env REGISTRY_AUTH_FILE= buildah logout docker.io
Not logged into docker.io

@rhatdan
Copy link
Member

rhatdan commented May 26, 2021

Why is this misleading?

@TomSweeneyRedHat
Copy link
Member

I think the logout error is misleading as it doesn't indicate that the file doesn't exist. From reading the message, I'd think the authfile existed, I just didn't have an entry in the authfile.

@rhatdan
Copy link
Member

rhatdan commented May 26, 2021

We treat REGISTRY_AUTH_FILE="" the same as we do not being set at all.

rhatdan added a commit to rhatdan/buildah that referenced this issue Jun 2, 2021
If you are running buildah within a user namespace, without
XDG_RUNTIME_DIR being set, we need to make sure buildah login, logout
handle XDG_RUNTIME_DIR the same was as buildah push.

Running buildah within a container is triggering failures, where buildah
login puts the auth.json file in /run/containers/0/auth.json but buildah
push looks for it in
/tmp/container-user-0/containers/containers/auth.json

Fixes: containers#3259

[NO TESTS NEEDED] The existing tests should see if this causes any
problems.

Signed-off-by: Daniel J Walsh <[email protected]>
rhatdan added a commit to rhatdan/buildah that referenced this issue Jun 2, 2021
If you are running buildah within a user namespace, without
XDG_RUNTIME_DIR being set, we need to make sure buildah login, logout
handle XDG_RUNTIME_DIR the same was as buildah push.

Running buildah within a container is triggering failures, where buildah
login puts the auth.json file in /run/containers/0/auth.json but buildah
push looks for it in
/tmp/container-user-0/containers/containers/auth.json

Fixes: containers#3259

[NO TESTS NEEDED] The existing tests should see if this causes any
problems.

Signed-off-by: Daniel J Walsh <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants