Skip to content

Commit

Permalink
Modify all health checks to be specified via enums (#2078)
Browse files Browse the repository at this point in the history
The set of health checks to be executed were dependent on a combination
of check enums and boolean options.

This change modifies the health checks to be governed strictly by a set
of enums.

Next steps:
- tightly couple category IDs to names
- tightly couple checks to their parent categories
- programmatic control over check ordering

Signed-off-by: Andrew Seigner <siggy@buoyant.io>
  • Loading branch information
siggy committed Jan 15, 2019
1 parent 6a3f4a1 commit 0437341
Show file tree
Hide file tree
Showing 5 changed files with 257 additions and 146 deletions.
43 changes: 31 additions & 12 deletions cli/cmd/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,33 +79,52 @@ func configureAndRunChecks(options *checkOptions) error {
if err != nil {
return fmt.Errorf("Validation error when executing check command: %v", err)
}
checks := []healthcheck.Checks{healthcheck.KubernetesAPIChecks}
checks := []healthcheck.Checks{
healthcheck.KubernetesAPIChecks,
healthcheck.KubernetesVersionChecks,
}

if options.preInstallOnly {
if options.singleNamespace {
checks = append(checks, healthcheck.LinkerdPreInstallSingleNamespaceChecks)
} else {
checks = append(checks, healthcheck.LinkerdPreInstallClusterChecks)
}
checks = append(checks, healthcheck.LinkerdPreInstallChecks)
} else if options.dataPlaneOnly {
checks = append(checks, healthcheck.LinkerdControlPlaneExistenceChecks)
checks = append(checks, healthcheck.LinkerdAPIChecks)
if !options.singleNamespace {
checks = append(checks, healthcheck.LinkerdServiceProfileChecks)
}
if options.namespace != "" {
checks = append(checks, healthcheck.LinkerdDataPlaneExistenceChecks)
}
checks = append(checks, healthcheck.LinkerdDataPlaneChecks)
} else {
checks = append(checks, healthcheck.LinkerdControlPlaneExistenceChecks)
checks = append(checks, healthcheck.LinkerdAPIChecks)
if !options.singleNamespace {
checks = append(checks, healthcheck.LinkerdServiceProfileChecks)
}
}

checks = append(checks, healthcheck.LinkerdVersionChecks)
if !(options.preInstallOnly || options.dataPlaneOnly) {
checks = append(checks, healthcheck.LinkerdControlPlaneVersionChecks)
}
if options.dataPlaneOnly {
checks = append(checks, healthcheck.LinkerdDataPlaneVersionChecks)
}

hc := healthcheck.NewHealthChecker(checks, &healthcheck.Options{
ControlPlaneNamespace: controlPlaneNamespace,
DataPlaneNamespace: options.namespace,
KubeConfig: kubeconfigPath,
KubeContext: kubeContext,
APIAddr: apiAddr,
VersionOverride: options.versionOverride,
RetryDeadline: time.Now().Add(options.wait),
ShouldCheckKubeVersion: true,
ShouldCheckControlPlaneVersion: !(options.preInstallOnly || options.dataPlaneOnly),
ShouldCheckDataPlaneVersion: options.dataPlaneOnly,
SingleNamespace: options.singleNamespace,
ControlPlaneNamespace: controlPlaneNamespace,
DataPlaneNamespace: options.namespace,
KubeConfig: kubeconfigPath,
KubeContext: kubeContext,
APIAddr: apiAddr,
VersionOverride: options.versionOverride,
RetryDeadline: time.Now().Add(options.wait),
})

success := runChecks(os.Stdout, hc)
Expand Down
Loading

0 comments on commit 0437341

Please sign in to comment.