in agent/healthcheck/health_check.go [193:223]
func (healthStatus *HealthStatus) computeHealthCheck(agentConfig config.AgentConfig) {
// If Envoy is not in LIVE state (not initialized or not ready), it is reported as Unhealthy.
// If Envoy is initialized but if there are failures in the initial config creation (leading to partial resources creation),
// it is reported as Unhealthy.
// Disconnection from Control plane (Applicable only when not using Relay Mode):
// - Even when initialized, Envoy is statically stable and hence continue to report healthy.
// - To prevent Envoy from getting stuck in a disconnected state, we define a configurable threshold crossing which
// it starts reporting unhealthy.
switch healthStatus.EnvoyState {
case LIVE:
if healthStatus.InitialConfigUpdateStatus == UPDATE_FAILED {
healthStatus.HealthStatus = Unhealthy
break
}
if agentConfig.EnableRelayModeForXds {
healthStatus.HealthStatus = Healthy
break
}
if healthStatus.ManagementServerConnectionStatus == connected {
healthStatus.HealthStatus = Healthy
} else {
if time.Since(*healthStatus.ManagementServerDisconnectedTimestamp) < agentConfig.HcDisconnectedTimeout {
healthStatus.HealthStatus = Healthy
} else {
healthStatus.HealthStatus = Unhealthy
}
}
default:
healthStatus.HealthStatus = Unhealthy
}
}