Skip to content

Commit

Permalink
Group checkers by category
Browse files Browse the repository at this point in the history
The `linkerd check` command organized the various checks via loosely
coupled category IDs, category names, and checkers themselves, all with
ordering defined by consumers of this code.

This change removes category IDs in favor of category names, groups all
checkers by category, and enforces ordering at the `HealthChecker`
level.

Part of #1471, depends on #2078.

Signed-off-by: Andrew Seigner <[email protected]>
  • Loading branch information
siggy committed Jan 14, 2019
1 parent f319bc4 commit 07537c7
Show file tree
Hide file tree
Showing 5 changed files with 518 additions and 548 deletions.
2 changes: 1 addition & 1 deletion cli/cmd/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func configureAndRunChecks(options *checkOptions) error {
if err != nil {
return fmt.Errorf("Validation error when executing check command: %v", err)
}
checks := []healthcheck.Checks{
checks := []healthcheck.Category{
healthcheck.KubernetesAPIChecks,
healthcheck.KubernetesVersionChecks,
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func TestCheckStatus(t *testing.T) {
t.Run("Prints expected output", func(t *testing.T) {
hc := healthcheck.NewHealthChecker(
[]healthcheck.Checks{},
[]healthcheck.Category{},
&healthcheck.Options{},
)
hc.Add("category", "check1", func() error {
Expand Down
8 changes: 4 additions & 4 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func cliPublicAPIClient() pb.ApiClient {
// checks fail, then CLI will print an error and exit. If the retryDeadline
// param is specified, then the CLI will print a message to stderr and retry.
func validatedPublicAPIClient(retryDeadline time.Time, apiChecks bool) pb.ApiClient {
checks := []healthcheck.Checks{
checks := []healthcheck.Category{
healthcheck.KubernetesAPIChecks,
healthcheck.LinkerdControlPlaneExistenceChecks,
}
Expand All @@ -123,11 +123,11 @@ func validatedPublicAPIClient(retryDeadline time.Time, apiChecks bool) pb.ApiCli
if result.Err != nil && !result.Warning {
var msg string
switch result.Category {
case healthcheck.KubernetesAPICategory:
case healthcheck.KubernetesAPIChecks:
msg = "Cannot connect to Kubernetes"
case healthcheck.LinkerdControlPlaneExistenceCategory:
case healthcheck.LinkerdControlPlaneExistenceChecks:
msg = "Cannot find Linkerd"
case healthcheck.LinkerdAPICategory:
case healthcheck.LinkerdAPIChecks:
msg = "Cannot connect to Linkerd"
}
fmt.Fprintf(os.Stderr, "%s: %s\n", msg, result.Err)
Expand Down
Loading

0 comments on commit 07537c7

Please sign in to comment.