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: Download bundle without specifying tag #4474

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

A-725-K
Copy link
Contributor

@A-725-K A-725-K commented Nov 21, 2024

The "latest" tag is not supported, therefore it is necessary to stop with an error in case it is not provided when using the -b flag command line flag.

Add unit tests to reproduce the bug and verify the fix.

Closes issue #4470

Fixes: Issue #4470

Solution/Idea

Before, in the GetBundleNameFromURI function, the imageAndTag array was trying to access its second element without ensuring that the length is at least 2 causing a crash in case the -b command line option was used to specify a bundle from a container image repository (using the docker:// scheme) without a tag. I have added a check to prevent the program from crashing, returning an error to the user since the "latest" tag is not an option.

Proposed changes

In GetBundleNameFromURI function:

  1. Check the lenght of imageAndTag array
  2. if it is greater or equal to 2, then obtain image name and tag as imageAndTag[0] and imageAndTag[1] respectively
  3. otherwise, bail out with an error
  4. Change all the use in the codebase, since now the function returns also an error in case of failure

Testing

Added unit tests to reproduce the bug and validate the fix proposed.
Check the TestGetBundleNameFromURI function in the pkg/crc/machine/bundle/metadata_test.go file.
Running crc setup -b docker://quay.io/crcont/openshift-bundle should now return an error message instead of crashing.

Copy link

openshift-ci bot commented Nov 21, 2024

Hi @A-725-K. Thanks for your PR.

I'm waiting for a crc-org 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-sigs/prow repository.

Copy link
Contributor

@cfergeau cfergeau left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks for contributing this fix!

pkg/crc/machine/bundle/metadata.go Outdated Show resolved Hide resolved
@openshift-ci openshift-ci bot added the lgtm label Nov 22, 2024
Copy link

openshift-ci bot commented Nov 22, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfergeau

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

@anjannath
Copy link
Member

@A-725-K we just merged another PR (#4405) and that created conflicts here, could you please rebase and push again, thanks!

Copy link

openshift-ci bot commented Nov 25, 2024

New changes are detected. LGTM label has been removed.

@A-725-K
Copy link
Contributor Author

A-725-K commented Nov 25, 2024

@A-725-K we just merged another PR (#4405) and that created conflicts here, could you please rebase and push again, thanks!

@anjannath rebased and pushed! Thanks for notifying me!

@praveenkumar
Copy link
Member

@A-725-K There is still conflict around pkg/crc/machine/bundle/metadata_test.go can you rebase and repush. Thanks for contributing.

/rebase

The "latest" tag is not supported, therefore it is necessary to stop
with an error in case it is not provided when using the -b flag command
line flag.

Add unit tests to reproduce the bug and verify the fix.

Closes issue crc-org#4470
@A-725-K
Copy link
Contributor Author

A-725-K commented Nov 25, 2024

@praveenkumar thank you for reviewing it! Rebased and pushed again!

Copy link

openshift-ci bot commented Nov 26, 2024

@A-725-K: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-crc d17a4c4 link true /test e2e-crc

Full PR test history. Your PR dashboard.

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-sigs/prow repository. I understand the commands that are listed here.

@praveenkumar praveenkumar merged commit face0f4 into crc-org:main Nov 26, 2024
27 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants