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

Fix buildah clustertask to support long image names #2033

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jordigilh
Copy link

@jordigilh jordigilh commented Feb 26, 2024

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:

  • Run make test lint before submitting a PR

Release Notes

Fix buildah clustertask to support long image names

Signed-off-by: Jordi Gil <jgil@redhat.com>
@tekton-robot tekton-robot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Feb 26, 2024
Copy link

linux-foundation-easycla bot commented Feb 26, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@tekton-robot tekton-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 26, 2024
@tekton-robot
Copy link
Contributor

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 tekton-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Feb 26, 2024
@jkandasa
Copy link
Member

/ok-to-test

@tekton-robot tekton-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Feb 27, 2024
@piyush-garg
Copy link
Contributor

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 27, 2024
buildah --storage-driver=$(params.STORAGE_DRIVER) push \
$(params.PUSH_EXTRA_ARGS) --tls-verify=$(params.TLSVERIFY) \
--digestfile /tmp/image-digest $(params.IMAGE) \
docker://$(params.IMAGE)
--digestfile /tmp/image-digest $IMAGE docker://$IMAGE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jordigilh thanks for the PR, I see we use $(params.IMAGE) on line number 90. can you please update that entry too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@vdemeester
Copy link
Member

/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.

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 27, 2024
@jordigilh
Copy link
Author

/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.

@vdemeester
Copy link
Member

/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 🤗

Signed-off-by: Jordi Gil <jgil@redhat.com>
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Feb 27, 2024
@tekton-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@jordigilh
Copy link
Author

/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}

Signed-off-by: Jordi Gil <jgil@redhat.com>
@tekton-robot tekton-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 28, 2024
@tekton-robot
Copy link
Contributor

[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 tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants