-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
51a2c1a
to
7529a97
Compare
This seems better than what we currently have. However, it seems like it's still really brittle to me. We're still relying on |
@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. |
There was a problem hiding this 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.
cli/shell/kubectl.go
Outdated
magicCharacterThatIndicatesProxyIsRunning = '\n' | ||
) | ||
|
||
var minimunKubectlVersionExpected = [3]int{1, 8, 4} |
There was a problem hiding this comment.
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.
cli/shell/kubectl.go
Outdated
|
||
if err != nil { | ||
return version, err | ||
} |
There was a problem hiding this comment.
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.
cli/shell/kubectl.go
Outdated
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) |
There was a problem hiding this comment.
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)
cli/shell/kubectl.go
Outdated
|
||
fmt.Println(kubectlOutput) | ||
if err != nil { | ||
return fmt.Errorf("Error waiting for kubectl to start the proxy. kubetl returned [%s], error: %v", kubectlOutput, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here: kubetl
=> kubectl
cli/shell/kubectl.go
Outdated
} | ||
|
||
if !isCompatibleVersion(minimunKubectlVersionExpected, actualVersion) { | ||
return nil, fmt.Errorf("Kubectl is on version %v, but version %v or more recent is required", actualVersion, minimunKubectlVersionExpected) |
There was a problem hiding this comment.
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"
694227c
to
0f9055a
Compare
@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. |
There was a problem hiding this 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.
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.
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 to1.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: