Skip to content

TRT-1989: model changes to prep for partitioning#3532

Merged
openshift-merge-bot[bot] merged 4 commits into
openshift:mainfrom
neisw:trt-1989-migration-prep
May 20, 2026
Merged

TRT-1989: model changes to prep for partitioning#3532
openshift-merge-bot[bot] merged 4 commits into
openshift:mainfrom
neisw:trt-1989-migration-prep

Conversation

@neisw
Copy link
Copy Markdown
Contributor

@neisw neisw commented May 15, 2026

Model changes include

  • Release and ProwJobRunStartTime for future partitioning
  • ProwJobId for future use to remove join based on ProwJobRunId to get ProwJobId to then get variants

Summary by CodeRabbit

  • Chores

    • Extended schema to persist release and run-timestamp metadata on job runs, run-tests, annotations and related join records; updated migration setup to include the join table.
  • Tests

    • Updated fixtures and synthetic data generation to populate release and timestamp fields for more realistic, time/release-aware test coverage.
  • Documentation

    • Added a partitioning-preparation plan describing denormalization, backfill, phased migration and validation steps.

@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-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 15, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 15, 2026

@neisw: This pull request references TRT-1989 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:

Model changes include

  • Release and ProwJobRunStartTime for future partitioning
  • ProwJobId for future use to remove join based on ProwJobRunId to get ProwJobId to then get variants

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

Walkthrough

This PR adds denormalized partitioning fields (ProwJobRelease, ProwJobRunTimestamp) to Prow models, propagates those values through GCS ingestion and test extraction, updates seeding and test fixtures to populate the new fields, and registers the explicit join-table for migrations. A partitioning prep document is included.

Changes

Prow run and test partitioning fields

Layer / File(s) Summary
Database schema extensions
pkg/db/models/prow.go
ProwJobRun gains ProwJobRelease; ProwJobRunTest gains ProwJobID, ProwJobRunTimestamp, ProwJobRunRelease; ProwJobRunTestOutput gains ProwJobRunTestTimestamp/ProwJobRunTestRelease; ProwJobRunProwPullRequest and ProwJobRunAnnotation gain denormalized release/timestamp fields; ProwJob.Release GORM tag loosened.
Migration wiring
pkg/db/db.go
Register the explicit ProwJobRunProwJobRunProwPullRequest join table with SetupJoinTable and include the join model in AutoMigrate.
GCS data loading pipeline
pkg/dataloader/prowloader/prow.go
processGCSBucketJobRun passes prow job ID, configured release, and run start time into prowJobRunTestsFromGCS; annotations, per-pull PR rows, run-test rows, and test outputs are annotated with release/timestamp; extractTestCases and recursive suite processing carry the context.
Synthetic data seeding
cmd/sippy/seed_data.go
seedRunsForJob now sets ProwJobRelease on seeded ProwJobRun records and populates ProwJobID, ProwJobRunRelease, and ProwJobRunTimestamp on seeded ProwJobRunTest entries.
Test fixture updates
pkg/api/job_runs_test.go, pkg/sippyserver/pr_new_tests_worker_test.go
Unit tests and fake builders updated to set ProwJobRelease on runs and ProwJobID/ProwJobRunRelease on run-test fixtures so tests reflect the new schema.
Partitioning plan document
docs/plans/trt-1989-partitioning-prep.md
New planning doc describing denormalization columns, backfill SQL, migration ordering, and phased partitioning approach.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

lgtm

Suggested reviewers

  • deepsm007
  • petr-muller
🚥 Pre-merge checks | ✅ 15 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Go Error Handling ⚠️ Warning panic() used in non-fatal condition at pkg/dataloader/prowloader/prow.go:1235. Should return error for nil suiteID instead of panicking. Replace panic("synthetic suite is missing from the database") with proper error return, consistent with error-returning function signature.
Test Coverage For New Features ⚠️ Warning Core data loading functions in prow.go (prowJobRunTestsFromGCS, processGCSBucketJobRun, extractTestCases) lack unit test coverage. Modified behavior populates new fields but has no tests. Add unit tests for prowJobRunTestsFromGCS and extractTestCases verifying new parameters (prowJobRelease, prowJobStartTime, prowJobID) are correctly used to populate model fields.
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the main objective of the changeset: adding model changes to prepare for future database partitioning.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Sql Injection Prevention ✅ Passed All DB operations use GORM safe methods. No user input concatenated into SQL. No new SQL injection vulnerabilities.
Excessive Css In React Should Use Styles ✅ Passed Custom check for React CSS styling is not applicable to this PR, which contains only Go backend code and Markdown documentation with zero React components or CSS files.
Single Responsibility And Clear Naming ✅ Passed Fields are appropriately scoped for partitioning prep. Method names are specific, not generic. Field naming is consistent and intentional. Single responsibility principle is maintained.
Stable And Deterministic Test Names ✅ Passed The custom check is for Ginkgo test names. The PR modifies Go test files, but the codebase uses standard Go testing (testing.T), not Ginkgo. Check is not applicable.
Test Structure And Quality ✅ Passed The custom check specifies Ginkgo test requirements (It blocks, BeforeEach, Eventually). The modified tests use Go's standard testing package with table-driven tests, not Ginkgo. Check not applicable.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests are added in this PR. All test files use standard Go unit tests (func TestXxx(t *testing.T)). Check is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests added. PR contains only database model changes and unit test fixture updates using standard Go testing framework, not Ginkgo.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies only backend Go code, database models, and documentation. No Kubernetes manifests, operator code, controllers, or scheduling constraints are introduced. Check not applicable.
Ote Binary Stdout Contract ✅ Passed Not applicable. Sippy is a CLI tool, not an OTE binary. PR has no process-level stdout writes. Test function fmt.Printf calls are framework-captured.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR does not add any new Ginkgo e2e tests. Changed test files are standard Go unit tests using testing.T, not Ginkgo-based. Custom check is not applicable.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot requested review from deepsm007 and sosiouxme May 15, 2026 13:37
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 15, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/db/models/prow.go`:
- Around line 92-99: ProwJobID was added as a denormalized lookup key but lacks
an index; modify the struct field declaration for ProwJobID (the ProwJobID field
in the prow job run tests model) to add a GORM index tag (e.g., include
`gorm:"index"` or a named index) so queries filtering by ProwJobID use an index
rather than causing full table scans.
🪄 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: Enterprise

Run ID: d96f992c-5f51-4c25-a083-71ee5bfd7ce3

📥 Commits

Reviewing files that changed from the base of the PR and between e99b97d and 171fc89.

📒 Files selected for processing (5)
  • cmd/sippy/seed_data.go
  • pkg/api/job_runs_test.go
  • pkg/dataloader/prowloader/prow.go
  • pkg/db/models/prow.go
  • pkg/sippyserver/pr_new_tests_worker_test.go

Comment thread pkg/db/models/prow.go Outdated
Comment on lines +92 to +99
// used for variants
// skips joining on ProwJobRunID just to get ProwJobID
ProwJobID uint
// used for partitioning
ProwJobRunTimestamp time.Time `gorm:"expression:DATE(timestamp AT TIME ZONE 'UTC')"`
// used for partitioning
ProwJobRunRelease string `gorm:"varchar(10)"`
TestID uint `gorm:"index;index:idx_prow_job_run_tests_test_id_status"`
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot May 15, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Index the new denormalized lookup key.

ProwJobID is added to avoid a join, but without an index this can still force full scans on prow_job_run_tests under real data volume.

💡 Suggested fix
-	ProwJobID uint
+	ProwJobID uint `gorm:"index"`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// used for variants
// skips joining on ProwJobRunID just to get ProwJobID
ProwJobID uint
// used for partitioning
ProwJobRunTimestamp time.Time `gorm:"expression:DATE(timestamp AT TIME ZONE 'UTC')"`
// used for partitioning
ProwJobRunRelease string `gorm:"varchar(10)"`
TestID uint `gorm:"index;index:idx_prow_job_run_tests_test_id_status"`
// used for variants
// skips joining on ProwJobRunID just to get ProwJobID
ProwJobID uint `gorm:"index"`
// used for partitioning
ProwJobRunTimestamp time.Time `gorm:"expression:DATE(timestamp AT TIME ZONE 'UTC')"`
// used for partitioning
ProwJobRunRelease string `gorm:"varchar(10)"`
TestID uint `gorm:"index;index:idx_prow_job_run_tests_test_id_status"`
🤖 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/db/models/prow.go` around lines 92 - 99, ProwJobID was added as a
denormalized lookup key but lacks an index; modify the struct field declaration
for ProwJobID (the ProwJobID field in the prow job run tests model) to add a
GORM index tag (e.g., include `gorm:"index"` or a named index) so queries
filtering by ProwJobID use an index rather than causing full table scans.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@coderabbitai, we are only staging the new columns for now and beginning data collection. We will be migrating the tables and backfilling the new columns at a later time. Indexing will be updated then.

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.

@neisw, understood — thanks for the context! A phased approach (stage columns → collect data → migrate/backfill → add indexes) makes sense here. Would you like me to open a follow-up GitHub issue to track adding the index on ProwJobID (and any other partitioning-related indexes) once the migration and backfill are complete?


✏️ Learnings added
Learnt from: neisw
Repo: openshift/sippy PR: 3532
File: pkg/db/models/prow.go:92-99
Timestamp: 2026-05-15T13:46:44.315Z
Learning: In `pkg/db/models/prow.go`, the `ProwJobID`, `ProwJobRunTimestamp`, and `ProwJobRunRelease` fields added to `ProwJobRunTest`, as well as `ProwJobRelease` on `ProwJobRun` and the timestamp/release fields on `ProwJobRunTestOutput`, are being staged in a phased approach: columns are added first for data collection, with table migration, backfill, and index creation deferred to a later PR. Do not flag missing indexes on these new columns as blocking issues.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e

@neisw
Copy link
Copy Markdown
Contributor Author

neisw commented May 18, 2026

@coderabbitai, regarding SQL injection vulnerability in pkg/dataloader/prowloader/prow.go lines 398-399: that code is not touched by this PR. However the effort this PR is a part of will eventually replace that code.

Consider that update along with the one regarding the indexes and update your analysis.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the SQL injection area mentioned
sed -n '385,415p' pkg/dataloader/prowloader/prow.go

# Check the model changes related to indexes
sed -n '1,100p' pkg/db/models/prow.go

Length of output: 4816


@neisw, thanks for the clarification on both points.

SQL injection at pkg/dataloader/prowloader/prow.go lines 398–399:
Acknowledged — that code predates this PR and is untouched here. Since it will be replaced as part of the broader effort this PR belongs to, no action is needed on this PR. Would you like me to open a follow-up GitHub issue to track remediation of that code path, in case it's useful as a reminder before the replacement lands?

Index analysis update:
Looking at the new partitioning fields added in pkg/db/models/prow.go (ProwJobRelease on ProwJobRun, and ProwJobRunTimestamp/ProwJobRunRelease on ProwJobRunTest), the absence of GORM index tags on these is intentional — for partitioned tables, range-based partition pruning on the partition key typically makes separate B-tree indexes on those columns redundant or even counterproductive, and partitioned table indexes are usually managed at the DDL/migration level rather than via GORM struct tags. The ProwJob.Release tag change (dropping varchar(10) while retaining index) also makes sense as GORM defaults to text for string fields, removing the unnecessary size constraint.

I'll update my analysis to reflect that:

  1. The SQL injection in lines 398–399 is pre-existing, out of scope, and planned for replacement.
  2. The lack of index tags on the new partitioning fields is by design for a future-partitioned schema.

✏️ Learnings added
Learnt from: neisw
URL: https://github.com/openshift/sippy/pull/3532

Timestamp: 2026-05-18T17:33:28.470Z
Learning: In the openshift/sippy repository, the SQL injection vulnerability in `pkg/dataloader/prowloader/prow.go` around lines 398-399 (the `partitionSQL` fmt.Sprintf building a DDL statement for test_analysis_by_job_by_dates partitions) is pre-existing code, not modified by PR `#3532` (TRT-1989), and is planned to be replaced by the broader partitioning effort this PR is part of. Do not flag it as a concern on PRs that don't touch it.

Learnt from: neisw
URL: https://github.com/openshift/sippy/pull/3532

Timestamp: 2026-05-18T17:33:28.470Z
Learning: In openshift/sippy, new partitioning fields on `ProwJobRun` (`ProwJobRelease`) and `ProwJobRunTest` (`ProwJobRunTimestamp`, `ProwJobRunRelease`) intentionally have no GORM `index` tags. Partition key columns in PostgreSQL partitioned tables rely on partition pruning rather than B-tree indexes; indexes on these columns are managed at the DDL/migration level, not via GORM struct tags.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/dataloader/prowloader/prow.go (1)

960-991: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Make ProwJobRun and join-row inserts atomic.

ProwJobRun is committed before join rows. If a later join insert fails, you keep partial state and retries can fail on duplicate run ID.

💡 Suggested fix
-	err = pl.dbc.DB.WithContext(ctx).Create(&models.ProwJobRun{
+	err = pl.dbc.DB.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
+		if err := tx.Create(&models.ProwJobRun{
 		Model: gorm.Model{
 			ID: uint(id),
 		},
 		Cluster:        pj.Spec.Cluster,
 		Duration:       duration,
 		ProwJob:        *dbProwJob,
 		ProwJobID:      dbProwJob.ID,
 		ProwJobRelease: dbProwJob.Release,
 		URL:            pj.Status.URL,
 		GCSBucket:      pj.Spec.DecorationConfig.GCSConfiguration.Bucket,
 		Timestamp:      pj.Status.StartTime,
 		OverallResult:  overallResult,
 		TestFailures:   failures,
 		Succeeded:      overallResult == sippyprocessingv1.JobSucceeded,
 		Labels:         labels,
 		Annotations:    annotations,
-	}).Error
-	if err != nil {
-		return err
-	}
-
-	for _, pull := range pulls {
-		if err := pl.dbc.DB.WithContext(ctx).Create(&models.ProwJobRunProwPullRequest{
+		}).Error; err != nil {
+			return fmt.Errorf("create prow job run %d: %w", id, err)
+		}
+
+		for _, pull := range pulls {
+			if err := tx.Create(&models.ProwJobRunProwPullRequest{
 			ProwJobRunID:        uint(id),
 			ProwPullRequestID:   pull.ID,
 			ProwJobRunRelease:   dbProwJob.Release,
 			ProwJobRunTimestamp: pj.Status.StartTime,
-		}).Error; err != nil {
-			return err
+			}).Error; err != nil {
+				return fmt.Errorf("create prow_job_run_prow_pull_request run=%d pr=%d: %w", id, pull.ID, err)
+			}
 		}
-	}
+		return nil
+	})
+	if err != nil {
+		return 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/dataloader/prowloader/prow.go` around lines 960 - 991, Wrap the
ProwJobRun and subsequent ProwJobRunProwPullRequest inserts in a single DB
transaction so they commit or roll back together: use
pl.dbc.DB.WithContext(ctx).Transaction(...) and inside use the transaction
handle (tx) instead of pl.dbc.DB to call Create for models.ProwJobRun and for
each models.ProwJobRunProwPullRequest; return any error from the transaction
callback so a failed join insert rolls back the ProwJobRun and avoids
partial/duplicate state. Ensure you still set the same fields (ID via uint(id),
ProwJob, ProwJobID, etc.) when creating ProwJobRun and reference uint(id) for
ProwJobRunID in the join inserts.
🤖 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/plans/trt-1989-partitioning-prep.md`:
- Line 106: The WHERE clause's operator precedence causes the OR to apply
globally; update the condition in the SQL that uses r.prow_job_id = j.id and
r.prow_job_release so the NULL/empty check is grouped: change the predicate to
require r.prow_job_id = j.id AND (r.prow_job_release IS NULL OR
r.prow_job_release = ''), or equivalently use r.prow_job_release IN (NULL,
'')—apply this change where the WHERE references r.prow_job_id, j.id and
r.prow_job_release.

In `@pkg/db/db.go`:
- Around line 75-79: The call to d.DB.SetupJoinTable(&models.ProwJobRun{},
"PullRequests", &models.ProwJobRunProwPullRequest{}) returns a raw error that is
returned directly; wrap that error with contextual information using fmt.Errorf
and the %w verb before returning so callers get useful migration context (e.g.,
include the operation and involved models/association names when wrapping the
error).

---

Outside diff comments:
In `@pkg/dataloader/prowloader/prow.go`:
- Around line 960-991: Wrap the ProwJobRun and subsequent
ProwJobRunProwPullRequest inserts in a single DB transaction so they commit or
roll back together: use pl.dbc.DB.WithContext(ctx).Transaction(...) and inside
use the transaction handle (tx) instead of pl.dbc.DB to call Create for
models.ProwJobRun and for each models.ProwJobRunProwPullRequest; return any
error from the transaction callback so a failed join insert rolls back the
ProwJobRun and avoids partial/duplicate state. Ensure you still set the same
fields (ID via uint(id), ProwJob, ProwJobID, etc.) when creating ProwJobRun and
reference uint(id) for ProwJobRunID in the join inserts.
🪄 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: Enterprise

Run ID: 00953495-29c0-48a6-90e0-1ea6c64693f0

📥 Commits

Reviewing files that changed from the base of the PR and between 9039e19 and d2ba641.

📒 Files selected for processing (4)
  • docs/plans/trt-1989-partitioning-prep.md
  • pkg/dataloader/prowloader/prow.go
  • pkg/db/db.go
  • pkg/db/models/prow.go

Comment thread docs/plans/trt-1989-partitioning-prep.md Outdated
Comment thread pkg/db/db.go
@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/plans/trt-1989-partitioning-prep.md`:
- Around line 86-89: Update the wording in the migration constraints so the FK
direction is correct: change the phrase "Tables with FKs from `prow_job_runs` to
non-partitioned tables" to express that these are tables with FKs to
`prow_job_runs` (e.g., annotations, pull request join table) — ensure the
sentence reads something like "Tables with FKs to `prow_job_runs` from
non-partitioned tables must either be co-partitioned or have their FKs dropped,"
and verify the examples (`annotations`, `pull request join table`) read as
tables referencing `prow_job_runs`.
🪄 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: Enterprise

Run ID: d54c95ca-5526-45c4-9646-8380aa4b1d3e

📥 Commits

Reviewing files that changed from the base of the PR and between d2ba641 and e6019ef.

📒 Files selected for processing (3)
  • docs/plans/trt-1989-partitioning-prep.md
  • pkg/dataloader/prowloader/prow.go
  • pkg/db/db.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/db/db.go
  • pkg/dataloader/prowloader/prow.go

Comment on lines +86 to +89
3. Tables with FKs **from** `prow_job_runs` to non-partitioned tables
(annotations, pull request join table) must either be co-partitioned
or have their FKs dropped.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot May 19, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix FK direction wording in migration constraints.

This section says FKs are from prow_job_runs, but the listed examples are tables with FKs to prow_job_runs. Please correct the direction to avoid migration confusion.

Suggested doc fix
-3. Tables with FKs **from** `prow_job_runs` to non-partitioned tables
-   (annotations, pull request join table) must either be co-partitioned
-   or have their FKs dropped.
+3. Tables with FKs **to** `prow_job_runs`
+   (annotations, pull request join table) must either be co-partitioned
+   or have those FK constraints adjusted/dropped during partition migration.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
3. Tables with FKs **from** `prow_job_runs` to non-partitioned tables
(annotations, pull request join table) must either be co-partitioned
or have their FKs dropped.
3. Tables with FKs **to** `prow_job_runs`
(annotations, pull request join table) must either be co-partitioned
or have those FK constraints adjusted/dropped during partition migration.
🤖 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 `@docs/plans/trt-1989-partitioning-prep.md` around lines 86 - 89, Update the
wording in the migration constraints so the FK direction is correct: change the
phrase "Tables with FKs from `prow_job_runs` to non-partitioned tables" to
express that these are tables with FKs to `prow_job_runs` (e.g., annotations,
pull request join table) — ensure the sentence reads something like "Tables with
FKs to `prow_job_runs` from non-partitioned tables must either be co-partitioned
or have their FKs dropped," and verify the examples (`annotations`, `pull
request join table`) read as tables referencing `prow_job_runs`.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Claude isn't in agreement with you @coderabbitai: These GORM tags create FK constraints on the child/join tables that reference prow_job_runs.id, but the cascade behavior is defined from the ProwJobRun side. The constraint says "when a prow_job_run is deleted, cascade to these tables." That's a FK from prow_job_runs's perspective in the GORM model.

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.

@neisw, that's a fair point from the GORM model perspective — the cascade behavior is declared on the ProwJobRun parent struct, so "from prow_job_runs" makes sense when reading the Go code.

For what it's worth, standard SQL/PostgreSQL terminology frames it the other way (the referencing table holds the FK column pointing to the parent), which is why the wording caught my eye — especially since this is a PostgreSQL partitioning guide where that distinction matters during migration. But since your team is familiar with the GORM model and the intent is clear in context, I'll defer to your judgment on the phrasing.

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e

@neisw
Copy link
Copy Markdown
Contributor Author

neisw commented May 19, 2026

/hold

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 19, 2026
Copy link
Copy Markdown
Member

@smg247 smg247 left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label May 20, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 20, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: neisw, smg247

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

@neisw
Copy link
Copy Markdown
Contributor Author

neisw commented May 20, 2026

/unhold

@openshift-ci openshift-ci Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 20, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 20, 2026

@neisw: 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.

@openshift-merge-bot openshift-merge-bot Bot merged commit ec3f70e into openshift:main May 20, 2026
8 checks passed
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. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants