operator icon indicating copy to clipboard operation
operator copied to clipboard

Fix buildah clustertask to support long image names

Open jordigilh opened this issue 1 year ago β€’ 10 comments

Changes

Fixes a problem in the buildah clustertask where when provided with a long image name (e.g. image-registry.openshift-image-registry.svc:5000/test/serverless-workflow-mtaanalysis:1.0), it caused the generated script to wrap the line which is interpreted by the shell as a new command, rather than part of the previous command:

Currently, the script generates this push command:

buildah --storage-driver=vfs push \
 --tls-verify=true \
--digestfile /tmp/image-digest \
image-registry.openshift-image-registry.svc:5000/test/serverless-workflow-mtaanalysis:1.0
 \
docker://image-registry.openshift-image-registry.svc:5000/test/serverless-workflow-mtaanalysis:1.0

Which, when executed, it fails with this error:

Writing manifest to image destination
/tekton/scripts/script-0-4dsn8: line 35: docker://image-registry.openshift-image-registry.svc:5000/test/serverless-workflow-mtaanalysis:1.0: No such file or directory

The proposal fix here is to capture the value of the image in an environment variable and use it in the push command, avoiding the wrapping and ensuring it is not affected by any image length.

IMAGE=$(params.IMAGE)
buildah --storage-driver=$(params.STORAGE_DRIVER) push \
  $(params.PUSH_EXTRA_ARGS) --tls-verify=$(params.TLSVERIFY) \
  --digestfile /tmp/image-digest $IMAGE docker://$IMAGE

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you review them:

  • [X] Run make test lint before submitting a PR

Release Notes

Fix buildah clustertask to support long image names

jordigilh avatar Feb 26 '24 20:02 jordigilh

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: jordigilh / name: Jordi Gil (811cb3a2ed0100a9e5412a43ddde6f72ddfe4914, be71798835816c1894cf545849bea66b401a66f4, b3e5bacd4a5e1abb95e676769e0246062ca2d902)

Hi @jordigilh. Thanks for your PR.

I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

tekton-robot avatar Feb 26 '24 20:02 tekton-robot

/ok-to-test

jkandasa avatar Feb 27 '24 06:02 jkandasa

/lgtm

piyush-garg avatar Feb 27 '24 06:02 piyush-garg

/hold The buildah Task is going to be maintained from openshift-pipelines/task-containers, so the change would need to be there. Though I am not entirely sure it is affected there.

vdemeester avatar Feb 27 '24 07:02 vdemeester

/hold The buildah Task is going to be maintained from openshift-pipelines/task-containers, so the change would need to be there. Though I am not entirely sure it is affected there.

Should I also raise a PR there? https://github.com/openshift-pipelines/task-containers/blob/66681544bedfa02e2d5d37075f1e2150f23809d1/scripts/buildah-bud.sh#L89-L92 The issue with the long name could also be found there.

jordigilh avatar Feb 27 '24 13:02 jordigilh

/hold The buildah Task is going to be maintained from openshift-pipelines/task-containers, so the change would need to be there. Though I am not entirely sure it is affected there.

Should I also raise a PR there? https://github.com/openshift-pipelines/task-containers/blob/66681544bedfa02e2d5d37075f1e2150f23809d1/scripts/buildah-bud.sh#L89-L92 The issue with the long name could also be found there.

ah superb πŸ‘ΌπŸΌ yeah that would be perfect @jordigilh πŸ€—

vdemeester avatar Feb 27 '24 15:02 vdemeester

New changes are detected. LGTM label has been removed.

tekton-robot avatar Feb 27 '24 20:02 tekton-robot

/hold The buildah Task is going to be maintained from openshift-pipelines/task-containers, so the change would need to be there. Though I am not entirely sure it is affected there.

Should I also raise a PR there? https://github.com/openshift-pipelines/task-containers/blob/66681544bedfa02e2d5d37075f1e2150f23809d1/scripts/buildah-bud.sh#L89-L92 The issue with the long name could also be found there.

ah superb πŸ‘ΌπŸΌ yeah that would be perfect @jordigilh πŸ€—

I stand corrected. It's not needed because it's a script itself and the parameters are passed as environment values directly, so the problem I faced here won't happen there. I got carried away when I saw a similar structure to the push command. Sorry for the confusion πŸ™

_buildah push ${PARAMS_PUSH_EXTRA_ARGS} \
    --digestfile="${digest_file}" \
    ${PARAMS_IMAGE} \
    docker://${PARAMS_IMAGE}

jordigilh avatar Feb 27 '24 23:02 jordigilh

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

tekton-robot avatar Feb 29 '24 14:02 tekton-robot

/hold The buildah Task is going to be maintained from openshift-pipelines/task-containers, so the change would need to be there. Though I am not entirely sure it is affected there.

Should I also raise a PR there? https://github.com/openshift-pipelines/task-containers/blob/66681544bedfa02e2d5d37075f1e2150f23809d1/scripts/buildah-bud.sh#L89-L92 The issue with the long name could also be found there.

ah superb πŸ‘ΌπŸΌ yeah that would be perfect @jordigilh πŸ€—

I stand corrected. It's not needed because it's a script itself and the parameters are passed as environment values directly, so the problem I faced here won't happen there. I got carried away when I saw a similar structure to the push command. Sorry for the confusion πŸ™

_buildah push ${PARAMS_PUSH_EXTRA_ARGS} \
    --digestfile="${digest_file}" \
    ${PARAMS_IMAGE} \
    docker://${PARAMS_IMAGE}

as the clustertask are deprecated and will be removed soon, we are not adding any changes, and as you mentioned tasks are not affected and as they are already shipped, we are not going with this change. Thanks for the efforts @jordigilh

piyush-garg avatar Aug 29 '24 02:08 piyush-garg