The Ignore Rule Hid the Diff, and the Sync Kept Applying It
For eleven months a GitOps application showed Synced while every sync quietly rewrote one of its secrets with a new random value. Nothing noticed, because nothing restarts when a Secret changes. Then one routine change restarted half of the things that read it.
The outage as it presented#
All CI stopped. We run Woodpecker, and its build agents were in a crash loop, each of them dying on the same line:
individual agent not found by token: sql: no rows in result set
That is a database error about a missing row, and it sends you to the database. The first theory arrived fully formed: the CI server’s database had been moved to a new home some months earlier, and the migration must have left the agents’ rows behind.
It was a good theory and the calendar killed it. The same agents had been restarted, and had registered again without complaint, since the migration. Rows that were never carried over do not work for three months and then stop.
Restarting the CI server fixed it. Which was a relief, and not an explanation.
Three ordinary facts#
Nothing exotic was involved. The outage needed three things to be true at once, and each of them is common enough that most GitOps installations have at least two.
One: the chart generates the secret. The CI system’s Helm chart creates the shared secret that agents use to register with the server. Like many charts, it tries to be stable about it: look the Secret up in the cluster, reuse the value if it exists, generate random characters only if it does not. In outline:
value = lookup(existing Secret) or randAlphaNum(64)
lookup asks the cluster. Argo CD does not render charts against the
cluster; it runs the equivalent of helm template, where lookup has
nothing to ask and returns empty. So under Argo CD that line is not
“reuse, else random”. It is random, on every render.
Two: the ignore rule only hides the diff. A secret that changes on every render makes the application permanently out of sync, and the well-known answer is an ignore rule:
spec:
ignoreDifferences:
- kind: Secret
jsonPointers:
- /data/WOODPECKER_AGENT_SECRET
This works exactly as far as the status display. ignoreDifferences is
consulted when Argo CD compares desired and live state. It is not
consulted when Argo CD applies desired state. The application shows
Synced, and the next sync — for any reason, about any resource — writes
the whole rendered manifest, fresh random value included.
Three: nothing restarts when a Secret changes. Both the server and the agents took the value as an environment variable from the Secret. A process reads its environment once, at start. Change the Secret under a running pod and the pod keeps the old value until something else restarts it. Charts that want a restart add a checksum annotation to the pod template; this one did not.
Eleven months of nothing#
Put those together and the application had been rewriting its own shared secret on every sync since the ignore rule was added, and it did not matter at all.
It did not matter because of fact three. The secret in the cluster kept changing; the secret in each running process did not. As long as the server and the agents were started around the same time — or simply never restarted — they agreed with each other and disagreed only with an object that nobody was reading.
What it took was a change that restarted one side and not the other. A values change touched the agents’ configuration. Argo CD re-rendered, produced another new secret, and rolled the agents, which started up with the value of the day. The server had last started two days earlier and was holding a different one.
Why the error lied#
Most systems would have said “unauthorized” at this point and saved us the detour. This one could not, for a reason that is perfectly sensible in its own code.
The server recognises an agent in two ways. An agent presenting the shared secret is a system agent: the server finds or creates its record, and the token stored in that record is the shared secret itself. Any other token is assumed to belong to an individually registered agent and is looked up by value in the agents table.
So an agent that arrives holding yesterday’s shared secret is not “a system agent with a bad password”. It does not match the secret the server holds, which makes it, by elimination, an individual agent — one whose token is then not found. The server’s report was accurate. There really was no such row. There never had been.
When an authentication failure is phrased as a lookup failure, the useful question is not where the row went. It is which lookup you ended up in, and why.
Reading it from outside#
All of this was established with a read-only role, without opening a shell in anything and without ever reading the secret.
- The agents’ fatal line gave the exact error text.
- The server pod’s last termination record gave the one date it had restarted.
- Argo CD keeps a sync history per application, with a timestamp for each deployment. The agents’ workload keeps a revision history too. The two lists matched one for one: every sync had been a re-render, and every re-render that touched the agents had rolled them.
- The chart template, at the pinned version, showed the lookup-or-random line.
- The server’s source, at the running version, showed where the error text comes from and what has to be true to reach it.
The comparison in the middle is the one worth keeping. A sync history lined up against a controller’s revision history tells you whether your GitOps tool is the thing restarting your workloads, and it costs two read-only queries.
Two things that were true and did not matter#
The server logged a warning at every start that its internal signing secret was not configured and a temporary one had been generated. That is real, and worth fixing, and unrelated: it signs the short-lived tokens agents use after they have registered, and losing it costs each agent one re-registration, which they do on their own.
The agents also started without a saved configuration file. Also true, and normal for agents registered this way.
Both were in the logs right next to the failure. Proximity is not evidence.
The option that completes the ignore rule#
spec:
syncPolicy:
syncOptions:
- RespectIgnoreDifferences=true
With it, the sync leaves ignored fields as they are in the cluster. The value is generated once, on first install, and from then on lives only in the cluster. Without it, an ignore rule is a statement about the dashboard.
Two things to know before relying on it. It applies to resources that already exist; on first creation there is no live value to respect, so the rendered one is used, which is what you want. And rotating the secret becomes a deliberate act: delete it, sync, and restart every consumer together.
The honest position on ignoreDifferences is that it is a claim — “this
field is allowed to differ” — and the claim only holds if the sync is told
to respect it. One without the other is this outage, waiting for a restart
to be scheduled on one side of a shared secret.
What to look for tonight#
- Every application with
ignoreDifferencesand noRespectIgnoreDifferences=true. Ask of each: is the ignored field something the cluster is supposed to own? Then the sync is overwriting it. - Every chart in use that calls
randAlphaNum,genCA,genPrivateKeyorlookup. Under template-only rendering these produce a new value each time, or nothing. - Every generated credential read by more than one workload, where the pod templates carry no checksum of the Secret. Those consumers agree with each other only by the accident of when they last started.
Any one of the three is survivable. We had all three, a green dashboard, and eleven quiet months.