Skip to content

fix: read live status before update comparison#9509

Open
Aias00 wants to merge 2 commits into
envoyproxy:mainfrom
Aias00:worktree-issue-9432-programmed-recovery
Open

fix: read live status before update comparison#9509
Aias00 wants to merge 2 commits into
envoyproxy:mainfrom
Aias00:worktree-issue-9432-programmed-recovery

Conversation

@Aias00

@Aias00 Aias00 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • read the current object through the uncached API reader before comparing status updates
  • keep status writes on the controller-runtime client while avoiding stale informer cache comparisons
  • add a regression test for stale cached Gateway status skipping a required Programmed recovery update

Test Plan

  • go test ./internal/provider/kubernetes ./internal/gatewayapi/status -count=1
  • git diff --check

Fixes #9432

Copilot AI review requested due to automatic review settings July 15, 2026 22:48
@Aias00
Aias00 requested a review from a team as a code owner July 15, 2026 22:48
@netlify

netlify Bot commented Jul 15, 2026

Copy link
Copy Markdown

Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit dc92ebf
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6a58f0cb5fca7d0008b1868d
😎 Deploy Preview https://deploy-preview-9509--cerulean-figolla-1f9435.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a Kubernetes provider status-update edge case where comparing against a stale informer-cached object could incorrectly skip a required Gateway status update (e.g., Programmed recovery), by reading the live object from the API server before doing the status equality comparison.

Changes:

  • Inject a statusReader into the status UpdateHandler and use it to Get the current object before comparing status updates.
  • Wire the provider to pass mgr.GetAPIReader() to avoid stale cache reads during status comparison.
  • Add a regression test ensuring a stale cached Gateway status does not prevent a required Programmed recovery update.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
internal/provider/kubernetes/status_updater.go Adds an API-reader-based fetch path for status comparisons to avoid stale cache skipping updates.
internal/provider/kubernetes/status_updater_test.go Adds a regression test that exercises the stale-cache comparison scenario and asserts a status write occurs.
internal/provider/kubernetes/kubernetes.go Wires mgr.GetAPIReader() into the status update handler construction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +100 to +103
// Get the resource directly from the API server when available. Using the
// informer-backed client here can compare against stale status and skip a
// required status update.
if err := u.statusReader.Get(context.Background(), update.NamespacedName, obj); err != nil {

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab81d3505c

ℹ️ 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".

Comment on lines +100 to +103
// Get the resource directly from the API server when available. Using the
// informer-backed client here can compare against stale status and skip a
// required status update.
if err := u.statusReader.Get(context.Background(), update.NamespacedName, obj); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add release note for status bug fix

This change is a user-visible bug fix for stale Gateway status updates, but I checked release-notes/current and there is no fragment for it. release-notes/current/README.md requires bug fixes to add a new file under release-notes/current/bug_fixes/, so this fix would be omitted from the next release notes unless a fragment such as 9432-...md is added.

Useful? React with 👍 / 👎.

@Aias00
Aias00 force-pushed the worktree-issue-9432-programmed-recovery branch 2 times, most recently from 469d75c to fbc7846 Compare July 15, 2026 22:52
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.41%. Comparing base (a16d887) to head (dc92ebf).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9509      +/-   ##
==========================================
- Coverage   75.43%   75.41%   -0.03%     
==========================================
  Files         252      252              
  Lines       41641    41644       +3     
==========================================
- Hits        31411    31404       -7     
- Misses       8098     8106       +8     
- Partials     2132     2134       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: liuhy <liuhongyu@apache.org>
@Aias00
Aias00 force-pushed the worktree-issue-9432-programmed-recovery branch from fbc7846 to 18e7837 Compare July 15, 2026 23:33
@Aias00

Aias00 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

/retest

Comment on lines +64 to +66
if statusReader == nil {
statusReader = client
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like this is only needed for the tests to pass? Can we pass a non-nil reader there instead?

@jukie jukie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM with 1 nit

// Get the resource directly from the API server when available. Using the
// informer-backed client here can compare against stale status and skip a
// required status update.
if err := u.statusReader.Get(context.Background(), update.NamespacedName, obj); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

will this increase the likelihood of getting ratelimited by the API server ?

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.

Gateway status stays Programmed=False even after deployment recovers

4 participants