Make service profile validation a warning instead of an error (#1807)

The existence of an invalid service profile causes `linkerd check` to fail.  This means that it is not possible to open the Linkerd dashboard with the `linkerd dashboard` command.  While service profile validation is useful, it should not lock users out.

Add the ability to designate health checks as warnings.  A failed warning health check will display a warning output in `linkerd check` but will not affect the overall success of the command.  Switch the service profile validation to be a warning.

Signed-off-by: Alex Leong <alex@buoyant.io>
This commit is contained in:
Alex Leong 2018-10-26 13:28:10 -07:00 committed by GitHub
parent 148d7bc608
commit 6cffad277b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 8 deletions

View File

@ -11,8 +11,9 @@ import (
)
const (
retryStatus = "[retry]"
failStatus = "[FAIL]"
retryStatus = "[retry]"
failStatus = "[FAIL]"
warningStatus = "[warning]"
)
type checkOptions struct {
@ -128,7 +129,11 @@ func runChecks(w io.Writer, hc *healthcheck.HealthChecker) bool {
}
if result.Err != nil {
fmt.Fprintf(w, "%s%s%s -- %s%s", checkLabel, filler, failStatus, result.Err, lineBreak)
status := failStatus
if result.Warning {
status = warningStatus
}
fmt.Fprintf(w, "%s%s%s -- %s%s", checkLabel, filler, status, result.Err, lineBreak)
return
}

View File

@ -106,7 +106,7 @@ func validatedPublicAPIClient(retryDeadline time.Time) pb.ApiClient {
return
}
if result.Err != nil {
if result.Err != nil && !result.Warning {
var msg string
switch result.Category {
case healthcheck.KubernetesAPICategory:

View File

@ -72,6 +72,7 @@ type checker struct {
category string
description string
fatal bool
warning bool
retryDeadline time.Time
check func() error
checkRPC func() (*healthcheckPb.SelfCheckResponse, error)
@ -81,6 +82,7 @@ type CheckResult struct {
Category string
Description string
Retry bool
Warning bool
Err error
}
@ -317,7 +319,8 @@ func (hc *HealthChecker) addLinkerdAPIChecks() {
hc.checkers = append(hc.checkers, &checker{
category: LinkerdAPICategory,
description: "no invalid service profiles",
fatal: true,
fatal: false,
warning: true,
check: func() error {
return hc.validateServiceProfiles()
},
@ -455,14 +458,17 @@ func (hc *HealthChecker) Add(category, description string, check func() error) {
// RunChecks runs all configured checkers, and passes the results of each
// check to the observer. If a check fails and is marked as fatal, then all
// remaining checks are skipped. If at least one check fails, RunChecks returns
// false; if all checks passed, RunChecks returns true.
// false; if all checks passed, RunChecks returns true. Checks which are
// designated as warnings will not cause RunCheck to return false, however.
func (hc *HealthChecker) RunChecks(observer checkObserver) bool {
success := true
for _, checker := range hc.checkers {
if checker.check != nil {
if !hc.runCheck(checker, observer) {
success = false
if !checker.warning {
success = false
}
if checker.fatal {
break
}
@ -471,7 +477,9 @@ func (hc *HealthChecker) RunChecks(observer checkObserver) bool {
if checker.checkRPC != nil {
if !hc.runCheckRPC(checker, observer) {
success = false
if !checker.warning {
success = false
}
if checker.fatal {
break
}
@ -488,6 +496,7 @@ func (hc *HealthChecker) runCheck(c *checker, observer checkObserver) bool {
checkResult := &CheckResult{
Category: c.category,
Description: c.description,
Warning: c.warning,
Err: err,
}
@ -508,6 +517,7 @@ func (hc *HealthChecker) runCheckRPC(c *checker, observer checkObserver) bool {
observer(&CheckResult{
Category: c.category,
Description: c.description,
Warning: c.warning,
Err: err,
})
if err != nil {
@ -522,6 +532,7 @@ func (hc *HealthChecker) runCheckRPC(c *checker, observer checkObserver) bool {
observer(&CheckResult{
Category: fmt.Sprintf("%s[%s]", c.category, check.SubsystemName),
Description: check.CheckDescription,
Warning: c.warning,
Err: err,
})
if err != nil {