Skip to content

ci(charts): a helm gate, and the selector check no schema could make - #452

Merged
athvin merged 1 commit into
mainfrom
bm/bluegreen-p4-chart-gate
Nov 5, 2026
Merged

athvin merged 1 commit into
mainfrom
bm/bluegreen-p4-chart-gate

Conversation

@athvin

@athvin athvin commented Nov 3, 2026

Copy link
Copy Markdown
Owner

There was no chart validation at all — zero hits for helm lint, helm template or kubeconform across every workflow — while images.yml triggers on infra/k8s/** and deploys chart changes straight into the ci namespace. The first thing to evaluate a chart edit was the cluster. plan-to-aws.md has listed this as unfinished since Phase 2.

Three steps of the ordinary kind

helm lint, then helm template + kubeconform -strict over three profiles — the dev default, the kind profile (web.enabled: false, so no BFF container and no drizzle hook), and the namespace chart. Three, because a template guarded by an if is unchecked in every profile that disables it.

Both renders force ingress.enabled=true and webIngressFromVpc.enabled=true. The objects worth checking are exactly the ones that don't exist until someone enables the edge — which is when nobody is reading this file.

And one step none of those can do

helm lint, helm template and kubeconform all answer "is each document well-formed". None answers:

does this selector match any pod that exists?

allow-alb-to-web's podSelector said app.kubernetes.io/name: er-web, from when the BFF was its own Deployment. After the pods were merged the only pod carries name: web-api, so the policy matched nothing — and default-deny-ingress would have blackholed the ALB the first time ingress.enabled was flipped. Every document was valid YAML, valid against the Kubernetes schema and lint-clean. It was wrong for weeks. No single-chart check could have seen it either: the policy is in er-dev-namespace and the pod it selects is in er-platform.

So scripts/ci/charts-check.py renders both and intersects them — generalised to the bug class rather than the one instance, because the colour dimension is about to add selectors meant to resolve to different pods and the same mistake would be invisible again:

  1. every Service selector matches at least one rendered pod
  2. every NetworkPolicy podSelector matches at least one rendered pod (an empty selector is default-deny-ingress's deliberate all-pods form, not a finding)
  3. the ALB ingress hole does not open the control plane's port

(3) is a security property rather than a correctness one. §4.1 says "er-api is on no load balancer in any environment"; after the pod merge that holds only because the hole is port-scoped, since the selector necessarily matches a pod that also serves er-api on 8000. A reviewer widening the port list would quietly publish the control plane and nothing else in the tree would notice.

Observed failing in all three directions before being trusted

state result
against main before #443 exit 1, naming allow-alb-to-web as matching no pod
with #443's fix exit 0
pod kind renamed so it examines nothing exit 2, refusing to report success

The third is the property every gate here needs, and the reason the second isn't enough on its own.

charts-check FAILED:
  - NetworkPolicy/allow-alb-to-web podSelector {'app.kubernetes.io/name': 'er-web'}
    matches NO pod — the rule is inert, and with default-deny-ingress in the same
    namespace whatever it was meant to admit is blackholed

That run is why this PR is rebased on top of #443 rather than independent of it: the gate was written before the fix, found the fix's bug on its own, and goes green on the merge after.

Wiring notes, each a rule rather than a preference

  • Gated on its own charts detect output, not on infra: a chart edit must not trigger terraform plan, and a terraform edit must not pay for a render. Same allowlist direction and the same grep -c (never -q, which can SIGPIPE git diff under pipefail into a flaky false skip). Both of detect's early-exit paths now set charts too — an unset output reads as false and would silently skip the gate on exactly the fail-safe path that exists to avoid silence.
  • No paths: filter, because this workflow's jobs are required checks and a workflow a path filter skips never reports.
  • Not a required check in this PR, and that order isn't optional: a job's name: is its branch-protection context, so adding a context for a job that has never reported green on main leaves every PR pending forever. Land it, watch it report, then require it.
  • helm and kubeconform install from version-pinned tarballs rather than third-party actions — the choice images.yml's helm install documents. PyYAML is installed explicitly rather than assumed present, so a missing dependency fails at a named step instead of becoming an import error inside a script.
  • The generated ci-and-supply-chain/references/required-checks.md is regenerated in the same commit, since adding a workflow job makes it stale and its drift check runs inside the required fmt + clippy + docs job.

Verification

  • make check green.
  • The gate run locally in all three states above.
  • kubeconform reports 15 valid / 2 skipped on the dev profile; the skips are the ExternalSecret CRD, which has no published schema. That's a real gap — a typo in a CRD's kind would be skipped rather than caught — which is why the step prints the skipped count rather than hiding it, and why the selector gate checks relationships no schema could express anyway.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

terraform plan

60a6364 · run log and full plans

env add change destroy
state-backend (plan only) 0 0 0
core 0 0 0
dev 0 0 0
prod 0 0 0

Planned with -refresh=false, so this is the config-versus-state diff and
not out-of-band drift. That is a security choice, not a speed one: a refreshing
plan reads secret values, and the plan role is assumable from any PR branch —
which can edit the workflow it runs under. Drift is caught at apply time, which
refreshes fully.

There was no chart validation at all — zero hits for `helm lint`,
`helm template` or `kubeconform` across every workflow — while `images.yml`
triggers on `infra/k8s/**` and deploys chart changes straight into the `ci`
namespace. The first thing to evaluate a chart edit was the cluster.
plan-to-aws.md has listed this as unfinished since Phase 2.

Three steps of the ordinary kind — `helm lint`, then `helm template` +
`kubeconform -strict` over THREE profiles (the dev default, the kind profile
where `web.enabled: false` removes the BFF container and the drizzle hook, and
the namespace chart), because a template guarded by an `if` is unchecked in
every profile that disables it.

**And one step none of those can do.** `helm lint`, `helm template` and
`kubeconform` all answer "is each document well-formed". None answers:

    does this selector match any pod that exists?

`allow-alb-to-web`'s `podSelector` said `app.kubernetes.io/name: er-web`, from
when the BFF was its own Deployment. After the pods were merged the only pod
carries `name: web-api`, so the policy matched NOTHING and the namespace's
`default-deny-ingress` would have blackholed the ALB the first time
`ingress.enabled` was flipped on. Every document was valid YAML, valid against
the Kubernetes schema and lint-clean. It was wrong for weeks. No single-chart
check could have seen it either: the policy is in `er-dev-namespace` and the pod
it selects is in `er-platform`.

So `scripts/ci/charts-check.py` renders both and intersects them, generalised to
the bug CLASS rather than the one instance — because the colour dimension is
about to add selectors meant to resolve to different pods, and the same mistake
would be invisible again:

1. every Service selector matches at least one rendered pod
2. every NetworkPolicy podSelector matches at least one rendered pod
   (an empty selector is `default-deny-ingress`'s deliberate all-pods form, not
   a finding)
3. the ALB ingress hole does NOT open the control plane's port

(3) is a security property rather than a correctness one. §4.1 says "er-api is
on no load balancer in any environment"; after the pod merge that holds only
because the hole is PORT-scoped, since the selector necessarily matches a pod
that also serves er-api on 8000. A reviewer widening the port list would
quietly publish the control plane and nothing else in the tree would notice.

Both renders force `ingress.enabled=true` and `webIngressFromVpc.enabled=true`.
The objects worth checking are exactly the ones that do not exist until someone
enables the edge — which is when nobody is reading this file.

**Observed failing in all three directions before being trusted:**

| state | result |
|---|---|
| against `main` today | exit 1, naming `allow-alb-to-web` as matching no pod |
| with the fix from the selector PR applied | exit 0 |
| pod `kind` renamed, so it examines nothing | exit **2**, refusing to report success |

The third is the property every gate here needs and the reason the second one
is not enough on its own.

Wiring notes, each of which is a rule rather than a preference:

- Gated on its own `charts` detect output, not on `infra`: a chart edit must not
  trigger `terraform plan`, and a terraform edit must not pay for a render. Same
  allowlist direction and the same `grep -c` (never `-q`, which can SIGPIPE
  `git diff` under `pipefail` into a flaky false skip). Both of detect's
  early-exit paths now set `charts` too — an unset output reads as `false` and
  would silently skip the gate on exactly the fail-safe path that exists to
  avoid silence.
- No `paths:` filter, because the workflow's jobs are required checks and a
  workflow a path filter skips never reports.
- **NOT a required check in this PR**, and that order is not optional: a job's
  `name:` IS its branch-protection context, so adding a context for a job that
  has never reported green on `main` leaves every PR pending forever. Land it,
  watch it report, then require it.
- helm and kubeconform install from version-pinned tarballs rather than
  third-party actions, the choice `images.yml`'s helm install documents; PyYAML
  is installed explicitly rather than assumed present, so a missing dependency
  fails at a named step instead of becoming an import error inside a script.

This PR's gate is RED until the selector fix lands — that is the point, and the
honest demonstration. It goes green on the merge after.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants