Skip to content

Commit a1aa820

Browse files
committed
chore: better errors
Signed-off-by: Armando Ruocco <[email protected]>
1 parent 2bfbd4c commit a1aa820

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

internal/cmd/healthcheck/main.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,21 @@ func unixHealthCheck() *cobra.Command {
4848
return healthErr
4949
}
5050

51-
log.Info("received status: %s", res.Status.String())
52-
switch res.Status {
53-
case grpc_health_v1.HealthCheckResponse_SERVING:
51+
if res.Status == grpc_health_v1.HealthCheckResponse_SERVING {
52+
log.Trace("healthcheck response OK")
5453
os.Exit(0)
54+
return nil
55+
}
56+
57+
err := fmt.Errorf("unexpected healthcheck response: %v", res.Status)
58+
log.Error(err, "while processing healthcheck response")
59+
60+
// exit code 1 is returned when we exit from the function with an error
61+
switch res.Status {
5562
case grpc_health_v1.HealthCheckResponse_UNKNOWN:
56-
os.Exit(1)
57-
case grpc_health_v1.HealthCheckResponse_NOT_SERVING:
5863
os.Exit(2)
64+
case grpc_health_v1.HealthCheckResponse_NOT_SERVING:
65+
os.Exit(3)
5966
default:
6067
os.Exit(125)
6168
}

0 commit comments

Comments
 (0)