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

odsComponentStageCopyImage fails for some sourceImageUrlIncludingRegistry strings #1174

Closed
dechants opened this issue Oct 28, 2024 · 4 comments · Fixed by #1177
Closed

odsComponentStageCopyImage fails for some sourceImageUrlIncludingRegistry strings #1174

dechants opened this issue Oct 28, 2024 · 4 comments · Fixed by #1177
Labels
bug Something isn't working

Comments

@dechants
Copy link

dechants commented Oct 28, 2024

Describe the bug
We import images from a private registry. Unfortunately some images are in the following format:

private-registry.com/kong:3.0.1

The component fails in this case because it prepends the internal registry:

skopeo copy --src-tls-verify=false --src-creds user@....:**** docker://image-registry.openshift-image-registry.svc:5000/private-registry.com/kong:3.0.1 --dest-creds

If an image is provided in the following format, the component is successful:

private-registry.com/repo/kong:3.0.1

To Reproduce
Steps to reproduce the behavior:

Use [REGISTRY/]IMAGE[:TAG]

Expected behavior
Allow [REGISTRY/]IMAGE[:TAG] and [REGISTRY/]REPO/IMAGE[:TAG]

Log Output (ensure to remove any confidential information like tokens, project names, etc.

+ skopeo copy --src-tls-verify=false --src-creds [email protected]:**** docker://image-registry.openshift-image-registry.svc:5000/private-registry.com/kong:3.0.1 --dest-creds openshift:... docker://image-registry.openshift-image-registry.svc:5000/pames-cd/kong:3.0.1 --dest-tls-verify=false
time="2024-10-28T10:14:18Z" level=fatal msg="initializing source docker://image-registry.openshift-image-registry.svc:5000/private-registry.com/kong:3.0.1: unable to retrieve auth token: invalid username/password: authentication required"

Additional context
#1119

@tbugfinder
Copy link
Contributor

According to the parameter description this is not a bug.

sourceImageUrlIncludingRegistryString | Source image to importThis needs to be in the following format: [REGISTRY/]REPO/IMAGE[:TAG]

Nevertheless I'd agree that a source format of type [REGISTRY/]IMAGE[:TAG] might be possible.

@tbugfinder
Copy link
Contributor

Following code section builds the given string, derived from the requirement to use [REGISTRY/]REPO/IMAGE[:TAG].
This means a pattern of stringA/stringB is read as:
stringA => repo
stringB => image:tag
(and registry is set to the internal).

https://github.com/opendevstack/ods-jenkins-shared-library/blob/master/vars/odsComponentStageCopyImage.groovy#L21-L35

A possible solution could be to check if stringA consists of two elements if split by "." (dot).

I've created a demo code however I'm not sure if this is intended.

@dechants
Copy link
Author

@tbugfinder thank you for taking care of this so quickly.
Idea/question: wouldn't it make sense to provide registry, repo, image, tag individually for source and target instead of in a single string?

@tbugfinder
Copy link
Contributor

Well, most often I find myself just copy/paste those image strings from the registries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants