Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
✅ Deploy Preview for cerulean-figolla-1f9435 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 55654c807d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Fixes envoyproxy#10267 Signed-off-by: SaiPisey2 <piseysai0202@gmail.com>
Signed-off-by: SaiPisey2 <piseysai0202@gmail.com>
Signed-off-by: SaiPisey2 <piseysai0202@gmail.com>
b477cfa to
034bb77
Compare
erikdeweerdt
left a comment
There was a problem hiding this comment.
Thanks for this, it's the fix we were hoping for. A few points:
- Backoff cap. A controller that holds the leader lease starts translating as soon as the API server answers again. Any policy translated before the cache comes up keeps the 500 direct response until the replay. With a 30 s cap, that window can approach 30 s after the Secret becomes readable during a longer outage. Could the cap be a few seconds instead? Or could the retry also run as soon as the provider sees the
envoy-oidc-hmacSecret, which it already watches? - Log message. A failed start used to log
failed to start wasm cache; it now logsfailed to load wasm cache TLS config, retrying. Anyone alerting on the old line loses that signal. Keeping the old wording in the retry message, or noting the change in the release note, would avoid that. failOpenwhile retrying.buildWasmsstill returnswasm cache is not initializedbefore it looks atfailOpen. So afailOpen: truepolicy still gets the 500 direct response during the retry window, unlike a module fetch failure. Fine as a follow-up, but worth a line in the PR or the release note if it's out of scope.
The replay in retranslateOnWasmCacheReady looks right to me. A snapshot that arrives after the cache is ready is forwarded without a replay, and the deep copy keeps the translator off the original values.
Signed-off-by: SaiPisey2 <piseysai0202@gmail.com>
|
@erikdeweerdt thanks for the review. Lowered the cap to 5s and put the old |
|
LGTM; thanks! |
|
@zirain could you approve the CI workflows when you get a chance? They're waiting on approval for d893547, and @erikdeweerdt has signed off on the changes. |
|
@zhaohuabing could you approve the CI run and take a look? It has an LGTM from @erikdeweerdt and merges cleanly. |
| // is ready, it replays the latest state so that resources translated without the | ||
| // cache, such as EnvoyExtensionPolicies with HTTP or Image Wasm sources, recover | ||
| // without waiting for an unrelated resource change. | ||
| func (r *Runner) retranslateOnWasmCacheReady( |
There was a problem hiding this comment.
Could we just hold off translation until the Wasm cache is ready? It's required infra like the rate limit service.
There was a problem hiding this comment.
I tried it. Holding off translation until the cache starts is simpler and drops the replay goroutine. One catch before I push it.
On Kubernetes, if envoy-oidc-hmac can never be read, translation never starts. That happens if the secret is missing (certgen hooks skipped), RBAC denies get on it, or the client config fails. No Gateway status, no xDS for new Envoy pods, and only an error log every 5s. I reproduced it in a unit test: nothing translated after 12s. On main the same case only rejects Wasm HTTP/Image policies, and the provider also treats a missing HMAC secret as non-fatal.
Which would you prefer?
- Hold off with no limit, as you suggested, and document that the HMAC secret is now required for any translation.
- Hold off for a bounded time (say 30s). After that, translate without the cache and keep retrying, then translate again once the cache starts. This keeps the replay from the current version.
I lean towards 2, but I'm happy to go with 1 if you see the secret as required anyway.
There was a problem hiding this comment.
Thanks for trying it. Either option fixes the outage we hit:
- With option 1, proxies that already have config keep serving it while translation waits, so routes behind a fail-closed Wasm policy never get the 500 direct response.
- With option 2, the same holds for outages shorter than the hold. After a longer one, the 500s last only until the next retry and the replay.
What I'd avoid is option 1's failure mode for installs that use no HTTP or Image Wasm source at all. An unreadable envoy-oidc-hmac doesn't affect them today; with option 1 it would stop all translation, with only a log line to show for it. (We run a startup probe on the Wasm cache port, so for us a cache that never starts becomes a visible restart loop, but the default chart has nothing like that.)
So I'd go with option 2, or with option 1 only when some EnvoyExtensionPolicy uses an HTTP or Image Wasm source, if that's easy to tell at that point. Either way, please keep failed to start wasm cache in the retry log.
There was a problem hiding this comment.
Let's go with option 1. A short API server error is covered by the retry. A long one fails the liveness probe and restarts the pod, which reads the secret again. That leaves an install error as the only way it stays stuck, and that should fail loudly. Please keep failed to start wasm cache in the retry log.
There was a problem hiding this comment.
Done in 92b6abc. Translation now waits for the Wasm cache, and the replay goroutine is gone. The retry log still says failed to start wasm cache, retrying. A provider with no TLS config for the cache (neither Kubernetes nor host) skips the wait. The release note says the HMAC secret must be readable before anything is translated. Thanks @erikdeweerdt for the startup-probe context.
Signed-off-by: SaiPisey2 <piseysai0202@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10337 +/- ##
==========================================
+ Coverage 82.82% 82.86% +0.03%
==========================================
Files 279 279
Lines 44665 44703 +38
==========================================
+ Hits 36993 37041 +48
+ Misses 7671 7661 -10
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| // The Wasm cache is required to translate EnvoyExtensionPolicies with HTTP | ||
| // or Image Wasm sources, so hold off translation until it has started. | ||
| // Updates received meanwhile are coalesced by the subscription. | ||
| select { | ||
| case <-r.wasmCacheDone: | ||
| default: | ||
| r.Logger.Info("waiting for the wasm cache to start before translating resources") | ||
| <-r.wasmCacheDone | ||
| } |
There was a problem hiding this comment.
This wait ends only when startWasmCache returns, and with the retry loop it may never return. For example, if the envoy-oidc-hmac secret is missing, EG keeps retrying, nothing gets translated, and the pod still looks healthy. The Wasm cache is infra EG depends on, so I'd rather fail loudly than wait quietly.
How about calling startWasmCache from Start before the translation goroutine starts, with a time-limited retry for brief API server outages, and returning its error? startRunners already exits when a runner's Start returns an error, so the pod would crash-loop with the cause in the logs. That also keeps translation from seeing a nil cache, so wasmCacheDone wouldn't be needed.
There was a problem hiding this comment.
Done in 95e85dc. Start starts the cache before the translation goroutine and returns the error if it can't, so wasmCacheDone is gone. On Kubernetes it retries for up to 30s and logs failed to start wasm cache, retrying. Host mode doesn't retry, since the secret is a local file. That also keeps TestCustomProviderFailedToStart at 0.2s instead of 30s. A shutdown during the retries returns nil, not a startup error.
Two side effects, both in the PR description:
- Runners start in order, so xds, infra, admin and metrics come up as much as 30s later while it retries.
/healthzcomes from the provider, so the probes don't notice. - Installs where the controller can't read
envoy-oidc-hmacnow crash-loop. I think that includeswatch.type=Namespaceswith an explicit list, because the chart grants no secret read in the controller namespace there. I haven't checked it on a cluster. Should the chart add that read?
Signed-off-by: SaiPisey2 <piseysai0202@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 95e85dc52c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // The Wasm cache is required to translate EnvoyExtensionPolicies with HTTP or | ||
| // Image Wasm sources, so start it before translating anything. If it cannot | ||
| // be started, fail so the error shows up as a restarting pod. | ||
| if err := r.startWasmCache(ctx); err != nil { |
There was a problem hiding this comment.
Keep pods unready until blocked xDS startup completes
When envoy-oidc-hmac is missing but the Kubernetes provider cache syncs normally, this synchronous wait blocks the sequential runner loop before xdsrunner is started (internal/cmd/server.go:232-256,331-337). The provider has already brought up /readyz, whose only check is cache sync (internal/provider/kubernetes/kubernetes.go:396-398), so the pod can become a ready endpoint for the Service's ports 18000/18002 while neither xDS nor the Wasm listener exists, for as long as the 30-second retry (and on every restart if the secret stays absent). Connections can then be routed to a connection-refusing pod; keep readiness false until this startup step and the downstream listeners complete.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This is an existing issue: /readyz only checks the informer cache sync, not whether the xDS and Wasm listeners are up. This PR makes the gap longer, but the real fix is to make /readyz report ready only once EG can actually serve proxies. Let's handle that in a follow-up.
|
Thanks @zhaohuabing! The red checks look unrelated to this change. |
Yes, they're unrelated. Could you please merge main and fix the conflicts? |
|
/retest |
What this PR does / why we need it:
startWasmCachecalledloadTLSConfigonce. If the HMAC secret could not be read at that moment (a transient API error, or the secret not created yet), it loggedfailed to start wasm cacheand returned, so the cache stayed nil and every EnvoyExtensionPolicy with an HTTP or Image Wasm source was rejected withwasm cache is not initializeduntil the controller restarted.Startnow starts the Wasm cache before the translation goroutine, so translation never sees a nil cache.loadTLSConfigis retried with backoff (1s doubling to a 5s cap) for up to 30s, which covers a brief API server outage. Each retry logsfailed to start wasm cache, retrying. In host mode the HMAC secret and certs are local files, so there is no retry.Startreturns the error.startRunnersthen stops the runners already started and the controller exits, so a missing or unreadableenvoy-oidc-hmacshows up as a restarting pod with the cause in the logs. A shutdown during the retries is not reported as a failure.Behaviour changes to be aware of:
envoy-oidc-hmacnow crash-loop instead of only rejecting HTTP/Image Wasm policies. For example: the certgen hook is skipped, or (unverified, needs a cluster)watch.type=Namespaceswith an explicit namespace list, where the chart grants no secrets read in the controller namespace.Startretries, the xds, infra, admin and metrics runners start up to 30s later. Running proxies keep their config./healthzis served by the provider, so the startup and liveness probes are not affected.Tested on kind (with an earlier version of this branch; the unit tests below cover the current one) with the controller built from
mainand from this branch: deleteenvoy-oidc-hmac, restart the controller, restore the secret 20s later.Accepted=False,wasm cache is not initializedAccepted=True~8s laterTestWasmPolicyAcceptedWhenSecretArrivesDuringStartcovers the transient case throughRunner.Start: the secret appears during the retries and the policy is accepted.TestStartFailsWhenWasmCacheCannotStartcovers the permanent case. Both fail onmain.Not changed here: while the cache is not started, a policy with
failOpen: trueis still rejected, because thewasm cache is not initializedcheck runs beforefailOpenis looked at. That was already the case before this PR and could be a follow-up.Which issue(s) this PR fixes:
Fixes #10267
PR Checklist
git commit -s). See DCO: Sign your work.make generate gen-check,make lint, and the unit-test/coverage build pass. (Flaky e2e failures are not considered breakages, butgen-check,lint, and coverage MUST pass.)release-notes/current/<section>/<pr-number>-<slug>.md(seerelease-notes/current/README.mdfor sections and naming). N/A if this PR does not contain non-trivial changes.release-notes/current/breaking_changes/.