Skip to content

TRT-2741: Add per-request BQ/PG toggle for Component Readiness#3825

Open
mstaeble wants to merge 1 commit into
openshift:mainfrom
mstaeble:trt-2741-phase3
Open

TRT-2741: Add per-request BQ/PG toggle for Component Readiness#3825
mstaeble wants to merge 1 commit into
openshift:mainfrom
mstaeble:trt-2741-phase3

Conversation

@mstaeble

@mstaeble mstaeble commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a dataSource query parameter and UI toggle (cookie-based) to switch Component Readiness between BigQuery and PostgreSQL data providers per request
  • Replaces the old PG test status query (CTE-based, per-row variant filtering in Go) with a prefix-sum approach using test_cumulative_summaries, with SQL-level variant grouping via VALUES clause joins
  • Adds GA base window support for the PG path, routing to prow_ga_raw_test_data when the base date range matches a pre-computed GA window (1, 30, or 90 days)
  • Restructures test_details query with a MATERIALIZED CTE to fix planner regression caused by server-level work_mem=128MB setting
  • Changes TestStatus.Variants from []string to map[string]string throughout, with cache unmarshal fallback for the type transition
  • Adds KeyWithVariants.Encode()/DecodeColumnID() using null-byte-separated encoding for deterministic, collision-free map keys
  • Indexes FindOpenRegression lookups by testID for O(1) access instead of linear scan
  • Merges CompareVariants into IncludeVariants for sample queries in cross-compare views
  • Renames DeserializeTestKey to IdentificationFromStatus to reflect actual behavior
  • Default base window changed from 27 to 30 days in the UI to align with GA window definitions

Known parity gaps (BQ vs PG)

These are documented and accepted for this phase:

  • lastFailure not scoped to variant group: PG computes last_failure globally per (test_id, suite_id) across all variants. BQ scopes it per variant group within its GROUP BY. Impact is cosmetic only (display field, not used for regression logic). Fixing requires 3 additional joins inside the LATERAL subquery.
  • lastFailure includes InfraFailure runs: Same LATERAL join does not join prow_job_runs to exclude InfraFailure-labeled runs. BQ excludes them. Same cosmetic impact and same fix path as above.
  • Lifecycle filter gap: BQ applies lifecycle IN ('blocking') per-test in sample queries. PG has no lifecycle column and includes informing-lifecycle tests. Tracked separately.
  • Job scope gap: BQ receives all prow results via BigQuery uploader. PG's prow loader processes only jobs matching config/openshift.yaml.

Test plan

  • go vet ./pkg/api/componentreadiness/... passes
  • make lint passes
  • make test passes (Go + Vitest)
  • make e2e passes
  • Independent code review (isolated sub-agent, no session context)
  • Staging deployment: verify dataSource=postgres returns results for component_readiness and test_details endpoints
  • Staging deployment: verify dataSource=postgres response times are acceptable (<5s for component_readiness, <1s for test_details)
  • Compare BQ vs PG responses for a pinned variant combination (should be near-identical)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added dataSource support to select BigQuery or PostgreSQL for Component Readiness reports, test details, and job-variant lookups.
    • Updated the UI to read the data source from a cookie and propagate it through API requests/links, with URL-safe encoding.
    • Expanded PostgreSQL-backed readiness reporting and test-details enrichment (including variant filtering).
  • Bug Fixes
    • Cache now regenerates when cached payloads can’t be decoded.
    • Component report/test-details keying was made deterministic, improving reliability; improved validation messaging and regression matching.
  • Documentation
    • Added PostgreSQL database tuning guidance.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@openshift-ci

openshift-ci Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 25, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 25, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 25, 2026

Copy link
Copy Markdown

@mstaeble: This pull request references TRT-2741 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Adds a dataSource query parameter and UI toggle (cookie-based) to switch Component Readiness between BigQuery and PostgreSQL data providers per request
  • Replaces the old PG test status query (CTE-based, per-row variant filtering in Go) with a prefix-sum approach using test_cumulative_summaries, with SQL-level variant grouping via VALUES clause joins
  • Adds GA base window support for the PG path, routing to prow_ga_raw_test_data when the base date range matches a pre-computed GA window (1, 30, or 90 days)
  • Restructures test_details query with a MATERIALIZED CTE to fix planner regression caused by server-level work_mem=128MB setting
  • Changes TestStatus.Variants from []string to map[string]string throughout, with cache unmarshal fallback for the type transition
  • Adds KeyWithVariants.Encode()/DecodeColumnID() using null-byte-separated encoding for deterministic, collision-free map keys
  • Indexes FindOpenRegression lookups by testID for O(1) access instead of linear scan
  • Merges CompareVariants into IncludeVariants for sample queries in cross-compare views
  • Renames DeserializeTestKey to IdentificationFromStatus to reflect actual behavior
  • Default base window changed from 27 to 30 days in the UI to align with GA window definitions

Known parity gaps (BQ vs PG)

These are documented and accepted for this phase:

  • lastFailure not scoped to variant group: PG computes last_failure globally per (test_id, suite_id) across all variants. BQ scopes it per variant group within its GROUP BY. Impact is cosmetic only (display field, not used for regression logic). Fixing requires 3 additional joins inside the LATERAL subquery.
  • lastFailure includes InfraFailure runs: Same LATERAL join does not join prow_job_runs to exclude InfraFailure-labeled runs. BQ excludes them. Same cosmetic impact and same fix path as above.
  • Lifecycle filter gap: BQ applies lifecycle IN ('blocking') per-test in sample queries. PG has no lifecycle column and includes informing-lifecycle tests. Tracked separately.
  • Job scope gap: BQ receives all prow results via BigQuery uploader. PG's prow loader processes only jobs matching config/openshift.yaml.

Test plan

  • go vet ./pkg/api/componentreadiness/... passes
  • make lint passes
  • make test passes (Go + Vitest)
  • make e2e passes
  • Independent code review (isolated sub-agent, no session context)
  • Staging deployment: verify dataSource=postgres returns results for component_readiness and test_details endpoints
  • Staging deployment: verify dataSource=postgres response times are acceptable (<5s for component_readiness, <1s for test_details)
  • Compare BQ vs PG responses for a pinned variant combination (should be near-identical)

🤖 Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci

openshift-ci Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mstaeble

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 25, 2026
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The change adds request-scoped data-source selection, deterministic test-key encoding, PostgreSQL component-readiness queries, provider routing, updated report and middleware integration, frontend URL propagation, and related validation and tests.

Changes

Component Readiness data-source and PostgreSQL integration

Layer / File(s) Summary
Contracts and deterministic identity encoding
pkg/apis/api/componentreport/..., pkg/api/componentreadiness/utils/..., pkg/api/utils.go, pkg/util/param/param.go
Request options and test-status identity shapes are updated; variant and column keys use deterministic encoding; URLs and validation use the new contracts.
Provider contracts and PostgreSQL query paths
pkg/api/componentreadiness/dataprovider/..., pkg/db/query/...
Provider methods accept request options, MixedProvider routes by data source, and PostgreSQL adds variant-aware status and test-detail query paths.
Report, server, and frontend propagation
pkg/api/componentreadiness/component_report.go, pkg/sippyserver/server.go, sippy-ng/src/component_readiness/*
Reports, handlers, endpoints, cache keys, and frontend requests propagate the selected data source.
Middleware, test details, cache, and regression integration
pkg/api/cache.go, pkg/api/componentreadiness/middleware/*, pkg/api/componentreadiness/test_details.go, pkg/api/componentreadiness/triage.go
Malformed cache entries regenerate, regression lookup uses an index, and fallback, test-detail, and link generation use encoded identities and data-source values.
CLI and supporting updates
cmd/sippy/*, pkg/dataloader/gateststatus/loader.go, pkg/db/models/prow.go, README.md, docs/database-tuning.md
CLI calls pass request options, date-range resolution is exported, and GA data and PostgreSQL tuning documentation are updated.

Estimated code review effort: 5 (Critical) | ~120 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (8)
pkg/api/componentreadiness/dataprovider/postgres/provider.go (1)

228-241: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Don't warn on ErrRecordNotFound.

A release with no ReleaseDefinition row is an expected miss, not a failure, and this runs on every base-status query — so it will emit a warning per request for those releases. Treat not-found as a plain "no GA window" result and reserve the warning for real query errors.

♻️ Suggested change
 	if err != nil {
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			return false
+		}
 		log.WithError(err).WithField("release", release).
 			Warn("failed to query GA date, falling back to prefix-sum query")
 		return false
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/api/componentreadiness/dataprovider/postgres/provider.go` around lines
228 - 241, Update PostgresProvider.baseMatchesGAWindow to detect the database
not-found error and return false without logging; keep the existing warning for
other query errors, preserving the fallback behavior for all failures.
pkg/api/componentreadiness/dataprovider/postgres/variants.go (1)

102-146: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add unit tests for the group-ID allocation logic.

buildVariantGroupMapping and buildColumnGroupMapping are pure functions with non-trivial invariants: sequential group IDs, synthetic column group IDs starting at len(groupToVariants) (which only holds because the real IDs are dense 0..N-1), and the "call once per map" contract. These are exactly the kind of assumptions that silently break later and corrupt grouped results. Table-driven tests here need no database.

Also note groupToVariants[nextGroupID] = dims stores the same map reference held by variantLookup; if any future caller mutates one, the other changes too. A shallow copy would remove that coupling.

As per coding guidelines, "new Go functions and methods need unit tests".

Also applies to: 160-203

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/api/componentreadiness/dataprovider/postgres/variants.go` around lines
102 - 146, Add table-driven unit tests for buildVariantGroupMapping and
buildColumnGroupMapping, covering sequential dense group IDs, synthetic column
IDs beginning at len(groupToVariants), duplicate grouping, and the requirement
that each mapping is built once per input map. Also copy variant dimension maps
when assigning groupToVariants so returned mappings do not share mutable
references with variantLookup.

Source: Coding guidelines

pkg/api/componentreadiness/dataprovider/mixed/provider.go (1)

36-41: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Centralize Component Readiness data-source constants and make mixed routing fail-safe.

The request docs at pkg/apis/api/componentreport/reqopts/types.go list "postgres"/"bigquery", while routing here and at pkg/api/componentreadiness/test_details.go:440 still uses magic literals. Also, NewMixedProvider always instantiates a postgres.PostgresProvider; route PostgreSQL test queries only when dbc is available (p.pg != nil) or make the constructor/newDataProvider return an error otherwise so PostgreSQL routes do not dereference a nil DB client.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/api/componentreadiness/dataprovider/mixed/provider.go` around lines 36 -
41, Centralize the “postgres” and “bigquery” values in the request-options
constants and reuse them in MixedProvider.providerFor and the routing logic in
test_details.go instead of magic literals. Make NewMixedProvider/newDataProvider
fail safely when no PostgreSQL DB client is available: either skip PostgreSQL
routing when p.pg is nil or return an error during construction, ensuring no
PostgreSQL query dereferences a nil client.
pkg/api/componentreadiness/dataprovider/postgres/cr_queries.go (2)

70-83: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Document the status = 12 literal.

A bare status code is opaque here; a short "why" comment (or a shared constant used elsewhere for failure status) helps future readers.

As per coding guidelines, "Keep comments minimal and helpful, and make them explain the 'why' rather than the 'what'."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/api/componentreadiness/dataprovider/postgres/cr_queries.go` around lines
70 - 83, Document the meaning of the status = 12 predicate in the
lastFailureLateral query by reusing an existing shared failure-status constant
if available, or adding a brief nearby comment explaining why this status
identifies failed runs. Keep the query behavior unchanged and avoid unrelated
documentation.

Source: Coding guidelines


350-358: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Collapse the three SET LOCAL statements into one Exec.

Three round trips with an identical error message add noise without value.

♻️ Suggested consolidation
-		if err := tx.Exec("SET LOCAL max_parallel_workers_per_gather = 4").Error; err != nil {
-			return fmt.Errorf("setting parallel query hints: %w", err)
-		}
-		if err := tx.Exec("SET LOCAL parallel_setup_cost = 0").Error; err != nil {
-			return fmt.Errorf("setting parallel query hints: %w", err)
-		}
-		if err := tx.Exec("SET LOCAL parallel_tuple_cost = 0").Error; err != nil {
-			return fmt.Errorf("setting parallel query hints: %w", err)
-		}
+		// Encourage parallel plans for these wide aggregations.
+		hints := "SET LOCAL max_parallel_workers_per_gather = 4;" +
+			"SET LOCAL parallel_setup_cost = 0;" +
+			"SET LOCAL parallel_tuple_cost = 0"
+		if err := tx.Exec(hints).Error; err != nil {
+			return fmt.Errorf("setting parallel query hints: %w", err)
+		}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/api/componentreadiness/dataprovider/postgres/cr_queries.go` around lines
350 - 358, In the transaction setup flow containing the three parallel-query
hint statements, combine the `SET LOCAL max_parallel_workers_per_gather`,
`parallel_setup_cost`, and `parallel_tuple_cost` commands into a single
`tx.Exec` call. Keep one error check returning the existing “setting parallel
query hints” wrapped error.
pkg/sippyserver/server.go (1)

1021-1022: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract the repeated variant-lookup boilerplate.

The same three lines (reqopts.RequestOptions{DataSource: param.SafeRead(req, "dataSource")} + GetJobVariants + error aggregation) now appear in three handlers. A small helper such as s.jobVariantsForRequest(req) (crtest.JobVariants, error) would keep the data-source plumbing in one place as more callers appear.

Also applies to: 1094-1095, 1147-1148

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/sippyserver/server.go` around lines 1021 - 1022, The repeated job-variant
lookup and error aggregation in the three handlers should be centralized. Add a
server helper such as jobVariantsForRequest using the request context,
crDataProvider, and dataSource extracted via param.SafeRead, then update the
affected handlers to call it while preserving their existing error handling and
outputs.
pkg/api/componentreadiness/test_details.go (2)

439-446: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add test coverage for the new postgres-backfill explanation branch.

internalGenerateTestDetailsReport now emits a distinct user-facing explanation when baseStatus is empty and the data source is postgres, but no test in this batch exercises that branch.

As per path instructions, **/*.{go,tsx,jsx}: "New or modified functionality should include test coverage: new Go functions and methods need unit tests, bug fixes need regression tests."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/api/componentreadiness/test_details.go` around lines 439 - 446, The new
PostgreSQL backfill explanation branch in internalGenerateTestDetailsReport
lacks test coverage. Add a unit test exercising empty baseStatus with
c.ReqOptions.DataSource set to "postgres", and assert the resulting
TestComparison.Explanations contains the expected user-facing explanation;
retain coverage for other data sources or non-empty baseStatus behavior.

439-446: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Shared constants for reqopts DataSource values

DataSource is set from a user request value in pkg/sippyserver/server.go, so routing/comparison points should derive from one shared set instead of string literals. Add exported constants for "bigquery" and "postgres" in pkg/apis/api/componentreport/reqopts and use the non-default provider constant in pkg/api/componentreadiness/dataprovider/mixed/provider.go and similar decision points.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/api/componentreadiness/test_details.go` around lines 439 - 446, Add
exported DataSource constants for the “bigquery” and “postgres” values in the
reqopts package, then replace raw DataSource string literals in test-details and
other routing/comparison points, including the non-default provider logic in
mixed provider.go, with the shared constants. Preserve the existing
provider-selection and explanation behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/api/componentreadiness/dataprovider/bigquery/querygenerators.go`:
- Around line 849-851: Version the cache namespaces in querygenerators.go to
invalidate entries created with the old identity format: bump both
BaseTestStatus~ and SampleTestStatus~ prefixes near the status encoding flow,
and bump both BaseJobRunTestStatusV2~ and SampleJobRunTestStatusV2~ prefixes at
line 1130. Keep the existing cache key structure unchanged apart from the
namespace versions.

In `@pkg/apis/api/componentreport/crtest/types.go`:
- Around line 105-113: Update VariantListToMap and VariantListToMapWithWarnings
in pkg/api/utils.go to split each variant at only the first colon using
strings.Cut, preserving colons in values and round-tripping inputs such as
Label:a:b; add a regression test covering URL generation followed by parsing of
such a value, while preserving consistent HATEOAS client behavior.

---

Nitpick comments:
In `@pkg/api/componentreadiness/dataprovider/mixed/provider.go`:
- Around line 36-41: Centralize the “postgres” and “bigquery” values in the
request-options constants and reuse them in MixedProvider.providerFor and the
routing logic in test_details.go instead of magic literals. Make
NewMixedProvider/newDataProvider fail safely when no PostgreSQL DB client is
available: either skip PostgreSQL routing when p.pg is nil or return an error
during construction, ensuring no PostgreSQL query dereferences a nil client.

In `@pkg/api/componentreadiness/dataprovider/postgres/cr_queries.go`:
- Around line 70-83: Document the meaning of the status = 12 predicate in the
lastFailureLateral query by reusing an existing shared failure-status constant
if available, or adding a brief nearby comment explaining why this status
identifies failed runs. Keep the query behavior unchanged and avoid unrelated
documentation.
- Around line 350-358: In the transaction setup flow containing the three
parallel-query hint statements, combine the `SET LOCAL
max_parallel_workers_per_gather`, `parallel_setup_cost`, and
`parallel_tuple_cost` commands into a single `tx.Exec` call. Keep one error
check returning the existing “setting parallel query hints” wrapped error.

In `@pkg/api/componentreadiness/dataprovider/postgres/provider.go`:
- Around line 228-241: Update PostgresProvider.baseMatchesGAWindow to detect the
database not-found error and return false without logging; keep the existing
warning for other query errors, preserving the fallback behavior for all
failures.

In `@pkg/api/componentreadiness/dataprovider/postgres/variants.go`:
- Around line 102-146: Add table-driven unit tests for buildVariantGroupMapping
and buildColumnGroupMapping, covering sequential dense group IDs, synthetic
column IDs beginning at len(groupToVariants), duplicate grouping, and the
requirement that each mapping is built once per input map. Also copy variant
dimension maps when assigning groupToVariants so returned mappings do not share
mutable references with variantLookup.

In `@pkg/api/componentreadiness/test_details.go`:
- Around line 439-446: The new PostgreSQL backfill explanation branch in
internalGenerateTestDetailsReport lacks test coverage. Add a unit test
exercising empty baseStatus with c.ReqOptions.DataSource set to "postgres", and
assert the resulting TestComparison.Explanations contains the expected
user-facing explanation; retain coverage for other data sources or non-empty
baseStatus behavior.
- Around line 439-446: Add exported DataSource constants for the “bigquery” and
“postgres” values in the reqopts package, then replace raw DataSource string
literals in test-details and other routing/comparison points, including the
non-default provider logic in mixed provider.go, with the shared constants.
Preserve the existing provider-selection and explanation behavior.

In `@pkg/sippyserver/server.go`:
- Around line 1021-1022: The repeated job-variant lookup and error aggregation
in the three handlers should be centralized. Add a server helper such as
jobVariantsForRequest using the request context, crDataProvider, and dataSource
extracted via param.SafeRead, then update the affected handlers to call it while
preserving their existing error handling and outputs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: e5867338-99ed-4e6f-bd14-a60e33f11da2

📥 Commits

Reviewing files that changed from the base of the PR and between 1c5aaf7 and 729e7d7.

📒 Files selected for processing (40)
  • cmd/sippy/annotatejobruns.go
  • cmd/sippy/automatejira.go
  • pkg/api/cache.go
  • pkg/api/componentreadiness/component_report.go
  • pkg/api/componentreadiness/component_report_test.go
  • pkg/api/componentreadiness/dataprovider/bigquery/provider.go
  • pkg/api/componentreadiness/dataprovider/bigquery/querygenerators.go
  • pkg/api/componentreadiness/dataprovider/interface.go
  • pkg/api/componentreadiness/dataprovider/mixed/provider.go
  • pkg/api/componentreadiness/dataprovider/postgres/cr_queries.go
  • pkg/api/componentreadiness/dataprovider/postgres/provider.go
  • pkg/api/componentreadiness/dataprovider/postgres/variants.go
  • pkg/api/componentreadiness/middleware/linkinjector/linkinjector.go
  • pkg/api/componentreadiness/middleware/regressiontracker/regressiontracker.go
  • pkg/api/componentreadiness/middleware/regressiontracker/regressiontracker_test.go
  • pkg/api/componentreadiness/middleware/releasefallback/releasefallback.go
  • pkg/api/componentreadiness/middleware/releasefallback/releasefallback_test.go
  • pkg/api/componentreadiness/queryparamparser_test.go
  • pkg/api/componentreadiness/regressiontracker.go
  • pkg/api/componentreadiness/test_details.go
  • pkg/api/componentreadiness/triage.go
  • pkg/api/componentreadiness/utils/queryparamparser.go
  • pkg/api/componentreadiness/utils/utils.go
  • pkg/api/componentreadiness/utils/utils_test.go
  • pkg/api/utils.go
  • pkg/apis/api/componentreport/crstatus/types.go
  • pkg/apis/api/componentreport/crtest/types.go
  • pkg/apis/api/componentreport/crtest/types_test.go
  • pkg/apis/api/componentreport/reqopts/types.go
  • pkg/dataloader/gateststatus/loader.go
  • pkg/db/models/prow.go
  • pkg/db/query/cumulative_query.go
  • pkg/db/query/feature_gates.go
  • pkg/sippyserver/server.go
  • pkg/util/param/param.go
  • sippy-ng/src/component_readiness/CompReadyUtils.jsx
  • sippy-ng/src/component_readiness/CompReadyVars.jsx
  • sippy-ng/src/component_readiness/ComponentReadiness.jsx
  • sippy-ng/src/component_readiness/ComponentReadinessIndicator.jsx
  • sippy-ng/src/component_readiness/ReleaseSelector.jsx

Comment thread pkg/api/componentreadiness/dataprovider/bigquery/querygenerators.go
Comment thread pkg/apis/api/componentreport/crtest/types.go
@mstaeble
mstaeble force-pushed the trt-2741-phase3 branch 3 times, most recently from b9d39bb to b8c7a98 Compare July 25, 2026 14:48
@mstaeble mstaeble changed the title TRT-2741: Add per-request BQ/PG toggle for Component Readiness [WIP] TRT-2741: Add per-request BQ/PG toggle for Component Readiness Jul 25, 2026

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/database-tuning.md`:
- Around line 8-11: Update the random_page_cost guidance in the document to
explicitly state that the application’s per-session setting overrides the
server-level RDS parameter-group value, and identify the required configuration
operators must change to affect Sippy’s effective value. Ensure the server-level
section is described as applicable only when no session override is set.

In `@pkg/api/componentreadiness/dataprovider/postgres/provider_test.go`:
- Around line 59-98: Update filterByDBGroupBy and its TestFilterByDBGroupBy
cases to accept sets.Set[string] for dbGroupBy instead of map[string]bool.
Remove the conversion from VariantOption.DBGroupBy in provider.go and pass the
set directly, updating test fixtures and assertions to use the existing set API.

In `@pkg/api/componentreadiness/dataprovider/postgres/variants_test.go`:
- Around line 118-127: Strengthen the tests around buildVariantGroupMapping by
asserting the exact valuesClause string and complete groupToVariants contents
for both collapsed and distinct projection cases, not just emptiness and counts.
Add expected mapping data to the relevant test cases and compare the generated
entries against it while preserving the existing validation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: f23b3b2d-5af5-40fc-a7a5-8f3500b85056

📥 Commits

Reviewing files that changed from the base of the PR and between 729e7d7 and b8c7a98.

📒 Files selected for processing (44)
  • README.md
  • cmd/sippy/annotatejobruns.go
  • cmd/sippy/automatejira.go
  • docs/database-tuning.md
  • pkg/api/cache.go
  • pkg/api/componentreadiness/component_report.go
  • pkg/api/componentreadiness/component_report_test.go
  • pkg/api/componentreadiness/dataprovider/bigquery/provider.go
  • pkg/api/componentreadiness/dataprovider/bigquery/querygenerators.go
  • pkg/api/componentreadiness/dataprovider/interface.go
  • pkg/api/componentreadiness/dataprovider/mixed/provider.go
  • pkg/api/componentreadiness/dataprovider/postgres/cr_queries.go
  • pkg/api/componentreadiness/dataprovider/postgres/provider.go
  • pkg/api/componentreadiness/dataprovider/postgres/provider_test.go
  • pkg/api/componentreadiness/dataprovider/postgres/variants.go
  • pkg/api/componentreadiness/dataprovider/postgres/variants_test.go
  • pkg/api/componentreadiness/middleware/linkinjector/linkinjector.go
  • pkg/api/componentreadiness/middleware/regressiontracker/regressiontracker.go
  • pkg/api/componentreadiness/middleware/regressiontracker/regressiontracker_test.go
  • pkg/api/componentreadiness/middleware/releasefallback/releasefallback.go
  • pkg/api/componentreadiness/middleware/releasefallback/releasefallback_test.go
  • pkg/api/componentreadiness/queryparamparser_test.go
  • pkg/api/componentreadiness/regressiontracker.go
  • pkg/api/componentreadiness/test_details.go
  • pkg/api/componentreadiness/triage.go
  • pkg/api/componentreadiness/utils/queryparamparser.go
  • pkg/api/componentreadiness/utils/utils.go
  • pkg/api/componentreadiness/utils/utils_test.go
  • pkg/api/utils.go
  • pkg/apis/api/componentreport/crstatus/types.go
  • pkg/apis/api/componentreport/crtest/types.go
  • pkg/apis/api/componentreport/crtest/types_test.go
  • pkg/apis/api/componentreport/reqopts/types.go
  • pkg/dataloader/gateststatus/loader.go
  • pkg/db/models/prow.go
  • pkg/db/query/cumulative_query.go
  • pkg/db/query/feature_gates.go
  • pkg/sippyserver/server.go
  • pkg/util/param/param.go
  • sippy-ng/src/component_readiness/CompReadyUtils.jsx
  • sippy-ng/src/component_readiness/CompReadyVars.jsx
  • sippy-ng/src/component_readiness/ComponentReadiness.jsx
  • sippy-ng/src/component_readiness/ComponentReadinessIndicator.jsx
  • sippy-ng/src/component_readiness/ReleaseSelector.jsx
🚧 Files skipped from review as they are similar to previous changes (37)
  • pkg/db/query/feature_gates.go
  • pkg/db/models/prow.go
  • pkg/apis/api/componentreport/reqopts/types.go
  • pkg/api/componentreadiness/queryparamparser_test.go
  • sippy-ng/src/component_readiness/ComponentReadiness.jsx
  • pkg/api/componentreadiness/utils/queryparamparser.go
  • pkg/api/componentreadiness/triage.go
  • pkg/api/componentreadiness/regressiontracker.go
  • pkg/api/componentreadiness/middleware/linkinjector/linkinjector.go
  • sippy-ng/src/component_readiness/ComponentReadinessIndicator.jsx
  • pkg/api/utils.go
  • pkg/dataloader/gateststatus/loader.go
  • cmd/sippy/annotatejobruns.go
  • cmd/sippy/automatejira.go
  • pkg/api/componentreadiness/dataprovider/bigquery/querygenerators.go
  • sippy-ng/src/component_readiness/ReleaseSelector.jsx
  • pkg/db/query/cumulative_query.go
  • pkg/util/param/param.go
  • pkg/api/componentreadiness/middleware/releasefallback/releasefallback_test.go
  • pkg/apis/api/componentreport/crstatus/types.go
  • pkg/api/componentreadiness/test_details.go
  • pkg/api/cache.go
  • sippy-ng/src/component_readiness/CompReadyUtils.jsx
  • pkg/api/componentreadiness/dataprovider/interface.go
  • pkg/api/componentreadiness/middleware/regressiontracker/regressiontracker.go
  • pkg/api/componentreadiness/dataprovider/postgres/variants.go
  • pkg/api/componentreadiness/middleware/regressiontracker/regressiontracker_test.go
  • pkg/api/componentreadiness/dataprovider/postgres/cr_queries.go
  • pkg/api/componentreadiness/middleware/releasefallback/releasefallback.go
  • pkg/api/componentreadiness/utils/utils.go
  • sippy-ng/src/component_readiness/CompReadyVars.jsx
  • pkg/sippyserver/server.go
  • pkg/apis/api/componentreport/crtest/types.go
  • pkg/api/componentreadiness/utils/utils_test.go
  • pkg/api/componentreadiness/dataprovider/mixed/provider.go
  • pkg/api/componentreadiness/component_report_test.go
  • pkg/api/componentreadiness/dataprovider/postgres/provider.go

Comment thread docs/database-tuning.md
Comment thread pkg/api/componentreadiness/dataprovider/postgres/provider_test.go
Comment thread pkg/api/componentreadiness/dataprovider/postgres/variants_test.go
Adds a `dataSource` query parameter to the Component Readiness API that
allows switching between BigQuery and PostgreSQL on a per-request basis.
The frontend exposes this as a toggle in the release selector.

PostgreSQL query optimizations:
- Restructure placeholder queries to group at the component level,
  reducing intermediate rows from 1.1M to a few thousand
- Fix GA date query to use First instead of GORM Pluck (which couldn't
  scan a PostgreSQL date column into *time.Time)
- Remove enable_nestloop=off which was catastrophic for LATERAL joins
- Reserve parallel worker hints (max_parallel_workers_per_gather=4,
  parallel_setup_cost=0, parallel_tuple_cost=0) for failure queries
  only, since placeholder queries perform well without them
- Use MATERIALIZED CTE in test_details to force test_id-driven plan
- Extract row scanning into shared scanRows helper

Also fixes variant validation to return HTTP 400 (ValidationError)
instead of 500 for invalid variant parameters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (2)
pkg/sippyserver/server.go (2)

1097-1099: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Preserve the underlying variant-query errors.

Formatting errs with %v discards error unwrapping. Join the returned errors and wrap with %w so callers can retain errors.Is/errors.As behavior. As per coding guidelines, wrap errors with context using fmt.Errorf and %w.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/sippyserver/server.go` around lines 1097 - 1099, Update the error return
in the variant-query path to join errs and wrap the joined error with fmt.Errorf
using %w, preserving the existing “failed to get job variants” context while
retaining errors.Is/errors.As behavior.

Source: Coding guidelines


1095-1096: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid parsing dataSource twice.

Line 1095 calls param.SafeRead(req, "dataSource"), and utils.ParseComponentReportRequest repeats that call at Line 1106. Pass the validated value into the parser (or split parsing) so invalid input is not validated and logged twice. As per path instructions, “Avoid calling the same utility function multiple times with identical arguments in the same code path.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/sippyserver/server.go` around lines 1095 - 1096, Update the request
handling around GetJobVariants and utils.ParseComponentReportRequest to read and
validate dataSource once, then pass the validated value into the parser or split
parsing accordingly. Remove the duplicate param.SafeRead call while preserving
existing validation and logging behavior for invalid input.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pkg/sippyserver/server.go`:
- Around line 1097-1099: Update the error return in the variant-query path to
join errs and wrap the joined error with fmt.Errorf using %w, preserving the
existing “failed to get job variants” context while retaining
errors.Is/errors.As behavior.
- Around line 1095-1096: Update the request handling around GetJobVariants and
utils.ParseComponentReportRequest to read and validate dataSource once, then
pass the validated value into the parser or split parsing accordingly. Remove
the duplicate param.SafeRead call while preserving existing validation and
logging behavior for invalid input.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 948b5f09-6e96-413a-98da-141e0d6e4b85

📥 Commits

Reviewing files that changed from the base of the PR and between b8c7a98 and 0faeda5.

📒 Files selected for processing (44)
  • README.md
  • cmd/sippy/annotatejobruns.go
  • cmd/sippy/automatejira.go
  • docs/database-tuning.md
  • pkg/api/cache.go
  • pkg/api/componentreadiness/component_report.go
  • pkg/api/componentreadiness/component_report_test.go
  • pkg/api/componentreadiness/dataprovider/bigquery/provider.go
  • pkg/api/componentreadiness/dataprovider/bigquery/querygenerators.go
  • pkg/api/componentreadiness/dataprovider/interface.go
  • pkg/api/componentreadiness/dataprovider/mixed/provider.go
  • pkg/api/componentreadiness/dataprovider/postgres/cr_queries.go
  • pkg/api/componentreadiness/dataprovider/postgres/provider.go
  • pkg/api/componentreadiness/dataprovider/postgres/provider_test.go
  • pkg/api/componentreadiness/dataprovider/postgres/variants.go
  • pkg/api/componentreadiness/dataprovider/postgres/variants_test.go
  • pkg/api/componentreadiness/middleware/linkinjector/linkinjector.go
  • pkg/api/componentreadiness/middleware/regressiontracker/regressiontracker.go
  • pkg/api/componentreadiness/middleware/regressiontracker/regressiontracker_test.go
  • pkg/api/componentreadiness/middleware/releasefallback/releasefallback.go
  • pkg/api/componentreadiness/middleware/releasefallback/releasefallback_test.go
  • pkg/api/componentreadiness/queryparamparser_test.go
  • pkg/api/componentreadiness/regressiontracker.go
  • pkg/api/componentreadiness/test_details.go
  • pkg/api/componentreadiness/triage.go
  • pkg/api/componentreadiness/utils/queryparamparser.go
  • pkg/api/componentreadiness/utils/utils.go
  • pkg/api/componentreadiness/utils/utils_test.go
  • pkg/api/utils.go
  • pkg/apis/api/componentreport/crstatus/types.go
  • pkg/apis/api/componentreport/crtest/types.go
  • pkg/apis/api/componentreport/crtest/types_test.go
  • pkg/apis/api/componentreport/reqopts/types.go
  • pkg/dataloader/gateststatus/loader.go
  • pkg/db/models/prow.go
  • pkg/db/query/cumulative_query.go
  • pkg/db/query/feature_gates.go
  • pkg/sippyserver/server.go
  • pkg/util/param/param.go
  • sippy-ng/src/component_readiness/CompReadyUtils.jsx
  • sippy-ng/src/component_readiness/CompReadyVars.jsx
  • sippy-ng/src/component_readiness/ComponentReadiness.jsx
  • sippy-ng/src/component_readiness/ComponentReadinessIndicator.jsx
  • sippy-ng/src/component_readiness/ReleaseSelector.jsx
🚧 Files skipped from review as they are similar to previous changes (37)
  • pkg/api/componentreadiness/queryparamparser_test.go
  • pkg/db/query/feature_gates.go
  • cmd/sippy/automatejira.go
  • sippy-ng/src/component_readiness/ComponentReadinessIndicator.jsx
  • README.md
  • pkg/api/componentreadiness/utils/queryparamparser.go
  • pkg/api/componentreadiness/middleware/linkinjector/linkinjector.go
  • docs/database-tuning.md
  • pkg/util/param/param.go
  • pkg/api/componentreadiness/dataprovider/postgres/provider_test.go
  • pkg/apis/api/componentreport/crtest/types_test.go
  • pkg/apis/api/componentreport/reqopts/types.go
  • pkg/api/componentreadiness/dataprovider/postgres/variants_test.go
  • pkg/api/utils.go
  • pkg/api/componentreadiness/triage.go
  • pkg/api/componentreadiness/dataprovider/interface.go
  • sippy-ng/src/component_readiness/CompReadyUtils.jsx
  • pkg/db/query/cumulative_query.go
  • pkg/api/componentreadiness/middleware/releasefallback/releasefallback.go
  • pkg/api/componentreadiness/dataprovider/bigquery/querygenerators.go
  • pkg/api/componentreadiness/middleware/releasefallback/releasefallback_test.go
  • pkg/apis/api/componentreport/crstatus/types.go
  • pkg/db/models/prow.go
  • pkg/api/componentreadiness/regressiontracker.go
  • pkg/api/componentreadiness/dataprovider/postgres/variants.go
  • pkg/api/componentreadiness/middleware/regressiontracker/regressiontracker.go
  • sippy-ng/src/component_readiness/CompReadyVars.jsx
  • pkg/apis/api/componentreport/crtest/types.go
  • pkg/api/componentreadiness/dataprovider/postgres/cr_queries.go
  • pkg/api/componentreadiness/utils/utils.go
  • pkg/api/componentreadiness/dataprovider/bigquery/provider.go
  • pkg/api/cache.go
  • pkg/api/componentreadiness/middleware/regressiontracker/regressiontracker_test.go
  • pkg/api/componentreadiness/component_report_test.go
  • pkg/api/componentreadiness/component_report.go
  • pkg/api/componentreadiness/utils/utils_test.go
  • pkg/api/componentreadiness/dataprovider/postgres/provider.go

@openshift-ci openshift-ci Bot added the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label Jul 26, 2026
@mstaeble mstaeble changed the title [WIP] TRT-2741: Add per-request BQ/PG toggle for Component Readiness TRT-2741: Add per-request BQ/PG toggle for Component Readiness Jul 26, 2026
@mstaeble
mstaeble marked this pull request as ready for review July 26, 2026 12:32
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 26, 2026
@openshift-ci
openshift-ci Bot requested review from dgoodwin and xueqzhan July 26, 2026 12:33
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e

@mstaeble

Copy link
Copy Markdown
Contributor Author

/test e2e

@openshift-ci

openshift-ci Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

@mstaeble: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants