Repository navigation
fix(tts-audio): drop egress policy, pin pods to a node pool - #286
Merged
Merged
Conversation
added 4 commits
November 27, 2026 23:54
The backfill could not create a single Job on this cluster: it read all 221
posts and failed each one with `connect ECONNREFUSED <apiserver>:443`.
The cause was the egress NetworkPolicies, but not in the way the manifests
suggested. Probing from inside a receiver pod, *any* egress policy selecting
these pods took down every in-cluster destination, including the pod's own
Service ClusterIP:
no egress policy -> API OPEN, own ClusterIP OPEN
any egress policy -> API ECONNREFUSED, own ClusterIP ECONNREFUSED
"Any" included a single policy whose only rule was `port: 443` with no `to:`,
and one with an explicit `to: ipBlock` covering the service, pod and node
ranges. Public hosts on 443 and direct pod-to-pod traffic kept working, so the
failure was specific to the service path. That is a CNI defect; there is no
egress rule shape that both selects these pods and leaves the API reachable.
The policies were also not containing anything meaningful, since any
destination on 443 passed.
So egress restriction is dropped until the dataplane is fixed, and the
evidence is recorded in base/netpol.yaml so nobody re-adds one unaware.
`test.sh` now fails if an egress policy reappears.
Pods are pinned to a node pool by label (`dsh.sredevops.org/node-pool`, value
from NODE_POOL) because "where these run" is now a decision with consequences.
The Deployment and backfill carry it in their manifests; synthesis Jobs get it
from the receiver, which reads NODE_POOL itself — the job template keeps an
empty `nodeSelector` so this cluster's pool is never baked into a template
every future Job is stamped from. render.sh refuses to render if that
template ever references the placeholder.
Also fixed, found while wiring this up:
- `render.sh` never defaulted TLS_SECRET, so rendering directly (not via
`make`) emitted `name: ` in the Gateway's certificateRef — a Gateway
referencing no certificate, silent until the hostname fails. The defaults
now exist there and are *exported*, because envsubst reads only the
environment. test.sh asserts no field renders empty.
- The deploy no longer needs TLS_SECRET passed by hand.
Verified on the cluster: 221 eligible posts, 221 Jobs created, 0 failures
(previously 0 created, 221 failed). The retry run reported
`{"result":"ok","created":10,"skipped":211,"failed":0}`, confirming
idempotency.
The job template asks for 2 CPU because of a throughput measurement, not a capacity one. On the cluster that runs it the node has 2 allocatable CPUs and the webhooks already hold 810m, so a 221-Job backfill queues every Job Pending: 0/2 nodes are available: 1 Insufficient cpu, 1 node(s) were unschedulable Nothing runs, and the Jobs do not fail — they simply sit there, which reads as "still working" rather than "will never start". Verified that lowering the request to 1 CPU lets a Job schedule and complete; the limit can stay at 4, since requests are what the scheduler books and limits are what the cgroup allows. The node also caps pods at 110, so a backfill of 221 cannot be fully resident regardless of CPU. Documented rather than tuned: the right request depends on the pool an operator is deploying to, and silently halving it would contradict the throughput numbers in the same document. The ADR records the measurement and why the pod placement is now explicit.
Three changes that only make sense together, because each one alone makes the
next one unsafe.
**Sizing.** requests becomes {cpu: 0, memory: 256Mi}, limits stay {cpu: 2,
memory: 3Gi}. The node has 2 allocatable cores and the webhooks hold ~800m, so
the previous 2-core request made every Job in a 221-post backfill unschedulable
and nothing ever ran. A 0 request always fits; the limit still lets a Job use
both cores when the node is otherwise idle.
**Queue.** A 0 request throttles nothing, so the scheduler admits every Job at
once and they contend until each crawls. Nothing in batch/v1 caps concurrency
*across* Jobs — `parallelism` caps pods inside one Job, and every post gets its
own — so the cap lives in worker/src/k8s.mjs: the backfill creates the next Job
only when fewer than MAX_CONCURRENT_JOBS (default 1) are active. QUEUE_MAX_WAIT_MS
bounds the wait so a Job that can never be scheduled fails the run instead of
blocking it forever.
**WORKER_IMAGE was never substituted.** Both workloads carried
`value: "${IMAGE}"`, but `${IMAGE}` is one of the placeholders envsubst is told
to skip (it belongs to the Job template inside the ConfigMap). The literal
string reached the cluster, the receiver stamped it into every Job's `image`,
and those Jobs failed with InvalidImageName — observed live, 66 of them. It is
now resolved in render.sh as `IMAGE:TAG`, the same reference kustomize gives the
Deployment, and test.sh fails if the placeholder comes back.
The template inside the ConfigMap keeps its own `${IMAGE}` placeholder on
purpose: that one is filled per Job by the receiver, not at render time.
Verified: `deploy/tts-audio/test.sh` (93 worker tests, 9 new for the queue and
3 for sizing/image), `shellcheck`, and each new assertion checked against an
injected regression.
`kubectl apply` creates or updates whatever it is given, so while `base/backfill.yaml` was a kustomize resource every `make deploy` — and every `make diff` — recreated the backfill Job. Deploying an unrelated ConfigMap change therefore started a full archive backfill. Observed twice: 221 Jobs queued from a deploy, and again from `make backfill`'s own double-apply workaround, which existed precisely because apply kept recreating the Job. The Job is now rendered only under `WITH_BACKFILL=1`, mirroring the existing `WITH_GATEWAY` flag. Only `make backfill` sets it: - `base/backfill.yaml` is not in `base/kustomization.yaml` and carries its own node-pool selector, since it no longer goes through a kustomize patch (`overlay/node-pool-backfill.yaml` is deleted). - `make deploy` pins `WITH_BACKFILL=0` explicitly, so the exclusion is a decision in the Makefile rather than a default that could drift. - `make backfill` deletes the previous Job, then applies with the flag. That removes the double-apply workaround: a Job's pod template is immutable, so deleting-then-creating is the only way to track the run you just started rather than a completed one from last week. - `make render`/`make diff` share one `RENDER_ENV` instead of duplicating the variable list three times. `test.sh` asserts both directions: the default render contains no Job, and `WITH_BACKFILL=1` renders one with the right node selector and a real WORKER_IMAGE. Verified the guard fires by re-adding backfill.yaml to the kustomization. Also corrected a README figure that was wrong by ~1000x: it said "~8k chars/s of CPU, so 1-2 minutes per post", while the measured throughput in the same document is 8 chars/s, making a 9k article ~19 minutes. A hundred posts is most of a day queued one at a time, not "a couple of hours".
ngeorger
approved these changes
Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The backfill could not create a single Job on this cluster: it read all 221 posts and failed every one with
connect ECONNREFUSED <apiserver>:443.Root cause
The egress NetworkPolicies — but not in the way the manifests suggested. Probing from inside a receiver pod:
10.43.0.1:443(API)ECONNREFUSEDECONNREFUSED"Any" included a single policy whose only rule was
port: 443with noto:, and one with an explicitto: ipBlockcovering the service, pod and node ranges. Public hosts on 443 and direct pod-to-pod traffic kept working throughout, so the failure was specific to the service path. That's a CNI defect — there is no egress rule shape that both selects these pods and leaves the API reachable.The previous fix (#283) added a more permissive rule, which could not have worked. It also gave no real containment: any destination on 443 passed.
Changes
base/netpol.yamlso nobody re-adds one unaware.test.shfails if an egress policy reappears.dsh.sredevops.org/node-pool, value fromNODE_POOL). The Deployment and backfill carry it in their manifests; synthesis Jobs get it from the receiver, which readsNODE_POOLitself. The job template keeps an emptynodeSelectorso this cluster's pool is never baked into a template every future Job is stamped from — andrender.shrefuses to render if it ever references the placeholder.Two bugs found while wiring this up
render.shnever defaultedTLS_SECRET, so rendering directly (not viamake) emittedname:in the Gateway'scertificateRef— a Gateway referencing no certificate, silent until the hostname fails. Defaults now exist there and are exported, becauseenvsubstreads only the environment.test.shasserts no field renders empty.TLS_SECRETpassed by hand.The backfill is no longer part of
make deploykubectl applycreates-or-updates, so while the backfill Job was a kustomize resource every deploy (and everymake diff) recreated it — shipping an unrelated ConfigMap change started a full archive backfill. It happened twice: 221 Jobs from a deploy, and again frommake backfill's own double-apply workaround, which existed only because apply kept recreating the Job.base/backfill.yamlis out of the kustomization and carries its own node-pool selector (overlay/node-pool-backfill.yamldeleted).render.shemits it only underWITH_BACKFILL=1, mirroringWITH_GATEWAY; onlymake backfillsets it.make deploypinsWITH_BACKFILL=0explicitly, so the exclusion is a written decision, not a default that can drift.make backfilldeletes the old Job then applies — a Job's pod template is immutable, so this replaces the double-apply and makeswaittrack the run you just started.test.shasserts both directions, verified by re-adding the file to the kustomization. A server-side dry-run of the new deploy path against the live cluster now reports no changes at all.Correction
The README claimed "~8k chars/s of CPU, so 1–2 minutes per post", while the same document's measured throughput is 8 chars/s. A 9k article is ~19 minutes; a hundred posts is most of a day queued one at a time — not "a couple of hours".
Verification
Against the live cluster:
{"result":"ok","scanned":221,"eligible":221,"created":221,"failed":0}— previouslycreated:0, failed:221{"result":"ok","created":10,"skipped":211,"failed":0}, confirming idempotencydeploy/tts-audio/test.sh✅ (84 worker tests, incl. 5 new node-selector tests)yarn verify✅ (97 theme tests)Each new guard was checked against an injected regression, not just observed passing.
Deploying this
Important
The image is built from
main, so the manifests in this PR are already applied but thereceiver still runs the old code. Synthesis Jobs are being created — the egress fix
works — but they only get the node selector once a receiver built from this branch runs.
Redeploy with the new 12-char SHA after merge.
Follow-up: backfill jobs are queued but cannot schedule
A separate, pre-existing capacity issue surfaced once the Jobs could actually be created.
It is not fixed here, deliberately:
Pending:0/2 nodes are available: 1 Insufficient cpuVerified that lowering
requests.cputo1lets a Job schedule and complete; the limitcan stay at 4, since requests are what the scheduler books. The node also caps pods at 110,
so 221 Jobs can never all be resident.
Documented in the runbook and the ADR rather than tuned here: the right request depends on
the pool being deployed to, and halving it silently would contradict the throughput numbers
in the same document. Worth deciding explicitly — lower the request, add capacity, or both.