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

🐛 regression - extracommands require a valid PROJECT file again #2126

Merged

Conversation

jmrodri
Copy link
Contributor

@jmrodri jmrodri commented Apr 6, 2021

Ignore UnsupportedVersion error to allow extra commands to be able to actually run.

Fixes: #2125

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 6, 2021
@k8s-ci-robot
Copy link
Contributor

Welcome @jmrodri!

It looks like this is your first PR to kubernetes-sigs/kubebuilder 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kubebuilder has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @jmrodri. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 6, 2021
@jmrodri
Copy link
Contributor Author

jmrodri commented Apr 6, 2021

@estroz I'm having trouble creating a test for this. I need a way to pass in an invalid PROJECT file. I started adding a testdata/v3alpha-PROJECT but then couldn't immediately find the place to pass that in.

Copy link
Contributor

@Adirio Adirio left a comment

Choose a reason for hiding this comment

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

I don't think that omitting the error is the best approach, as this will not set the CLI's project-version, thus trying to obtain it from --project-version (which would probably be not provided) and then trying to resolve it automatically from the list of plugins, which may not be possible, and thus still resulting in an error. I think that we should probably set CLI's project-version to 3 if 3-alpha is encountered inside the switch statement I mention below.

pkg/cli/cli.go Outdated Show resolved Hide resolved
@camilamacedo86
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 6, 2021
@Adirio
Copy link
Contributor

Adirio commented Apr 6, 2021

Just a small note that was commented during the triage meeting. As this variable is used for plugin resolution, I nice approach could be once a version is not found and seeing that the version is unstable (alpha/beta), if the corresponding stable version exists, set that so that plugin resolution can still work properly.

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 7, 2021
@jmrodri
Copy link
Contributor Author

jmrodri commented Apr 7, 2021

The result of using this PR with the SDK is:

$ operator-sdk version
WARN[0000] Config version 3-alpha has been stabilized as 3, and 3-alpha is no longer supported. Run `operator-sdk alpha config-3alpha-to-3` to upgrade your PROJECT config file to version 3 
operator-sdk version: "scorecard-kuttl/v2.0.0-44-g2b2f989d", commit: "2b2f989d2a47b343d71e77c0963537e271a87979", kubernetes version: "v1.19.4", go version: "go1.15.8", GOOS: "linux", GOARCH: "amd64"

$ operator-sdk alpha config-3alpha-to-3 
WARN[0000] Config version 3-alpha has been stabilized as 3, and 3-alpha is no longer supported. Run `operator-sdk alpha config-3alpha-to-3` to upgrade your PROJECT config file to version 3 
Your PROJECT config file has been converted from version 3-alpha to 3. Please make sure all config data is correct.

$ operator-sdk version
operator-sdk version: "scorecard-kuttl/v2.0.0-44-g2b2f989d", commit: "2b2f989d2a47b343d71e77c0963537e271a87979", kubernetes version: "v1.19.4", go version: "go1.15.8", GOOS: "linux", GOARCH: "amd64"

pkg/cli/cli.go Outdated Show resolved Hide resolved
pkg/cli/cli.go Show resolved Hide resolved
@estroz estroz added the kind/regression Categorizes issue or PR as related to a regression from a prior release. label Apr 7, 2021
@jmrodri jmrodri force-pushed the fix-regression-extracommands branch from 3a6040d to 2a1ff46 Compare April 8, 2021 02:05
@k8s-ci-robot k8s-ci-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 Apr 8, 2021
@jmrodri jmrodri force-pushed the fix-regression-extracommands branch from 2a1ff46 to d2a5b6d Compare April 8, 2021 02:12
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 8, 2021
@camilamacedo86
Copy link
Member

/test pull-kubebuilder-e2e-k8s-1-16-15

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

👍

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 8, 2021
pkg/cli/cli.go Outdated Show resolved Hide resolved
@jmrodri jmrodri force-pushed the fix-regression-extracommands branch from d2a5b6d to 5c61117 Compare April 8, 2021 21:14
@k8s-ci-robot k8s-ci-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 Apr 8, 2021
@jmrodri jmrodri force-pushed the fix-regression-extracommands branch from 5c61117 to 6beb9d5 Compare April 8, 2021 21:17
@jmrodri
Copy link
Contributor Author

jmrodri commented Apr 8, 2021

# verify PROJECT file has 3-alpha
[jesusr@transam demo-zeus-operator{master}]$ grep 3-alpha PROJECT 
version: 3-alpha

# verify version still works when it can't parse the 3-alpha config
[jesusr@transam demo-zeus-operator{master}]$ operator-sdk version
WARN[0000] Config version 3-alpha has been stabilized as 3, and 3-alpha is no longer supported. Run `operator-sdk alpha config-3alpha-to-3` to upgrade your PROJECT config file to version 3 
operator-sdk version: "scorecard-kuttl/v2.0.0-44-g2b2f989d", commit: "2b2f989d2a47b343d71e77c0963537e271a87979", kubernetes version: "v1.19.4", go version: "go1.15.8", GOOS: "linux", GOARCH: "amd64"

# verify conversion works
[jesusr@transam demo-zeus-operator{master}]$ operator-sdk alpha config-3alpha-to-3
WARN[0000] Config version 3-alpha has been stabilized as 3, and 3-alpha is no longer supported. Run `operator-sdk alpha config-3alpha-to-3` to upgrade your PROJECT config file to version 3 
Your PROJECT config file has been converted from version 3-alpha to 3. Please make sure all config data is correct.

[jesusr@transam demo-zeus-operator{master}]$ grep version: PROJECT 
  version: v1
version: "3"

@jmrodri
Copy link
Contributor Author

jmrodri commented Apr 8, 2021

Using a completely invalid config results in an error still:

grep[jesusr@transam demo-zeus-operator{master}]$ grep version PROJECT       
  version: v1
version: 4-alpha
 
[jesusr@transam demo-zeus-operator{master}]$ operator-sdk alpha config-3alpha-to-3
Error: unable to load the configuration: unable to create config for version "4-alpha": version 4-alpha is not supported
Usage:
  operator-sdk [flags]
...
FATA[0000] unable to load the configuration: unable to create config for version "4-alpha": version 4-alpha is not supported

UPDATE: we agreed that 3-alpha is a special case here and that something like a 4 or 4-alpha are not valid right now and we do want it to fail.

@jmrodri jmrodri force-pushed the fix-regression-extracommands branch 2 times, most recently from 9588ee0 to c10fa17 Compare April 8, 2021 21:28
@jmrodri
Copy link
Contributor Author

jmrodri commented Apr 8, 2021

@Adirio @estroz I think I got all of the comments.

pkg/cli/cli.go Outdated Show resolved Hide resolved
@jmrodri jmrodri force-pushed the fix-regression-extracommands branch from 93eaf29 to 898c685 Compare April 11, 2021 01:14
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 11, 2021
@jmrodri jmrodri force-pushed the fix-regression-extracommands branch from 898c685 to 02dceb7 Compare April 11, 2021 02:25
* Handle failing on 3-alpha configs
* Set project version to stable version if the it is registered
* Added IsRegistered command to registry
* Add unit test for buildCmd
* Add unit test for IsRegistered
* Fix typo in test name: resgitry_test -> registry_test

Signed-off-by: jesus m. rodriguez <jesusr@redhat.com>
@jmrodri jmrodri force-pushed the fix-regression-extracommands branch from 02dceb7 to 2442aa7 Compare April 11, 2021 04:21
pkg/cli/cli.go Show resolved Hide resolved
Copy link
Contributor

@Adirio Adirio left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 11, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Adirio, camilamacedo86, jmrodri

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:
  • OWNERS [Adirio,camilamacedo86]

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

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/regression Categorizes issue or PR as related to a regression from a prior release. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression: extra commands require a valid PROJECT file again
5 participants