Skip to content

fix(egress-enforcement-check): retry probe to tolerate standard-mode CNI reconciliation window - #276

Merged
saadqbal merged 2 commits into
developfrom
fix/egress-enforcement-standard-mode-retry
Jun 24, 2026
Merged

fix(egress-enforcement-check): retry probe to tolerate standard-mode CNI reconciliation window#276
saadqbal merged 2 commits into
developfrom
fix/egress-enforcement-standard-mode-retry

Conversation

@saadqbal

@saadqbalsaadqbal commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What

Fixes the SECURITY §8.2 egress-lockdown enforcement helm test (egress-enforcement-check) false-negative on standard-mode CNI clusters — notably AWS VPC CNI with NETWORK_POLICY_ENFORCING_MODE=standard.

Closes#275. Follow-up to tracebloc/client-runtime#104; unblocks the per-fleet rollout gate for tracebloc/client-runtime#102.

Why

standard mode allows a brand-new pod all traffic until its per-pod policy reconciles (a few-second startup window). The probe curled the canary host immediately on startup, won that race, connected, and reported EGRESS LOCKDOWN NOT ENFORCED — even though the lockdown is enforced for real training pods (which start far slower than the window). Both dev (tb-client-dev-templates) and prod (tracebloc-clients-prod) run AWS VPC CNI in standard mode, so as-is the gate would false-fail on every fleet and could mislead an operator into thinking the lockdown is broken.

Change

  • Retry-until-blocked — the probe loops until egress is observed blocked (curl exit 7/28 → PASS), bounded by a new networkPolicy.training.enforcementProbeTimeoutSeconds (default 60s); FAILs only if the host stays reachable for the whole timeout. Correct on standard mode, strict mode, and genuinely non-enforcing clusters alike.
  • Docs — refreshed the stale values.yaml CNI guidance: AWS VPC CNI does enforce with enableNetworkPolicy=true (the prior comment claimed it doesn't).
  • Tests — +2 helm-unittest cases (retry loop honours the configurable timeout; default 60s). Full chart suite: 267/267.

Verified on dev (EKS, 2026-06-24)

Applied the lockdown on tb-client-dev-templates and probed from a tracebloc.io/workload=training pod:

  • helm test (old single-shot behaviour) → Failed (probe connected on startup).
  • a training-labelled pod that sleeps 30s then probes → 1.1.1.1:443 and example.com:443blocked (curl exit 28); backend reachable via the squid gateway (exit 0).

So the lockdown works for real pods; only the instant probe raced it. Dev was rolled back to its original state after verification.

Not in scope

standard mode's startup window is itself a narrow egress gap for untrusted pod code; strict mode closes it but is a cluster-wide change — tracked separately as a §8.2 threat-model decision.

🤖 Generated with Claude Code


Note

Low Risk
Changes only the helm test hook script, values docs, and chart tests; no runtime training or NetworkPolicy behavior is modified.

Overview
Fixes false FAIL results on the §8.2 egress-lockdown helm test when the CNI enforces policy only after a short per-pod reconcile (e.g. AWS VPC CNI standard mode).

The egress-enforcement-check probe no longer curls once at startup. It loops (3s between attempts) until curl sees blocked egress (exit 7/28) → PASS, or until networkPolicy.training.enforcementProbeTimeoutSeconds (default 60s) expires while the host stayed reachable → FAIL. A reached latch records any successful TCP connect so a later DNS failure cannot flip a real non-enforcement case to “inconclusive.”

values.yaml documents the new timeout, updates EKS guidance (VPC CNI can enforce with enableNetworkPolicy=true), and refreshes failure-message hints. Helm unittest adds coverage for the retry loop, timeout wiring, and the 60s default.

Reviewed by Cursor Bugbot for commit 5ba4646. Bugbot is set up for automated code reviews on this repo. Configure here.

…CNI reconciliation window
The SECURITY §8.2 egress-lockdown enforcement helm test false-failed on
clusters whose CNI enforces egress NetworkPolicy in "standard" mode —
notably AWS VPC CNI with NETWORK_POLICY_ENFORCING_MODE=standard, which both
the dev and prod fleets use. Standard mode allows a brand-new pod all
traffic until its per-pod policy reconciles (a few-second startup window);
the probe curled the canary host instantly on startup, won that race,
connected, and reported "EGRESS LOCKDOWN NOT ENFORCED" — even though the
lockdown is enforced for real training pods, which start far slower than
the window.
Retry the probe until egress is observed blocked, bounded by a new
networkPolicy.training.enforcementProbeTimeoutSeconds (default 60s): PASS as
soon as the connect is blocked, FAIL only if the host stays reachable for
the whole timeout. Correct on standard mode, strict mode, and genuinely
non-enforcing clusters alike.
Also refresh the stale values.yaml CNI guidance (AWS VPC CNI does enforce
with enableNetworkPolicy=true) and extend helm-unittest (full suite 267 pass).
Verified on dev (EKS, tb-client-dev-templates): a training-labelled pod that
sleeps 30s then probes is blocked on 1.1.1.1:443 and example.com:443, and
reaches the backend via the squid gateway.
Refs #275, tracebloc/client-runtime#104, tracebloc/client-runtime#102.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit db87393. Configure here.

Comment threadclient/templates/egress-enforcement-check.yaml
…NS failure
Bugbot (PR #276): the post-loop inconclusive branch keyed off only the last
curl exit code. If an earlier attempt observed the host reachable (rc=0) but
a later attempt failed DNS (rc=6), the hook reported "inconclusive / no TCP
attempted" instead of "NOT ENFORCED" — a misdiagnosis that could send an
operator chasing DNS when the CNI simply isn't enforcing egress.
Latch a `reached` flag whenever a probe establishes a TCP connection (any curl
exit other than 6) and branch on it after the loop: a connect seen on ANY
attempt yields the definitive NOT-ENFORCED verdict; INCONCLUSIVE is reserved
for the case where no TCP connection ever succeeded. helm-unittest updated.
Refs #275.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@saadqbalsaadqbal self-assigned this Jun 24, 2026
@saadqbal
saadqbal merged commit b587815 into developJun 24, 2026
18 checks passed
saadqbal added a commit that referenced this pull request Jun 24, 2026
Readies the 1.8.1 release, which ships the egress-enforcement-check
standard-mode CNI fix (#276, closes#275): the §8.2 helm-test gate now
retries through the per-pod NetworkPolicy reconciliation window instead of
racing it, so it no longer false-fails on AWS VPC CNI standard mode (the dev
and prod fleets both use it). Validated end-to-end on dev — the patched
`helm test` goes green where the previous instant-probe test failed.
Refs #275.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@saadqbal

Copy link
Copy Markdown
ContributorAuthor

/fr-pass

Functional review passed on dev: the patched egress-enforcement-check helm test goes green on a real standard-mode VPC CNI cluster (tb-client-dev-templates), and a live egress-restriction demo confirmed a training pod's direct external calls are blocked while only the allowlisted backend is reachable via the squid gateway.

saadqbal added a commit that referenced this pull request Jun 24, 2026
…k standard-mode CNI fix) (#278)
* fix(egress-enforcement-check): retry probe to tolerate standard-mode CNI reconciliation window (#276)
* fix(egress-enforcement-check): retry probe to tolerate standard-mode CNI reconciliation window
The SECURITY §8.2 egress-lockdown enforcement helm test false-failed on
clusters whose CNI enforces egress NetworkPolicy in "standard" mode —
notably AWS VPC CNI with NETWORK_POLICY_ENFORCING_MODE=standard, which both
the dev and prod fleets use. Standard mode allows a brand-new pod all
traffic until its per-pod policy reconciles (a few-second startup window);
the probe curled the canary host instantly on startup, won that race,
connected, and reported "EGRESS LOCKDOWN NOT ENFORCED" — even though the
lockdown is enforced for real training pods, which start far slower than
the window.
Retry the probe until egress is observed blocked, bounded by a new
networkPolicy.training.enforcementProbeTimeoutSeconds (default 60s): PASS as
soon as the connect is blocked, FAIL only if the host stays reachable for
the whole timeout. Correct on standard mode, strict mode, and genuinely
non-enforcing clusters alike.
Also refresh the stale values.yaml CNI guidance (AWS VPC CNI does enforce
with enableNetworkPolicy=true) and extend helm-unittest (full suite 267 pass).
Verified on dev (EKS, tb-client-dev-templates): a training-labelled pod that
sleeps 30s then probes is blocked on 1.1.1.1:443 and example.com:443, and
reaches the backend via the squid gateway.
Refs #275, tracebloc/client-runtime#104, tracebloc/client-runtime#102.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(egress-enforcement-check): NOT-ENFORCED verdict outranks a late DNS failure
Bugbot (PR #276): the post-loop inconclusive branch keyed off only the last
curl exit code. If an earlier attempt observed the host reachable (rc=0) but
a later attempt failed DNS (rc=6), the hook reported "inconclusive / no TCP
attempted" instead of "NOT ENFORCED" — a misdiagnosis that could send an
operator chasing DNS when the CNI simply isn't enforcing egress.
Latch a `reached` flag whenever a probe establishes a TCP connection (any curl
exit other than 6) and branch on it after the loop: a connect seen on ANY
attempt yields the definitive NOT-ENFORCED verdict; INCONCLUSIVE is reserved
for the case where no TCP connection ever succeeded. helm-unittest updated.
Refs #275.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* chore(chart): bump client 1.8.0 → 1.8.1 (version + appVersion) (#277)
Readies the 1.8.1 release, which ships the egress-enforcement-check
standard-mode CNI fix (#276, closes#275): the §8.2 helm-test gate now
retries through the per-pod NetworkPolicy reconciliation window instead of
racing it, so it no longer false-fails on AWS VPC CNI standard mode (the dev
and prod fleets both use it). Validated end-to-end on dev — the patched
`helm test` goes green where the previous instant-probe test failed.
Refs #275.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@saadqbal
saadqbal deleted the fix/egress-enforcement-standard-mode-retry branch July 9, 2026 11:41
Sign up for freeto 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.

3 participants

@saadqbal@aptracebloc@LukasWodka