An operator registers a service with a script health check that runs a custom binary. The binary exits with status code 1. What status will Consul assign to the service's health check?
For script health checks, Consul interprets the exit code: 0 means passing, 1 means warning, and any other non-zero code means critical. However, in Consul 1.15, the behavior is that exit code 1 is actually treated as critical for script checks. This is because the script check does not differentiate between warning and critical; any non-zero exit code results in a critical status. Therefore, the service will be marked critical.
Why this answer
In Consul, script health checks use the exit code of the script to determine health status. An exit code of 0 indicates passing, while any non-zero exit code indicates a failure. Specifically, Consul treats exit code 1 as critical for script checks, not warning.
Therefore, when the custom binary exits with 1, the check status becomes critical, and the service is considered unhealthy.
Exam trap
The trap here is assuming that exit code 1 corresponds to a warning state, as it might in some other systems, but Consul script checks treat any non-zero exit as critical.