Skip to content

feat: add resourceVersion to Freight, Stage, Warehouse list and watch endpoints#6311

Draft
jacobboykin wants to merge 8 commits into
mainfrom
jacobboykin/resource-version-watch
Draft

feat: add resourceVersion to Freight, Stage, Warehouse list and watch endpoints#6311
jacobboykin wants to merge 8 commits into
mainfrom
jacobboykin/resource-version-watch

Conversation

@jacobboykin
Copy link
Copy Markdown
Member

@jacobboykin jacobboykin commented May 18, 2026

Summary

Supersedes #6156.

This adds resourceVersion-aware list/watch initialization for the large collection streams used by the UI: Stages, Warehouses, Promotions, and Freight via QueryFreight.

The practical effect is that after the UI performs the initial list request, the follow-up watch starts from that list's Kubernetes resourceVersion instead of replaying the same existing resources as individual watch events. This avoids a startup replay storm that can make large project pages and Promotion-heavy stage pages feel frozen.

Implementation

  • Returns resourceVersion values from list/query responses used by follow-up watches.
  • Passes those resourceVersions into the corresponding watch requests.
  • Uses a singleton uncached Kubernetes reader for the list+watch seed endpoints so the returned list resourceVersion is fresh/watchable.
  • Preserves Kargo authorization before bypassing the controller-runtime cache: each direct list is explicitly authorized with the existing authorizing client before the uncached reader is used.
  • Handles filtered watch edge cases where an object leaves a filter by sending a synthetic delete event.
  • Surfaces Kubernetes watch error events cleanly through REST/SSE clients.

Why direct reads here?

The controller-runtime cached client can return list resourceVersion 0, and using the max item resourceVersion from a cached list is not reliable because it can be older than the apiserver watch window. In testing against a real akuity kargo instance, that caused expired-resourceVersion retry loops.

This PR keeps direct reads scoped to the list+watch seed paths where the returned resourceVersion is immediately used to start a watch. The direct reader is constructed once at server startup, not per request.

Performance Testing

This branch removes a major source of duplicate work during UI startup for large projects. After the UI performs its initial list calls, follow-on watch streams now start from the listed resourceVersion instead of replaying every existing object as a fresh watch event. In large-project validation with roughly 1k Stages and 1.3k Freight resources, this avoided about 15.6 MB of duplicate decoded watch payload on project open and reduced graph stabilization time from about 11.6s to 3.9s, a roughly 66% improvement.

The user-facing impact is that large project pages become usable much sooner and avoid the “page is loaded but feels frozen/slow” behavior caused by processing thousands of redundant watch events. In e2e stage-level validation with 1k Promotions, the Promotions page became usable about 4.6s sooner, worst-case hover stalls dropped from nearly 10s to about 65ms, and frame cadence improved from severe frame drops to normal responsiveness. This directly addresses our reported issues where opening large Kargo views or interacting with menus could grind the browser to a halt during initial watch startup.

… endpoints

Signed-off-by: Jesse Suen <[email protected]>
(cherry picked from commit 0a0b864)
@netlify
Copy link
Copy Markdown

netlify Bot commented May 18, 2026

Deploy Preview for docs-kargo-io ready!

Name Link
🔨 Latest commit 1c4d9da
🔍 Latest deploy log https://app.netlify.com/projects/docs-kargo-io/deploys/6a0fabe8cf806900074b72fa
😎 Deploy Preview https://deploy-preview-6311.docs.kargo.io
📱 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.

@kargo-governance-bot kargo-governance-bot Bot added needs/area Issue or PR needs to be labeled to indicate what parts of the code base are affected needs/kind Issue or PR needs to be labeled to clarify its nature needs/priority Priority has not yet been determined; a good signal that maintainers aren't fully committed labels May 18, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

❌ Patch coverage is 78.32168% with 93 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.36%. Comparing base (9de13ee) to head (1c4d9da).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
pkg/server/list_promotions_v1alpha1.go 50.00% 15 Missing and 4 partials ⚠️
pkg/server/watch_helpers.go 71.21% 14 Missing and 5 partials ⚠️
pkg/server/server.go 0.00% 15 Missing and 1 partial ⚠️
pkg/server/query_freights_v1alpha1.go 82.69% 5 Missing and 4 partials ⚠️
pkg/server/list_warehouses_v1alpha1.go 68.18% 5 Missing and 2 partials ⚠️
pkg/server/list_stages_v1alpha1.go 87.75% 3 Missing and 3 partials ⚠️
pkg/server/list_for_watch_seed.go 77.77% 2 Missing and 2 partials ⚠️
pkg/server/watch_promotions_v1alpha1.go 81.25% 1 Missing and 2 partials ⚠️
pkg/server/watch_stages_v1alpha1.go 85.71% 1 Missing and 2 partials ⚠️
pkg/server/watch_warehouses_v1alpha1.go 72.72% 1 Missing and 2 partials ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6311      +/-   ##
==========================================
+ Coverage   58.05%   58.36%   +0.30%     
==========================================
  Files         499      501       +2     
  Lines       41743    42023     +280     
==========================================
+ Hits        24235    24526     +291     
+ Misses      16048    16011      -37     
- Partials     1460     1486      +26     

☔ View full report in Codecov by Sentry.
📢 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs/area Issue or PR needs to be labeled to indicate what parts of the code base are affected needs/kind Issue or PR needs to be labeled to clarify its nature needs/priority Priority has not yet been determined; a good signal that maintainers aren't fully committed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants