Repository navigation
install: add a liveness probe to the Envoy sidecars of Substrate - #735
Conversation
mayawang
left a comment
There was a problem hiding this comment.
Clean root-cause writeup and tests. Since restartStuckDeployments works around agent-substrate/substrate#3601, let's link that issue in the code and docs so we know when it's safe to remove. Left a couple of small notes inline on scope, threshold, and Envoy draining.
|
Let's file an issue tracking agent-substrate/substrate#3601, and fix the force restart once it's closed. |
|
Instead of restarting stuck pods in |
`ax local start` could not recover when a pod of Agent Substrate ran but never became ready. It applied the unchanged manifests, which creates no new pod, waited for the same pod, and failed with "timed out waiting for the condition". The case in google#697 is the envoy container of atenet-router. When only the router container next to it restarts, its shutdown sequence has already failed Envoy's health check and drained its listeners, and nothing sets that back (agent-substrate/substrate#3601). Kubernetes does not repair the pod: the envoy process is alive and has only a readiness probe, and the pod still matches its Deployment. atenet-egress has the same defect. Bootstrap now adds a liveness probe on /ready to the envoy container of atenet-router (RenderSystemBundle) and atenet-egress (RenderEgressBundle), so the kubelet restarts a drained Envoy by itself. A container that has a liveness probe already keeps it. The probe fails after 60 seconds of 503. Envoy also answers 503 while it starts, and the window leaves it time for that. A pod that is being deleted is not affected: the kubelet runs no liveness probe on it. alreadyHealthy now requires the pods of every workload that Bootstrap waits for. It did not look at atenet-egress, so a cluster with a stuck egress pod was reported healthy and Bootstrap returned. A cluster installed before this change gets the probe the next time Bootstrap applies the manifests. The rollout status and the timeout error now name a container that runs but is not ready, and the error gives the command that restarts the workload. This also applies to `ax install`. Tested on a new Kind cluster: after SIGTERM to the router process, the kubelet restarted envoy and the pod was ready again without another `ax local start`, in 132 seconds for atenet-router and 117 seconds for atenet-egress. Fixes google#697
9c86c2d to
77c2a3a
Compare
Yeah, we could do that and clean it up later. Also filed issue #755 to track. |
Part of #754 ## Problem `ax local status` looked only at `ate-api-server` and at the `proxy_arp` sysctl of the node. In #754 the `envoy` container of `atenet-router` stayed unready and the `atenet-router` Service had no endpoints, so new workspaces hung, while the status still read: ``` Substrate: ate-api-server (1/1 available) ``` ## Change `KindProvider.Status` now reads every workload that `ax local start` installs for Agent Substrate, with one `kubectl get deployments,statefulsets,daemonsets -A`. When a workload has fewer available pods than it wants, the `Substrate:` line names it instead of `ate-api-server`: ``` Substrate: degraded: atenet-router (0/1 available), atenet-egress (0/1 available) ``` ## Not in this PR #754 also asks that a Workspace report the unreachable router as a condition instead of staying in `Preparing` with no conditions. Arguable if we should let workspace to report the underlying subtrate status especially we could potentially make workspace 100% declaritive. ## Test On a Kind cluster built from this branch (no liveness probe from #735, so Envoy stays drained): ``` $ ax local status --name ax-754 Cluster: ax-754 (kind) State: Running Kube Context: kind-ax-754 Substrate: ate-api-server (1/1 available) AX Server: ax-server (1/1 available in ax-system) $ docker exec ax-754-control-plane pkill -TERM -f 'router --mode=ingress' $ docker exec ax-754-control-plane pkill -TERM -f 'router --mode=egress' $ kubectl --context kind-ax-754 -n ate-system get deploy atenet-router atenet-egress NAME READY UP-TO-DATE AVAILABLE atenet-egress 0/1 1 0 atenet-router 0/1 1 0 $ ax local status --name ax-754 Cluster: ax-754 (kind) State: Running Kube Context: kind-ax-754 Substrate: degraded: atenet-router (0/1 available), atenet-egress (0/1 available) AX Server: ax-server (1/1 available in ax-system) ```
Fixes #697
Root cause:
ax local startonly re-applies unchanged manifests, which creates no new pod, and then waits on the stuck one.agent-substrate/substrate#3601
The root cause is on substrate end. When only the atenet-router container restarts (the kubelet restarts single containers, not pods), the router's shutdown sequence has already told Envoy to fail its health check (POST /healthcheck/fail). The new router process never undoes that, and Envoy itself never restarted, so it reports DRAINING and 503 on /ready forever. Kubernetes does not repair it: the envoy container has a readiness probe but no liveness probe, and a Deployment does not replace a pod for being unready. atenet-egress has the same problem.
Fix on Ax
kubectl rolloutrestart commands.The probe is ·initialDelaySeconds: 30, periodSeconds: 10, failureThreshold: 6·: Envoy is restarted after 60 seconds of 503. Envoy also answers 503 while it starts, and the window leaves it time for that.
Test