acoustic-carpenter-78188
07/29/2026, 8:58 PMSecretService, task pods kept getting the old
value for up to a day. Users hit this as "I rotated my secret and my tasks still fail auth."
Two sharper cases fall out of the same gap:
Cascade shadowing. lookUpSecret resolves through a project+domain → domain → org cascade and
caches under whichever scope the fetcher hit. One logical secret can therefore be cached under any
of (org, domain, project), (org, domain, ""), or (org, "", ""). Clearing only the exact tuple
misses a value cached at a broader scope, and the cascade keeps serving it. Concretely: an
org-scoped secret is cached, a user then creates a project-scoped override, the project key is
invalidated, the org key survives, and the cascade still returns the old value. This is why
create invalidates too, not just update.
Deleted secrets staying live. If the Secret is already gone from Kubernetes (deleted
out-of-band), DeleteSecret returns NotFound. Returning early there left the webhook serving the
cached value — a secret the user believes is deleted keeps being injected into pods until TTL.
What changes were proposed in this pull request?
Webhook side — clearing the cache
• InvalidateCache is part of the SecretsInjector interface, so adding a caching injector
without wiring up invalidation is a compile error rather than a silently reintroduced staleness
bug. Read-through injectors (global, k8s, aws, gcp, azure, vault) implement it as a no-op.
• EmbeddedSecretManagerInjector.InvalidateCache clears all three cascade keys — the caller can't
know which scope the cached copy lived at, and the deletes are cheap.
• SecretsPodMutator.InvalidateCache fans out across enabled injectors.
• A plain-HTTP server on its own port (webhook.cacheInvalidationPort, default 9444) exposes
POST /invalidate-secret, so invalidation keeps working once the webhook no longer shares a
process with the secret service. 0 disables it.
Secret service side — triggering it
• Posts to the webhook after every write: create, update, and delete. Delete invalidates on its
NotFound path too, via defer.
• Resolves the configured host and posts to every address rather than issuing one request to
the name. Against a headless Service the name yields an A record per pod and Go's client picks
one, so a single request would invalidate one arbitrary replica and leave the rest stale — a
failure that looks exactly like success. A ClusterIP Service or bare host resolves to one
address, so both topologies share the path.
• Best-effort by design: the secret is already durably written when invalidation runs, so failures
are logged with an n/m pod count and the write RPC still succeeds. The degraded state is
"old value until TTL", which is exactly the pre-PR behavior.
Chart
• A headless Service (clusterIP: None, port 9444) resolving to every webhook pod. Added
alongside the existing webhook Service rather than converting it — that one is what the
MutatingWebhookConfiguration points the API server at for admission and must keep its
ClusterIP.
• flyte-core-components.secret.webhookURL points at it; the Go default stays localhost so
local and devbox runs need no DNS.
Incidental
• The org is part of the secret cache key, so the value stamped on pod labels, used to encode the
secret name, and passed to InvalidateCache must agree. They were three independent "flyte"
literals in three packages; hoisted to flytesecret.DefaultOrganization.
Security note
/invalidate-secret is plain HTTP and unauthenticated. It is bound to its own port and included
only in the cluster-internal Services, never routed through an ingress. It carries no secret
material in either direction — the request names a secret, the response is a status code — but it
is a cache-eviction primitive and should stay cluster-internal.
A naming trap worth knowing
The webhook now serves two ports: 9443 for admission, 9444 for invalidation. webhookURL does
not say which, and a URL with no port defaults to 9444. The field comment, config comment, pflag
help, and values.yaml comment all state this explicitly.
How was this patch tested?
Unit tests
• InvalidateCache clears exactly the three cascade keys.
• Create, update, and delete each invalidate with the right (org, domain, project, name).
• Delete invalidates even when the Secret is missing, while still reporting NotFound.
• Invalidation failure (disabled, unreachable, 5xx) never fails the write.
• Fan-out reaches every resolved address; target construction covers port defaulting, IPv6
bracketing, trailing slash, and no-host rejection.
• Server: valid request 200, missing name 400, malformed body 400, GET 405.
go build ./... and go test ./flyteplugins/go/tasks/pluginmachinery/secret/... ./executor/... ./secret/...
pass. helm lint and helm template clean; chart README regenerated with helm-docs.
End-to-end on a live single-binary cluster
Rotation, against the 24h TTL that would otherwise make a stale read permanent:
| Step | Action | Task saw |
| ---- | ---------------------------------------------------------- | --------------------------------------- |
| 1 | create secret v1, run task | v1 (now cached) |
| 2 | rotate to v2 via the API, run task | v2 — invalidation worked |
| 3 | patch the k8s Secret directly to v3, bypassing the service | v2 — stale, proving the cache is real |
| 4 | POST /invalidate-secret by hand, run task | v3 |
Step 3 is the control; without it step 2 proves nothing.
Deleted-secret fix, same shape:
| Step | Action | Result |
| ---- | -------------------------------------- | ------------------------------------------ |
| 1 | create secret, run task | value injected, now cached |
| 2 | kubectl delete the Secret out-of-band | k8s empty, cache warm |
| 3 | run task | still injected — the bug |
| 4 | DeleteSecret on the now-missing secret | NotFound returned and invalidation fired |
| 5 | run task | pod never created; admission denied |
Fan-out was verified against a headless Service with two endpoints — one real pod and one dead
address — since the binary is not yet multi-replica-ready (see below). A single write produced an
invalidation on the real pod and a connection attempt to the dead one, ending in
`failed on 1/2 webhook pod(s)`: both addresses attempted from one write, which a single-request
implementation cannot produce.
Known limitations
• Fan-out is not exercised by real replicas yet. flyte-binary is hardcoded to replicas: 1,
and running more today would be unsafe for unrelated reasons: leader election defaults to off,
and with localCert: true each replica mints its own webhook cert and races on the
MutatingWebhookConfiguration CA bundle. The headless Service and fan-out are in place so
invalidation is already correct when those are fixed; they are not a claim that multi-replica
works today.
• Invalidation is best-effort. A wedged or unreachable webhook degrades to TTL behavior with a
warning log rather than failing the write.
Labels
added, fixed
Check all the applicable boxes
• I updated the documentation accordingly.
• All new and existing tests passed.
• All commits…
flyteorg/flyteacoustic-carpenter-78188
07/31/2026, 5:23 PM