Skip to content

Agent Health and Readiness

The K8s agent exposes HTTP endpoints for Kubernetes liveness, readiness, and metrics probes. The Helm chart configures these probes automatically.

Endpoint Purpose Probe type
/healthz Is the process alive? Liveness
/livez Alias for /healthz Liveness
/readyz Is the agent ready to serve traffic? Readiness
/metrics Prometheus metrics Scrape target

All endpoints return JSON and are rate-limited (100 req/s by default).

/healthz always returns 200 OK as long as the process is running. It does not check downstream dependencies. If this endpoint stops responding, the kubelet restarts the pod.

/readyz reflects whether the agent is able to do useful work. The response depends on the pod’s role.

A leader pod is marked ready when OnStartedLeading fires. After that, readiness depends on continued operational success: if no successful push or heartbeat has been recorded in the last 5 minutes, the endpoint returns 503 Service Unavailable with status degraded. This removes the pod from the Service’s endpoint set, which is the correct signal to Kubernetes that the agent is not functioning.

Once the pusher or heartbeat records a success, the pod returns to 200 OK with status ready.

At startup the leader sends its full list of workloads and pods at the pace Shoehorn accepts them, and keeps retrying while Shoehorn is unreachable instead of dropping part of the list. If Shoehorn stays unreachable for 5 minutes, the leader shows degraded until the list is delivered.

The leader keeps trying for up to SHOEHORN_FULL_SYNC_MAX_WAIT, 15 minutes by default. After that it gives up on the list, withholds its completion, and logs a warning. It sends a new list at its next restart or handover, and reports ready again once a push succeeds. While the list is pending, the agent logs its progress every minute.

A follower pod is marked ready when leader election determines it is not the leader. Followers do not run the pusher or heartbeat, so they never record operational successes. To avoid false degradation, followers skip the 5-minute success check entirely. A follower remains ready as long as the process is alive.

This means follower pods stay in the Service’s endpoint set indefinitely, which is the desired behavior – they are healthy standby replicas waiting for failover.

Pod starts
|
v
[not_ready] -- 503
|
|-- OnStartedLeading --> [ready (leader)] -- 200
| |
| +-- no success in 5m --> [degraded] -- 503
| | |
| +------- success recorded ---+
|
+-- OnNewLeader (someone else) --> [ready (follower)] -- 200 (indefinitely)

The /metrics endpoint exposes standard Prometheus metrics. Key agent-specific metrics:

All agent metrics live under the shoehorn_ namespace.

Metric Type Description
shoehorn_health_checks_total Counter Health check requests by endpoint and status
shoehorn_health_rate_limit_hits_total Counter Rate limit rejections by endpoint
shoehorn_k8s_watcher_events_total{kind,type} Counter Kubernetes events processed by the watcher
shoehorn_k8s_watcher_events_dropped_total Counter Events dropped because the event channel was full. During the agent’s startup full sync, workload and pod events wait for room instead
shoehorn_k8s_watcher_deletes_dropped_total{reason} Counter Deletes dropped before reaching the platform. The resource stays in the catalog until the agent’s next full sync, which runs when it starts or takes over as leader. timeout: the event channel stayed full for 10 seconds. backpressure: dropped at once because the channel was still full after a timeout. stopped: the agent was shutting down. Also counted in events_dropped_total
shoehorn_full_sync_completions_withheld_total{layer} Counter Full syncs that ended without telling the platform they were complete, because part of the sync was not delivered. The platform then removes nothing, so a deleted resource stays in the catalog until the agent’s next full sync, which runs when it starts or takes over as leader. The full sync waits for Shoehorn however large the cluster, for up to SHOEHORN_FULL_SYNC_MAX_WAIT (15 minutes by default), so this counts a rejection, a shutdown, or a full sync that ran out of that time. The agent log names the reason. layer names where it was noticed. pusher: Shoehorn rejected a push of the sync as invalid, or the agent stopped or ran out of time before a push was delivered. batcher and watcher: the agent stopped, or ran out of time, while the end of the sync was on its way. A count at a shutdown or handover is expected; a count at a restart without one means Shoehorn rejected part of the sync or stayed unreachable for longer than the maximum wait
shoehorn_connected_workloads_not_collected_total{reason} Counter Workloads whose connected resources were not collected in a push. collection_failed: an API call failed. push_cap: skipped because the push reached the agent’s cap of 50,000 connected resources. payload_size: the workload was too large for a push on its own and was sent trimmed, without its connected resources. The platform keeps what it had stored for them, so a climbing count means that data may be out of date
shoehorn_k8s_watcher_events_filtered_total{reason} Counter Events filtered by namespace, label, or rate limit
shoehorn_k8s_watcher_drop_rate Gauge Current event drop rate (per second, last minute)
shoehorn_batcher_batches_dropped_total{reason} Counter Batches dropped before the pusher took them. timeout: a batch after the startup full sync waited 5 seconds, or the agent’s final batch at shutdown found no room for 10 seconds. ctx_cancelled: the agent was shutting down while a batch waited. Batches of the startup full sync wait for the pusher instead of timing out, until the agent shuts down
shoehorn_pusher_payload_size_too_large_total Counter Batches not sent because an object does not fit a push of 9 MiB even trimmed. A full sync that carried such a batch withholds its completion, so shoehorn_full_sync_completions_withheld_total counts it too
shoehorn_pusher_batches_split_total Counter Batches sent as several pushes because they exceeded the 9 MiB push size limit or one of the platform’s per-push caps (5,000 entities, 5,000 workloads and pods, 10,000 pod events, 1,000 network policies). A steady count is normal on a cluster with many large workloads
shoehorn_pusher_objects_trimmed_total{object,level} Counter Objects too large for a push on their own, sent trimmed, with a warning in the agent log naming each one. object: entity or instance. level: values, long annotation values, messages and descriptions cut to 256 bytes with every key kept; or identity, only identity, status, and the labels and shoehorn.dev annotations the catalog identity, owner, type and tags come from. Shoehorn stores the trimmed values for that object
shoehorn_pusher_payload_size_bytes Histogram Payload size distribution

The agent sends pushes of up to 9 MiB. Shoehorn accepts request bodies of up to 10 MiB, or K8S_AGENT_PUSH_BODY_LIMIT_BYTES if that is set lower, so keep that setting at 10 MiB or more. A proxy in front of Shoehorn must accept 10 MiB bodies too: ingress-nginx allows 1 MiB by default, so set nginx.ingress.kubernetes.io/proxy-body-size: 10m on Shoehorn’s Ingress.

The Helm chart can create a ServiceMonitor for automatic Prometheus scraping.

groups:
- name: shoehorn-k8s-agent
rules:
- alert: ShoehornAgentDroppingEvents
expr: rate(shoehorn_k8s_watcher_events_dropped_total[5m]) > 0
for: 10m
annotations:
summary: K8s agent is dropping events
description: |
The agent's event channel is overflowing. Raise agent.eventChannelSize
or stretch agent.resyncPeriod (in the Helm chart) and redeploy.
- alert: ShoehornAgentBatchesDropped
expr: increase(shoehorn_batcher_batches_dropped_total[15m]) > 0
annotations:
summary: K8s agent is dropping batches before they reach the platform
- alert: ShoehornReconcileGuardSkipping
expr: rate(shoehorn_k8s_reconcile_skipped_total[30m]) > 0
for: 1h
annotations:
summary: Reconciliation sweeps repeatedly skipped by a guard
description: |
The platform's partial-sync or empty-sync guard is firing. Stale
catalogue rows may be accumulating. Check the agent's drop counters.
  • Leader degradation alerts: If the leader pod enters degraded state, it means pushes and heartbeats have stopped succeeding. Investigate API connectivity, token validity, and circuit breaker state in the logs.
  • Frequent leader transitions: If OnNewLeader fires repeatedly in logs, check for resource pressure, pod evictions, or network partitions affecting the leader election lease.
  • All pods not-ready: If all replicas show not_ready, leader election may not be completing. Check that the agent has permission to create Leases in the configured namespace.