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

Validate KUDO installation before running commands #1113

Merged
merged 13 commits into from
Dec 2, 2019

Conversation

ANeumann82
Copy link
Member

@ANeumann82 ANeumann82 commented Nov 28, 2019

What this PR does / why we need it:

  • Validate the CRDS (are they installed, and the same version as KUDO ctrl)
  • Add cmd line flag to skip validation

The PR validates that the KUDO CRDs are installed on the targeted cluster, and that the CRD version is the same as in the KUDO CLI. This is executed anytime a KudoClient is created.

It adds a global flag "--validate-installation" that defaults to "true" that allows a user to skip this validation and run the command anyway.

Fixes #1056

pkg/kudoctl/cmd/init/crds.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/init/crds.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/init/crds.go Show resolved Hide resolved
pkg/kudoctl/cmd/init/crds.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/init/manager.go Outdated Show resolved Hide resolved
pkg/kudoctl/util/kudo/kudo.go Outdated Show resolved Hide resolved
pkg/kudoctl/util/kudo/kudo.go Outdated Show resolved Hide resolved
pkg/kudoctl/util/kudo/kudo.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alenkacz alenkacz left a comment

Choose a reason for hiding this comment

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

I have few nits on this PR but before I dive into that - what do you think about introducing a command instead? I think it's much nicer to have something like k kudo validate-install than --validate-install on every command of course we would have to do a good job documenting it. I like this model from linkerd they have a check command and run various checks on your cluster to help you figure out if linkerd is healthy.

pkg/kudoctl/cmd/init/crds.go Outdated Show resolved Hide resolved
@ANeumann82
Copy link
Member Author

I have few nits on this PR but before I dive into that - what do you think about introducing a command instead? I think it's much nicer to have something like k kudo validate-install than --validate-install on every command of course we would have to do a good job documenting it. I like this model from linkerd they have a check command and run various checks on your cluster to help you figure out if linkerd is healthy.

Well, the origin of this PR is an issue that a user ran kudo get instances without an installation that resulted in a cryptic error. This kind of requires the validation running on every command, although it is indeed overhead.

More important I think is future work, if we have more KUDO versions out in the wild. If operator1 upgrades the KUDO installation on the cluster, and operator2 tries to run a command on that cluster, it would be good for the operator to know that his KUDO control does not match the installed CRDs and manager.

As already mentioned to @nfnt , the "validate-install" is more of an override to skip the validation in case you know what you're doing. From my perspective, the validation should be performed on every run. (It doesn't make sense for some subcommands like package, plan, repo though)

Start KUDO controller for IT
@ANeumann82
Copy link
Member Author

After thinking about it a bit more, i've removed the validation of the KUDO manager again. It's not required that the installed controller is matching versions, as long as the CRDs are compatible.

The validate-installation command might be a good addition in the future, especially when it comes to upgrading KUDO, but that's out of the scope of this PR. I will include the idea in an upcoming KEP targeting KUDO upgrades

Copy link
Contributor

@alenkacz alenkacz left a comment

Choose a reason for hiding this comment

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

LGTM, have few comments though :)

pkg/kudoctl/cmd/init/crds.go Outdated Show resolved Hide resolved
pkg/kudoctl/cmd/init/manager.go Outdated Show resolved Hide resolved
pkg/kudoctl/env/environment.go Outdated Show resolved Hide resolved
pkg/kudoctl/util/kudo/kudo.go Show resolved Hide resolved
pkg/kudoctl/util/kudo/kudo.go Outdated Show resolved Hide resolved
pkg/kudoctl/util/kudo/kudo.go Show resolved Hide resolved
@@ -31,7 +32,7 @@ type Client struct {
}

// NewClient creates new KUDO Client
func NewClient(kubeConfigPath string, requestTimeout int64) (*Client, error) {
func NewClient(kubeConfigPath string, requestTimeout int64, validateInstall bool) (*Client, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't mind adding a test for this method actually verifying the behavior with validate=true 👼

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added a unit test, but I have a hard time coming up with a test in the current structure. I'll start a refactoring PR next, and going to tackle the whole testing thing there.

@ANeumann82 ANeumann82 merged commit 1e9e07d into master Dec 2, 2019
@ANeumann82 ANeumann82 deleted the an/validate-kudo-install branch December 2, 2019 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error whitout user meaning when run kubectl kudo get instances before init
3 participants