opendevstack / ods-jenkins-shared-library

Shared Jenkins library which all ODS projects & components use - provisioning, SonarQube code scanning, Nexus publishing, OpenShift template based deployments and repository orchestration
Apache License 2.0
69 stars 57 forks source link

odsComponentStageCopyImage fails when copying images from Nexus Artifact Repository #1119

Open dechants opened 1 month ago

dechants commented 1 month ago

Describe the bug I am unable to use this component with the following source image registry: docker-group-ods.<OCP_DOMAIN>

To Reproduce

odsComponentStageCopyImage(
 context,
 [branch: 'dev',
 sourceCredential: '',
 sourceImageUrlIncludingRegistry: "docker-group-ods.<OCP_DOMAIN>/kong:3.0.1-alpine",
 tagIntoTargetEnv: false,
 verifyTLS: false]
 )

Results in:

skopeo copy --src-tls-verify=false docker://image-registry.openshift-image-registry.svc:5000/docker-group-ods.<OCP_DOMAIN>/kong:3.0.1-alpine --dest-creds openshift:eyJhbGc... docker://image-registry.openshift-image-registry.svc:5000/pames-cd/kong:3.0.1-alpine --dest-tls-verify=false

Why is image-registry.openshift-image-registry.svc:5000/ prepended to docker-group-ods.<OCP_DOMAIN>/kong:3.0.1-alpine?

Expected behavior Here is a working example:

odsComponentStageCopyImage(
 context,
 [branch: 'dev',
 sourceCredential: '',
 sourceImageUrlIncludingRegistry: "ghcr.io/ing-bank/scruid/druid:0.18.0",
 tagIntoTargetEnv: false,
 verifyTLS: false]
 )

Results in:

skopeo copy --src-tls-verify=false docker://ghcr.io/ing-bank/scruid/druid:0.18.0 --dest-creds openshift:eyJhbGc... docker://image-registry.openshift-image-registry.svc:5000/pames-cd/druid:0.18.0 --dest-tls-verify=false

jeronimolina commented 2 weeks ago

I've been reviewing this incident as you opened a ticket on our support queue. The problem is that the image you are looking for on the nexus docker registry it's not being found. I try to replicate it in my project which is in europe using the europe nexus cluster and at the end of the log I received the same as you + at the end of the pipeline the following: ERROR: Could not copy `docker-group-ods.apps.eu-dev.ocp.aws.boehringer.com/kong:3.0.1-alpine', status 1

When this happens, seems that the shared library doesn't found the image and try to find it locally on openshift by default. This is the reason why is adding the "image-registry.openshift-image-registry.svc:5000/" in front of.

To solve it I checked how the nexus docker path for the image was exactly on nexus europe and I found that it was "library/kong:3.0.1" instead of only "kong:3.0.1". When I applied the correct path adding "library/kong:3.0.1-alpine" all worked fine and the log was correct again as seen here: skopeo copy --src-tls-verify=false docker://docker-group-ods.apps.eu-dev.ocp.aws.boehringer.com/library/kong:3.0.1-alpine --dest-creds openshift:eyJhbGc... And the pipeline succeeded. If your pipeline is in europe also try to do what I explained before, if not check that the path is correct on the nexus of the cluster where your project is as the problem point to this.

Hope this helps and adds a bit of context!

Kind regards.