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

Check kubectl versions before attempting dashboard #53

Merged
merged 7 commits into from
Dec 19, 2017

Conversation

pcalcado
Copy link
Contributor

@pcalcado pcalcado commented Dec 15, 2017

Different versions of kubectl have different outputs for the $ kubectl proxy command, which sometimes causes $ conduit dashboard to hang. This adds a version check that will make sure that the client is at least at $version, currently set to 1.8.4, before attempting anything.

There's also a refactoring extracting business logic from the UI layer and adding lots of tests for it.

e.g. output:

 $   go build -o ~/tmp/conduit  cli/main.go  && ~/tmp/conduit dashboard
2017/12/15 23:45:02 Failed to start kubectl: Kubectl is on version [1 4 4], but version [1 8 4] or more recent is required

@pcalcado pcalcado force-pushed the phil/dashboard-should-work-older-versions branch from 51a2c1a to 7529a97 Compare December 15, 2017 12:47
@pcalcado pcalcado changed the title WIP DO NOT MERGE Check kubectl versions before attempting anything Check kubectl versions before attempting dashboard Dec 15, 2017
@pcalcado pcalcado self-assigned this Dec 15, 2017
@briansmith
Copy link
Contributor

This seems better than what we currently have. However, it seems like it's still really brittle to me. We're still relying on kubectl being in $PATH and we're going to be sensitive to the whims of the kubectl developers changing the output format of kubectl going forward. It seems much better to me to do the proxying ourselves instead of shelling out to kubectl, especially since we could, AFAICT, just copy/paste the proxying code directly from kubectl, which seems to be about the same size as this PR. However, I won't object to this going in as is if Kevin feels like this is OK. I'll let him make the approval call.

@pcalcado
Copy link
Contributor Author

@briansmith Thanks.

Changing the underlying architecture wasn't the goal of the PR, the refactoring here means to extract logic spread in the UI and make it less brittle by both tests and enhanced error handling. Also, I am not sure I agree that a production-ready and we'll tested implementation would be similar in size to this PR.

Copy link
Contributor

@klingerf klingerf left a comment

Choose a reason for hiding this comment

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

Nice refactor! And the tests are great. I just had a few pieces of misc feedback below. I agree that eventually replacing our use of kubectl with the client-go library would be a good direction in the future.

magicCharacterThatIndicatesProxyIsRunning = '\n'
)

var minimunKubectlVersionExpected = [3]int{1, 8, 4}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to set our minimum at 1.8.0. The magic character that we're dependent on was added here:

kubernetes/kubernetes@0daee3a#diff-595bfea7ed0dd0171e1f339a1f8bfcb6R155

And that commit made it into the 1.8.0 release.


if err != nil {
return version, err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You have two err != nil checks in a row here, and it's impossible for the second one to fire. I'd remove it. And I think you should wait to assign versionString until after the error check happens, i.e move line 39 to line 42.

bytes, err := kctl.sh.CombinedOutput("kubectl", "version", "--client", "--short")
versionString := string(bytes)
if err != nil {
return [3]int{}, fmt.Errorf("Error running kubectl Version. Output: %s Error: %v", versionString, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency with the rest of your error checks here, I think you should return the existing version array, rather than instantiating a new one.

	return version, fmt.Errorf("Error running kubectl Version. Output: %s Error: %v", versionString, err)


fmt.Println(kubectlOutput)
if err != nil {
return fmt.Errorf("Error waiting for kubectl to start the proxy. kubetl returned [%s], error: %v", kubectlOutput, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo here: kubetl => kubectl

}

if !isCompatibleVersion(minimunKubectlVersionExpected, actualVersion) {
return nil, fmt.Errorf("Kubectl is on version %v, but version %v or more recent is required", actualVersion, minimunKubectlVersionExpected)
Copy link
Contributor

Choose a reason for hiding this comment

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

TIOLI -- you could clean this up a bit if you added a helper to convert int[3] to version string. otherwise, as written, you'll end up with:

"Kubectl is on version [1 2 3], but version [2 3 4] or more recent is required"

@pcalcado pcalcado force-pushed the phil/dashboard-should-work-older-versions branch from 694227c to 0f9055a Compare December 19, 2017 00:28
@pcalcado
Copy link
Contributor Author

@klingerf Thanks so much for the thorough read!

I've changed all the points. wrt embedding kubectl, I think that it is a generally good direction but there are other things to consider (e.g. are we going to have our embedded version different from the kubectl that the use has installed in their computer, are we committed to releasing a new build of CLI every time there is a new kubectl, what about the current architecture change going on with kubectl—whould we wait for it to be finished?) but irrespective of when/if we do it the first step should be isolating kubectl and kubeapi code in its own module and objects so that we can change the implementation without having to change client code.

Copy link
Contributor

@klingerf klingerf left a comment

Choose a reason for hiding this comment

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

⭐️ Ok, awesome, thanks for making those updates! And I agree that moving this logic to the shell package makes sense, regardless of which direction we decide to go with interacting with kubectl going forward.

@pcalcado pcalcado merged commit 6f9e8be into master Dec 19, 2017
@pcalcado pcalcado deleted the phil/dashboard-should-work-older-versions branch February 5, 2018 22:21
khappucino pushed a commit to Nordstrom/linkerd2 that referenced this pull request Mar 5, 2019
Following on linkerd#52, this change moves the
`telemetry::metrics::tls_config_reload` module to
`telemetry::tls_config_reload`.

The `Fmt` type has been renamed to `Report`.

Furthermore, two helper methods have been added to `metrics::Scopes` so
that its internal representation need not be made public.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants