Two Kubernetes incidents with healthy pods and clean logs. Deciding where to look was the real work, and AI didn’t do that part.
The alert said „high error rate.“ No stack trace, no culprit, just a number that crossed a line.
I opened the logs of our ingress reverse proxy, and it was serving 500s to real users. Then I checked the application behind it. Health metrics up. One restart, a few startup lines from it, and not a single error or warning. Nothing you’d circle in red.
The proxy said requests failed. The application said it never failed anything. Both were telling the truth.
My team hit two incidents like that on services we run on Kubernetes. The first turned out to be textbook, once we knew which question to ask. The second was stranger, because the thing meant to protect users was the thing causing the outage.
Each fix was a few lines. Finding them took most of the effort. I think writing code is mostly a solved problem now, but day two isn’t. Once software is deployed and people are using it, you meet the bugs that got past every test you wrote, and they rarely leave a stack trace.
We could have ignored both. My team runs on „you build it, you run it,“ so there’s no ops department to hand this to, and our SLO is roughly 99.9% successful responses. A handful of 500s here and there barely dents that. But an SLO gives you room to be pragmatic. It doesn’t give you permission to stop caring about the 0.1%, because every one of those is a person whose request failed.
The only clue was the restart
In the first incident there was exactly one event on the table, and it looked like the least interesting one. Pods restart all the time. This one came back healthy. Everything else said normal.
So the question changed. It stopped being „what’s broken?“ and became „can a restart produce 500s without the application ever noticing?“
It can. The application had no graceful shutdown. When it got a termination signal, it just stopped. It didn’t finish the requests it was already handling, and it didn’t wait for traffic to stop arriving. The connections died mid-flight, the proxy had nobody to answer, and the user got a 500.
From the application’s side, nothing went wrong. It was told to stop and it stopped. The failure lived in the gap between two components that each thought they were behaving correctly.
What actually happens when Kubernetes kills a pod
This bug is easy to ship on Kubernetes, and once you see why, you’ll want to check every service you own.
When Kubernetes terminates a pod, two things kick off at roughly the same time. The kubelet sends SIGTERM to your container. Separately, the control plane removes the pod from the Service’s endpoints, and that change has to propagate to every proxy and load balancer routing traffic. Those two paths don’t wait for each other.
sequenceDiagram
participant K as Kubernetes
participant P as Ingress proxy
participant A as App container
K->>A: SIGTERM
K->>P: remove pod from endpoints (propagates with a delay)
Note over A: exits immediately
P->>A: new request (endpoint list not updated yet)
A--xP: connection refused / reset
P-->>P: logs 5xx to the user
If your process exits the instant SIGTERM arrives, there’s a window where the proxy still thinks the pod is alive and keeps sending it requests. Any request already in flight dies too. A few hundred milliseconds of that during each restart is enough to trip an error-rate alert, and the app’s own logs show nothing at all.
We had two options to fix it.
The first is a preStop hook. Kubernetes runs it before sending SIGTERM, so a short sleep there gives the endpoint removal time to propagate before the process even hears about shutdown:
lifecycle:
preStop:
exec:
command: ["sleep", "10"]
This needs a sleep binary in the image. Recent Kubernetes versions also have a native sleep action for lifecycle hooks if your image is distroless. Keep the total under terminationGracePeriodSeconds (30 seconds by default), or Kubernetes will SIGKILL the container before it finishes.
The second option is to fix it in the application. Catch SIGTERM, stop accepting new connections, let in-flight requests finish, then exit. In Go that’s roughly:
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGTERM)
defer stop()
go srv.ListenAndServe()
<-ctx.Done()
shutdownCtx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
srv.Shutdown(shutdownCtx)
In practice you often want both. The app-level shutdown drains the requests already in flight. The preStop delay covers the requests that are still on their way because the proxy hasn’t heard the news yet.
Yes, this is textbook. Ask any model why you get 500s during pod restarts and it will probably say „preStop hook“ before you finish typing. But nobody handed us that question. We had a vague alert and a system insisting it was fine. I can picture an agent doing every early step right, pulling the proxy logs, finding the restart, scanning the app logs, and ending up exactly where I was, holding a pile of evidence that says nothing is wrong. The question only appears once you treat „it only restarted“ as the most interesting fact on the table instead of the least. Maybe a model gets there. I wouldn’t bet my SLO on it.
„Flaky“ is a bug you decided not to understand
The second incident didn’t even have a restart to point at.
Same alert, high error rate. Application healthy, no restarts, no error logs. And every so often, a few 500s.
It happened rarely enough that we almost filed it under flakes. I hate doing that. „Flaky“ is what we call a bug when we’ve decided not to understand it. So we started digging.
There was nothing to dig into, so we built something. We had AI write the test scripts, a whole set of them, plus tooling to snapshot the entire environment while they ran, probe results included. Deciding what to capture was ours. So was deciding to run it for days instead of an hour, because the failure was rare and we needed it to happen while we were watching.
Eventually it did, and the snapshots showed what the dashboards never had. Readiness probes were failing.
The probe was waiting in line with the customers
We ran several replicas of this service. Sometimes one replica would fail its readiness probe, Kubernetes would mark it unready, and it would drop out of the load balancer until it recovered. The others picked up the slack, and users mostly didn’t notice.
Sometimes, though, every replica failed its readiness probe at the same time. Now the Service has zero ready endpoints, and every request in that window fails.
Why were the probes failing? The server was slow, and the probe timed out. That’s all. Not under a spike either. Ordinary traffic, nothing unusual, and the health endpoint still couldn’t answer in time.
The mechanism is worth internalizing. The health endpoint lived on the same server as the real application traffic, so the probe stood in the same queue as every customer request. When the server got slow, the probe waited like everyone else, and the probe had a stopwatch. Kubernetes‘ default readiness timeoutSeconds is 1 second, and plenty of manifests never touch it. A server that’s sluggish but perfectly alive can blow through that and get pulled out of rotation.
Every replica ran the same code against the same traffic, so whatever slowed one down could slow all of them down together. When that happened, Kubernetes turned „slow“ into „down.“ The mechanism meant to protect users from unhealthy pods was creating the outage.
And it hid well. Kubernetes does record a failed probe as a Warning event, but events expire after an hour by default, and an occasional short stretch of unreadiness scrolls past long before anyone runs kubectl get events. Inside the application there was nothing to log. A slow response isn’t an error.
The boring fix was the right one
The cleanest fix is a dedicated health server inside the application, on its own port, so probes don’t compete with real traffic. But this wasn’t our code. It’s an open source application. We can open issues and send PRs, and we’re still at the maintainers‘ mercy on whether and when that ships.
The second option was to do it ourselves. Build a sidecar with its own health service, or build and maintain our own image that adds one. That works, and now we’re maintaining a fork of somebody else’s operational behavior forever.
The third option was to raise the readiness probe timeout.
We did that. And from then on, it worked.
I want to be fair about the trade-offs. A longer timeout means Kubernetes takes longer to pull a truly broken pod out of rotation. For this service that was the right call, because the pods weren’t broken. They were slow sometimes, under normal load, and the probe was far too strict about it.
The slowness isn’t free either. If the health endpoint sometimes needed more than a second, some users were waiting that long too. That’s a latency problem worth chasing on its own. It’s just a different problem from Kubernetes yanking every replica out of rotation. Sometimes the super easy fix is the correct one. The trick is knowing you’re picking it for a reason and not because you’re tired.
The fix was the easy part
Both bugs lived between components, where every log is honestly clean. Reading the logs harder would never have found either one, no matter who was reading.
What found them was two different moves. The first incident needed reasoning about evidence that wasn’t there. The second needed an experiment to produce evidence that didn’t exist yet. AI wrote the scripts for that experiment. It didn’t decide that a rare failure means running for days, or that green dashboards mean you capture the raw state instead of trusting them. Neither move is a coding task.
Caring about that 0.1%, and forming a theory about what’s missing, is still a human job. Day two needs people who refuse to call it flaky.
Peace, nerds.