X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/3fa6aa4043286ad61e5f29c136d3cc2942e8750d..HEAD:/sdk/go/health/aggregator.go diff --git a/sdk/go/health/aggregator.go b/sdk/go/health/aggregator.go index b5301dffe0..3bf37b1294 100644 --- a/sdk/go/health/aggregator.go +++ b/sdk/go/health/aggregator.go @@ -135,6 +135,7 @@ type CheckResult struct { Response map[string]interface{} `json:",omitempty"` ResponseTime json.Number ClockTime time.Time + Server string // "Server" header in http response Metrics respTime time.Duration } @@ -223,7 +224,8 @@ func (agg *Aggregator) ClusterHealth() ClusterHealthResponse { for svcName, sh := range resp.Services { switch svcName { case arvados.ServiceNameDispatchCloud, - arvados.ServiceNameDispatchLSF: + arvados.ServiceNameDispatchLSF, + arvados.ServiceNameDispatchSLURM: // ok to not run any given dispatcher case arvados.ServiceNameHealth, arvados.ServiceNameWorkbench1, @@ -359,6 +361,7 @@ func (agg *Aggregator) ping(target *url.URL) (result CheckResult) { } result.Health = "OK" result.ClockTime, _ = time.Parse(time.RFC1123, resp.Header.Get("Date")) + result.Server = resp.Header.Get("Server") return } @@ -437,7 +440,7 @@ func (ccmd checkCommand) RunCommand(prog string, args []string, stdin io.Reader, err := ccmd.run(ctx, prog, args, stdin, stdout, stderr) if err != nil { if err != errSilent { - fmt.Fprintln(stdout, err.Error()) + fmt.Fprintln(stderr, err.Error()) } return 1 } @@ -451,7 +454,8 @@ func (ccmd checkCommand) run(ctx context.Context, prog string, args []string, st loader.SetupFlags(flags) versionFlag := flags.Bool("version", false, "Write version information to stdout and exit 0") timeout := flags.Duration("timeout", defaultTimeout.Duration(), "Maximum time to wait for health responses") - outputYAML := flags.Bool("yaml", false, "Output full health report in YAML format (default mode shows errors as plain text, is silent on success)") + quiet := flags.Bool("quiet", false, "Silent on success (suppress 'health check OK' message on stderr)") + outputYAML := flags.Bool("yaml", false, "Output full health report in YAML format (default mode prints 'health check OK' or plain text errors)") if ok, _ := cmd.ParseFlags(flags, prog, args, "", stderr); !ok { // cmd.ParseFlags already reported the error return errSilent @@ -486,11 +490,14 @@ func (ccmd checkCommand) run(ctx context.Context, prog string, args []string, st } if resp.Health != "OK" { for _, msg := range resp.Errors { - fmt.Fprintln(stdout, msg) + fmt.Fprintln(stderr, msg) } fmt.Fprintln(stderr, "health check failed") return errSilent } + if !*quiet { + fmt.Fprintln(stderr, "health check OK") + } return nil }