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

Pulling images from a diferent private repository than context fails after v1.7.0 #2576

Open
atorrembo opened this issue Jun 15, 2023 · 16 comments
Labels
area/authentication area/registry For all bugs having to do with pushing/pulling into registries gitlab kind/bug Something isn't working priority/p0 Highest priority. Break user flow. We are actively looking at delivering it. regression/v1.7.0 regression

Comments

@atorrembo
Copy link

atorrembo commented Jun 15, 2023

Actual behavior
Trying to run a pipeline in GitLab Runner using Kubernetes executor with a private repository that has a Multistage Dockerfile using a FROM image from another private repository in the same gitlab project/group (Same access credentials)

Context:
/PRIVATE_GROUP-1/PRIVATE_PROJECT1

Script in the build stage:
/kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/Dockerfile" --target "prod" --no-push

Returns:

error checking push permissions -- make sure you entered the correct tag name, and that you are authenticated correctly, and try again: checking push permission for "registry.gitlab.com/privategroupname/privateregistryname/image:version": creating push check transport for registry.gitlab.com failed: GET https://gitlab.com/jwt/auth?scope=PRIVATE_REGISTRY:push,pull&service=container_registry: DENIED: access forbidden

Using --no-push parameter I got another clue

INFO[0000] Retrieving image registry.gitlab.com/privateregistry/image:1.0 from registry registry.gitlab.com
error building image: GET https://gitlab.com/jwt/auth?scope=PRIVATE_REGISTRY:pull&service=container_registry: UNAUTHORIZED:
HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password. See https://gitlab.com/help/user/profile/account/two_factor_authentication#troubleshooting

So after trying everything I've found in the internet I started downgrading versions from v1.11.0 until in v1.7.0 the job starts to work as expected.

Expected behavior
Image built and pushed to a private repository

To Reproduce
Steps to reproduce the behavior:

  1. Run a build Job in a Project having a Dockerfile using a FROM image from another project registry in the same group (same credentials). I handle the authentication by injecting the docker.json file

Additional Information

  • Dockerfile
    FROM registry.gitlab.com/PRIVATE_GROUP-1/PRIVATE_REGISTRY-2/runner:3.11 AS prod
  • Build Context
    Just FROM, it fails in the first step trying to pull that image
  • Kaniko Image (fully qualified with digest)
    V1.7.0 OK
    V1.8.0 FAILS
    V1.9.0 FAILS
    V1.10.0 FAILS
    V1.11.0 FAILS

Part of my runners config:
# [[runners.kubernetes.volumes.secret]]
# name = "gitlab-registry-token"
# mount_path = "/root/.docker/"

And the secret:
image

This is only additonal info, this configuration works with "docker pull" and with kaniko < 1.7

  • A "docker pull" command added for testing in the same job works OK

Triage Notes for the Maintainers

Description Yes/No
Please check if this a new feature you are proposing
  • - [No]
Please check if the build works in docker but not in kaniko
  • - [Yes]
Please check if this error is seen when you use --cache flag
  • - [No]
Please check if your dockerfile is a multistage dockerfile
  • - [Yes]
@atorrembo atorrembo changed the title Pulling images from private repositories fails after v1.7.0 Pulling images from a diferent private repositorie than context fails after v1.7.0 Jun 15, 2023
@atorrembo atorrembo changed the title Pulling images from a diferent private repositorie than context fails after v1.7.0 Pulling images from a diferent private repository than context fails after v1.7.0 Jun 15, 2023
@aaron-prindle aaron-prindle added regression priority/p0 Highest priority. Break user flow. We are actively looking at delivering it. area/registry For all bugs having to do with pushing/pulling into registries area/authentication kind/bug Something isn't working gitlab regression/v1.7.0 labels Jun 21, 2023
@lusu007
Copy link

lusu007 commented Jun 21, 2023

I encountered the same problem when I set up Harbor as a proxy for DockerHub to overcome DockerHub's strict rate limiting. However, upon changing the base image to the proxy registry, I encountered this issue. 🫤

@lusu007
Copy link

lusu007 commented Jul 10, 2023

Is there any update regarding this issue? DockerHub's rate limiting is causing significant disruptions to my pipeline, effectively halving its efficiency. I'm eagerly hoping for a resolution to this problem, as it would enable me to overcome the rate limit restrictions and restore my pipeline's full functionality.

@algo7
Copy link

algo7 commented Jul 10, 2023

Any news on this?

@lusu007
Copy link

lusu007 commented Sep 26, 2023

Hey,
this still makes our proxy cache unusable. I would be happy to provide more information if needed and I would appreciate if someone could take a look at this.

@zijiwork
Copy link

What progress has been made?

@RufusJWB
Copy link

It would be great if you could provide a fix or a recommended work-around. This problem will probably appear more often in the next months, since Visual Studio is now creating multistage build files for container deployment of ASP.net applications: https://learn.microsoft.com/en-us/visualstudio/containers/container-build?view=vs-2022#multistage-build . I hope my reproducible problem description in #2944 will help you fixing this issue.

@atorrembo
Copy link
Author

Have you tried using runner version 1.7.0?

@lusu007
Copy link

lusu007 commented Jan 18, 2024

Have you tried using runner version 1.7.0?

Using an old outdated version isn't an optimal solution. 😅

@atorrembo
Copy link
Author

Nope, just for investigation/debuggin purposes

@RufusJWB
Copy link

Have you tried using runner version 1.7.0?

I just did. This is the docker file I use:

FROM gcr.io/kaniko-project/executor:v1.7.0-debug

WORKDIR /buildDir/SRC

COPY . .

WORKDIR "PROXY Protocol Tester"

CMD ["--verbosity=debug", "--ignore-path=/buildDir", "--context=/buildDir", "--single-snapshot", "--cache=false", "--dockerfile=/buildDir/SRC/PROXY Protocol Tester/Dockerfile", "--no-push"]

But it is also failing: https://gist.github.com/RufusJWB/1e9b46657faea8c4ea31574fcc120c44

@DeanHnter
Copy link

Still having this exact issue with current version

@RufusJWB
Copy link

Still having this exact issue with current version

Have a look into my repro: #2944 I was able to fix it.

@lusu007
Copy link

lusu007 commented Feb 16, 2024

Still having this exact issue with current version

Have a look into my repro: #2944 I was able to fix it.

I just tried your suggested fix, but it's not working for me. In my opinion #2944 and this issue aren't even related because we are having authentication issues and you are not. 🙁

Even with your fixes implemented I still get the following error:

error checking push permissions -- make sure you entered the correct tag name, and that you are authenticated correctly, and try again: checking push permission for "redacted.com/redacted/redacted": POST https://redacted.com/v2/redacted/redacted/blobs/uploads/: UNAUTHORIZED: unauthorized to access repository: redacted/redacted, action: push: unauthorized to access repository: redacted/redacted, action: push

@lusu007
Copy link

lusu007 commented Jul 5, 2024

After further debugging, I found that the problem arises when the --no-push flag is utilized. However, when the --no-push flag isn't set, but a --destination is specified, the error disappears and authentication proceeds successfully.

I believe the no-push flag should not influence the authentication when pulling base images.

@meyfa
Copy link

meyfa commented Jul 5, 2024

With --no-push set, this code is never called:

if err := checkRemotePushPermission(destRef, creds.GetKeychain(), tr); err != nil {

Behind the scenes, that function performs authentication against the registry. As such, unless we are pushing, auth is never performed.

We would need an additional function, e.g., checkRemotePullPermissions, that runs in case --no-push is set. This would allow us to use remote images as the base image even without pushing.

@atorrembo
Copy link
Author

damn...
setting env var DOCKER_CONFIG=/root/.docker did the trick (running on gitlab kubernetes executor]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/authentication area/registry For all bugs having to do with pushing/pulling into registries gitlab kind/bug Something isn't working priority/p0 Highest priority. Break user flow. We are actively looking at delivering it. regression/v1.7.0 regression
Projects
None yet
Development

No branches or pull requests

8 participants