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

Update check and inject output #2087

Merged
merged 4 commits into from
Jan 16, 2019
Merged

Update check and inject output #2087

merged 4 commits into from
Jan 16, 2019

Conversation

siggy
Copy link
Member

@siggy siggy commented Jan 15, 2019

The outputs of the check and inject commands did not vary much
between successful and failed executions, and were a bit verbose and
challenging to parse.

Reorganize output of check and inject commands, to provide more
output when errors occur, and less output when successful.

Specific changes:

linkerd check

  • visually group checks by category
  • introduce hintURL's, to provide doc links when checks fail
  • add spinners when retrying, remove addtional retry lines
  • colored emojis to indicate success/warning/failure

linkerd inject

  • modify default output to mirror kubectl apply
  • only output non-successful inject reports
  • support --verbose flag to output all inject reports

Fixes #1471, #1653, #1656, #1739

Signed-off-by: Andrew Seigner siggy@buoyant.io

Example outputs

Note the unicode symbols are rendered with color in the terminal:

screen shot 2019-01-15 at 3 35 08 pm

✔
✘
⚠

linkerd check with retries

check-spinner4

linkerd check --pre

$ bin/linkerd check --pre --expected-version=$(bin/root-tag)
kubernetes-api
--------------
✔ can initialize the client
✔ can query the Kubernetes API

kubernetes-version
------------------
✔ is running the minimum Kubernetes API version

pre-kubernetes-cluster-setup
----------------------------
✘ control plane namespace does not already exist
    The "linkerd" namespace already exists
✔ can create Namespaces
✔ can create ClusterRoles
✔ can create ClusterRoleBindings
✔ can create CustomResourceDefinitions

pre-kubernetes-setup
--------------------
✔ can create ServiceAccounts
✔ can create Services
✔ can create Deployments
✔ can create ConfigMaps

linkerd-version
---------------
✔ can determine the latest version
✔ cli is up-to-date

Status check results are ✘

linkerd check

$ bin/linkerd check --expected-version=$(bin/root-tag)
kubernetes-api
--------------
✔ can initialize the client
✔ can query the Kubernetes API

kubernetes-version
------------------
✔ is running the minimum Kubernetes API version

linkerd-existence
-----------------
✔ control plane namespace exists
✔ controller pod is running
✔ can initialize the client
✔ can query the control plane API

linkerd-api
-----------
✔ control plane pods are ready
✔ can query the control plane API
✔ [kubernetes] control plane can talk to Kubernetes
✔ [prometheus] control plane can talk to Prometheus

linkerd-service-profile
-----------------------
✔ no invalid service profiles

linkerd-version
---------------
✔ can determine the latest version
✔ cli is up-to-date

control-plane-version
---------------------
⚠ control plane is up-to-date
    is running version 19.1.1 but the latest dev version is 75971c4b-siggy

Status check results are ✔

linkerd check --pre with errors

$ bin/linkerd check --pre --expected-version=$(bin/root-tag)
kubernetes-api
--------------
✔ can initialize the client
✔ can query the Kubernetes API

kubernetes-version
------------------
✔ is running the minimum Kubernetes API version

pre-kubernetes-cluster-setup
----------------------------
✘ control plane namespace does not already exist
    The "linkerd" namespace already exists
✔ can create Namespaces
✘ can create ClusterRoles
    Missing permissions to create ClusterRoles
    See https://linkerd.io/2/getting-started/#step-0-setup for hints
✔ can create ClusterRoleBindings
✔ can create CustomResourceDefinitions

pre-kubernetes-setup
--------------------
✔ can create ServiceAccounts
✔ can create Services
✔ can create Deployments
✔ can create ConfigMaps

linkerd-version
---------------
✔ can determine the latest version
✔ cli is up-to-date

Status check results are ✘

linkerd check --proxy

$ bin/linkerd check --expected-version=$(bin/root-tag) --proxy
kubernetes-api
--------------
✔ can initialize the client
✔ can query the Kubernetes API

kubernetes-version
------------------
✔ is running the minimum Kubernetes API version

linkerd-existence
-----------------
✔ control plane namespace exists
✔ controller pod is running
✔ can initialize the client
✔ can query the control plane API

linkerd-api
-----------
✔ control plane pods are ready
✔ can query the control plane API
✔ [kubernetes] control plane can talk to Kubernetes
✔ [prometheus] control plane can talk to Prometheus

linkerd-service-profile
-----------------------
✔ no invalid service profiles

linkerd-version
---------------
✔ can determine the latest version
✔ cli is up-to-date

linkerd-data-plane
------------------
✔ data plane namespace exists
✔ data plane proxies are ready
✔ data plane proxy metrics are present in Prometheus
⚠ data plane is up-to-date
    linkerd/linkerd-prometheus-568f746f6b-pvs6w is running version edge-19.1.1 but the latest version is dev-75971c4b-siggy

Status check results are ✔

linkerd inject

$ curl -s https://run.linkerd.io/emojivoto.yml | bin/linkerd inject - | kubectl apply -f -

namespace "emojivoto" skipped
deployment "emoji" injected
service "emoji-svc" skipped
deployment "voting" injected
service "voting-svc" skipped
deployment "web" injected
service "web-svc" skipped
deployment "vote-bot" injected

namespace "emojivoto" created
deployment.apps "emoji" created
service "emoji-svc" created
deployment.apps "voting" created
service "voting-svc" created
deployment.apps "web" created
service "web-svc" created
deployment.apps "vote-bot" created

linkerd inject --verbose

$ curl -s https://run.linkerd.io/emojivoto.yml | bin/linkerd inject --verbose - | kubectl apply -f -

✔ pods do not use host networking
✔ pods do not have a proxy or initContainer already injected
✔ at least one resource injected
✔ pod specs do not include UDP ports

namespace "emojivoto" skipped
deployment "emoji" injected
service "emoji-svc" skipped
deployment "voting" injected
service "voting-svc" skipped
deployment "web" injected
service "web-svc" skipped
deployment "vote-bot" injected

namespace "emojivoto" created
deployment.apps "emoji" created
service "emoji-svc" created
deployment.apps "voting" created
service "voting-svc" created
deployment.apps "web" created
service "web-svc" created
deployment.apps "vote-bot" created

@siggy siggy added the area/cli label Jan 15, 2019
@siggy siggy self-assigned this Jan 15, 2019
@siggy siggy added this to In progress in Post 2.1 Polish via automation Jan 15, 2019
@siggy siggy moved this from In progress to Needs review in Post 2.1 Polish Jan 15, 2019
Copy link
Member

@alpeb alpeb left a comment

Choose a reason for hiding this comment

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

This looks pretty neat!
It seems only the uninject output remains to get inline with the changes made to inject.
I commented below one minor nit I found.

@wmorgan
Copy link
Member

wmorgan commented Jan 15, 2019

I know the Helm folks ran into issue with emoji output in their CLIs -- maybe @michelleN has an opinion?

cli/cmd/check.go Outdated
if result.Retry {
fmt.Fprintf(w, "%s%s%s -- %s%s", checkLabel, filler, retryStatus, result.Err, lineBreak)
spin.Suffix = fmt.Sprintf(" %s -- %s", result.Description, result.Err)
spin.Color("bgBlack", "bold", "fgRed")
Copy link
Member

Choose a reason for hiding this comment

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

I have a light theme in my console (I know, weird, but I have my reasons :) ) so the spinner doesn't look right. Although I looked a bit into the spinner lib and couldn't find a way to cater for both dark and light themes at the same time :-(

Copy link
Member Author

Choose a reason for hiding this comment

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

@alpeb can you try replacing that spin.Color(... line with spin.Start(...? maybe the default colors will play better in light and dark themes?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that did the trick. I looks fine in both dark and light.

Copy link
Member Author

Choose a reason for hiding this comment

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

@alpeb I'm trying another revision with spin.Color("bold"), let me know how that looks.

@grampelberg
Copy link
Contributor

Really great improvement! The warnings are great.

  • Could we try spinner 21? I really like that one =)
  • How does it work with normal chars (X for example) and just coloring them? The emojis aren't rendering very well in my font/terminal combo I'm afraid.
  • The error output could use a little love, I assume that'll be tweaked in a follow up? (Thinking about URLs and such).

@siggy
Copy link
Member Author

siggy commented Jan 15, 2019

@grampelberg

  • will try spinner 21
  • going to switch to coloring unicode chars (good idea!)
  • re: hint URLs, you are correct we'll fill more in later, this PR adds the functionality but only populates a few of the error messages.

siggy added a commit that referenced this pull request Jan 16, 2019
Depends on #2037, #2038, #2063, #2066, #2086, #2087, #2089

Signed-off-by: Andrew Seigner <siggy@buoyant.io>
siggy added a commit that referenced this pull request Jan 16, 2019
Depends on #2037, #2038, #2063, #2066, #2086, #2087, #2089

Signed-off-by: Andrew Seigner <siggy@buoyant.io>
Copy link
Member

@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.

⭐️ Wow @siggy! This is so great. I especially like the added support for the --verbose flag for linkerd inject.

cli/cmd/check.go Outdated
underline := ""
for i := 0; i < len(result.Category); i++ {
underline = underline + "-"
}
Copy link
Member

Choose a reason for hiding this comment

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

You can use strings.Repeat here:

diff --git a/cli/cmd/check.go b/cli/cmd/check.go
index 8da69362..4d2c8fc9 100644
--- a/cli/cmd/check.go
+++ b/cli/cmd/check.go
@@ -145,13 +145,8 @@ func runChecks(w io.Writer, hc *healthcheck.HealthChecker) bool {
 				fmt.Fprintln(w)
 			}
 
-			underline := ""
-			for i := 0; i < len(result.Category); i++ {
-				underline = underline + "-"
-			}
-
 			fmt.Fprintln(w, result.Category)
-			fmt.Fprintln(w, underline)
+			fmt.Fprintln(w, strings.Repeat("-", len(result.Category)))
 
 			lastCategory = result.Category
 		}


func getFiller(text string) string {
filler := ""
for i := 0; i < lineWidth-len(text)-len(okStatus)-len("\n"); i++ {
Copy link
Member

Choose a reason for hiding this comment

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

👏 glad this is going away

Post 2.1 Polish automation moved this from Needs review to Reviewer approved Jan 16, 2019
The outputs of the `check` and `inject` commands did not vary much
between successful and failed executions, and were a bit verbose and
challenging to parse.

Reorganize output of `check` and `inject` commands, to provide more
output when errors occur, and less output when successful.

Specific changes:

`linkerd check`
- visually group checks by category
- introduce `hintURL`'s, to provide doc links when checks fail
- add spinners when retrying, remove addtional retry lines
- colored emojis to indicate success/warning/failure

`linkerd inject`
- modify default output to mirror `kubectl apply`
- only output non-successful inject reports
- support `--verbose` flag to output all inject reports

Fixes #1471, #1653, #1656, #1739

Signed-off-by: Andrew Seigner <siggy@buoyant.io>
Signed-off-by: Andrew Seigner <siggy@buoyant.io>
Signed-off-by: Andrew Seigner <siggy@buoyant.io>
Signed-off-by: Andrew Seigner <siggy@buoyant.io>
@siggy siggy merged commit 92f2cd9 into master Jan 16, 2019
Post 2.1 Polish automation moved this from Reviewer approved to Done Jan 16, 2019
@siggy siggy deleted the siggy/i-dont-want-no-bools branch January 16, 2019 23:14
siggy added a commit that referenced this pull request Jan 17, 2019
Depends on #2037, #2038, #2063, #2066, #2087, #2089, #2105

Signed-off-by: Andrew Seigner <siggy@buoyant.io>
siggy added a commit that referenced this pull request Jan 20, 2019
The default font in Windows console did not support the Unicode
characters recently added to check and inject commands. Also the color
library the linkerd cli depends on was not being used in a
cross-platform way.

Replace the existing Unicode characters used in `check` and `inject`
with characters available in most fonts, including Windows console.
Similarly replace the spinner used in `check` with one that uses
characters available in most fonts.

Modify `check` and `inject` to use `color.Output` and `color.Error`,
which wrap `os.Stdout` and `os.Stderr`, and perform special
tranformations when on Windows.

Add a `--no-color` option to `linkerd logs`. While stern uses the same
color library that `check`/`inject` use, it is not yet using the
`color.Output` API for Windows support. That issue is tracked at:
https://github.com/wercker/stern/issues/69

Relates to #2087

Signed-off-by: Andrew Seigner <siggy@buoyant.io>
siggy added a commit that referenced this pull request Jan 23, 2019
The default font in Windows console did not support the Unicode
characters recently added to check and inject commands. Also the color
library the linkerd cli depends on was not being used in a
cross-platform way.

Replace the existing Unicode characters used in `check` and `inject`
with characters available in most fonts, including Windows console.
Similarly replace the spinner used in `check` with one that uses
characters available in most fonts.

Modify `check` and `inject` to use `color.Output` and `color.Error`,
which wrap `os.Stdout` and `os.Stderr`, and perform special
tranformations when on Windows.

Add a `--no-color` option to `linkerd logs`. While stern uses the same
color library that `check`/`inject` use, it is not yet using the
`color.Output` API for Windows support. That issue is tracked at:
https://github.com/wercker/stern/issues/69

Relates to #2087

Signed-off-by: Andrew Seigner <siggy@buoyant.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants