Skip to content

feat: [TKC-5291] Support silent_mode for Postgres repository#7403

Merged
vsukhin merged 13 commits intomainfrom
copilot/support-silent-mode
Mar 27, 2026
Merged

feat: [TKC-5291] Support silent_mode for Postgres repository#7403
vsukhin merged 13 commits intomainfrom
copilot/support-silent-mode

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 23, 2026

SilentMode was unimplemented in the Postgres code path (nil with // TODO: Unimplemented!? comments) while MongoDB already supported it. This adds full silent_mode persistence and filtering parity with MongoDB.

Pull request description

  • Migration: Adds silent_mode JSONB column to test_workflow_executions
  • SQL queries: Added silent_mode to all SELECT, INSERT, and UPDATE statements in executions.sql
  • GetFinished filter: Excludes executions with silent_mode @> '{"health": true}' using JSONB containment (index-friendly, no cast errors), matching MongoDB behavior
  • sqlc codegen: Added type override test_workflow_executions.silent_mode → *testkube.SilentMode in scheduling package; regenerated all affected models/params via make generate-sqlc
  • common_postgres.go: Both mapPgTestWorkflowExecutionPartial and mapPgTestWorkflowExecution now populate SilentMode from the row instead of hardcoding nil
  • postgres.go (testworkflow repository): insertMainExecution and updateMainExecution serialize SilentMode to JSONB (nil pointer produces SQL NULL); parseExecutionJSONFields deserializes it on read with proper error propagation
  • Tests (postgres_test.go): Added TestPostgresRepository_SilentModeInsert, TestPostgresRepository_SilentModeGet, and TestPostgresRepository_GetFinished_SilentMode to verify serialization, deserialization, and row mapping
  • Tests (executions.sql_test.go): Updated all affected sqlc mock tests to include the silent_mode column in query patterns, mock column lists, row values, and INSERT/UPDATE param structs

Checklist (choose whats happened)

  • breaking change! (describe)
  • tested locally
  • tested on cluster
  • added new dependencies
  • updated the docs
  • added a test

Breaking changes

Changes

Fixes


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits March 23, 2026 19:18
Copilot AI changed the title [WIP] Add support for silent mode in Postgres repository feat: Support silent_mode for Postgres repository Mar 23, 2026
Copilot AI requested a review from vsukhin March 23, 2026 19:23
@vsukhin vsukhin marked this pull request as ready for review March 23, 2026 19:28
@vsukhin vsukhin requested a review from a team as a code owner March 23, 2026 19:28
Copilot AI review requested due to automatic review settings March 23, 2026 19:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Postgres parity with MongoDB for silent_mode on test workflow executions by persisting the field in Postgres, wiring it through sqlc-generated models/queries, and applying the finished-executions filter to exclude silent_mode.health=true runs.

Changes:

  • Add silent_mode JSONB to test_workflow_executions via a goose migration.
  • Update Postgres SQL queries + sqlc-generated code to read/write silent_mode, and map it into TestWorkflowExecution objects.
  • Update controlplane scheduling sqlc models/mappers to include SilentMode.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
sqlc.yaml Adds sqlc override for test_workflow_executions.silent_mode in scheduling generator.
pkg/repository/testworkflow/postgres/postgres.go Serializes/deserializes SilentMode and passes it through insert/update and row-mapping.
pkg/database/postgres/migrations/20260323000000_silent_mode.sql Introduces the silent_mode JSONB column.
pkg/database/postgres/queries/executions.sql Adds silent_mode to selects/inserts/updates and applies GetFinished exclusion filter.
pkg/database/postgres/sqlc/executions.sql.go Regenerated sqlc bindings reflecting silent_mode and updated GetFinished query.
pkg/database/postgres/sqlc/models.go Regenerated model includes SilentMode field for TestWorkflowExecution.
pkg/database/postgres/sqlc/db.go Regenerated sqlc boilerplate (version header).
pkg/database/postgres/sqlc/leases.sql.go Regenerated sqlc boilerplate (version header).
pkg/database/postgres/sqlc/sequences.sql.go Regenerated sqlc boilerplate (version header).
pkg/controlplane/scheduling/sqlc/models.go Adds SilentMode to scheduling sqlc TestWorkflowExecution model.
pkg/controlplane/scheduling/sqlc/scheduler.sql.go Updates RETURNING/SELECT projections and scan targets to include silent_mode.
pkg/controlplane/scheduling/sqlc/execution_querier.sql.go Updates projections and scan targets to include silent_mode.
pkg/controlplane/scheduling/sqlc/execution_controller.sql.go Regenerated sqlc boilerplate (version header).
pkg/controlplane/scheduling/sqlc/db.go Regenerated sqlc boilerplate (version header).
pkg/controlplane/scheduling/common_postgres.go Maps SilentMode from sqlc rows into API execution objects.
go.mod Includes indirect dependency churn (not obviously tied to this feature).
go.sum Updates checksums/versions consistent with the go.mod changes.

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

Comment thread pkg/repository/testworkflow/postgres/postgres.go Outdated
Comment thread pkg/database/postgres/queries/executions.sql
Comment thread pkg/database/postgres/migrations/20260323000000_silent_mode.sql Outdated
Comment thread go.mod
Comment thread pkg/repository/testworkflow/postgres/postgres.go Outdated
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 23, 2026

Greptile Summary

This PR adds full silent_mode persistence for the Postgres code path, bringing it to parity with the existing MongoDB implementation. The changes are consistent and well-structured: a nullable JSONB migration, silent_mode wired into every SELECT/INSERT/UPDATE query, proper nil-guard serialization in insertMainExecution/updateMainExecution, correct deserialization in parseExecutionJSONFields, and the scheduling package updated to expose the typed *testkube.SilentMode field instead of the previous hardcoded nil.\n\nKey findings:\n\n- Filter semantics are correct. The GetFinished SQL filter (e.silent_mode IS NULL OR (e.silent_mode->>'health')::boolean IS NOT TRUE) is semantically equivalent to MongoDB's {silentmode.health: {$ne: true}} union {silentmode: {$exists: false}}. The IS NOT TRUE idiom correctly handles absent keys (which produce SQL NULL) caused by Go's omitempty on bool fields.\n- Struct-cast compatibility is maintained. All generated row types (GetFinishedTestWorkflowExecutionsRow, GetRunningTestWorkflowExecutionsRow, etc.) have SilentMode []byte inserted in the same position (between Runtime and CreatedAt), preserving the Go struct-cast pattern used throughout postgres.go.\n- Minor: filter uses text extraction rather than JSONB containment as stated in the PR description. The ->>'health' + ::boolean cast is safe given Go's marshaller, but @> containment would be GIN-index-friendly if an index is ever added. See inline comment.

Confidence Score: 5/5

Safe to merge; all changes are correct, well-tested, and follow established patterns.

No logic bugs, data-loss risk, or broken contracts found. The only finding is a P2 style suggestion about preferring JSONB containment over text-cast in the GetFinished filter — not a blocker.

No files require special attention.

Important Files Changed

Filename Overview
pkg/database/postgres/queries/executions.sql Adds e.silent_mode to all SELECT lists, INSERT, and UPDATE; GetFinished filter uses ->>'health' text extraction + cast instead of the JSONB containment (@>) claimed in the PR description — functionally correct but minor discrepancy.
pkg/database/postgres/sqlc/executions.sql.go Generated file: SilentMode []byte added in the same position (between Runtime and CreatedAt) across all row types, keeping struct-cast compatibility; no issues.
pkg/repository/testworkflow/postgres/postgres.go Correctly serializes/deserializes SilentMode in insert/update/read paths; parseExecutionJSONFields updated with consistent nil-guard and error propagation pattern.
pkg/controlplane/scheduling/common_postgres.go Removes two nil hardcodes and wires exec.SilentMode from the row; straightforward and correct.
sqlc.yaml Type override for silent_mode added only in the scheduling package section (consistent with runtime pattern); no issues.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[TestWorkflowExecution.SilentMode] -->|nil| B[SQL NULL / omit from INSERT]
    A -->|non-nil| C[json.Marshal → JSONB bytes]
    C --> D[(silent_mode JSONB column)]
    D -->|SELECT| E[SilentMode bytes from DB]
    E -->|len == 0 / NULL| F[execution.SilentMode = nil]
    E -->|len > 0| G[json.Unmarshal → *SilentMode]
    D -->|GetFinished filter| H{silent_mode IS NULL?}
    H -->|yes| I[Row included]
    H -->|no| J{health key text-cast = true?}
    J -->|yes| K[Row excluded]
    J -->|no / absent| I
Loading

Reviews (4): Last reviewed commit: "fix: remove misleading comment" | Re-trigger Greptile

Comment thread pkg/database/postgres/sqlc/db.go Outdated
vsukhin and others added 3 commits March 23, 2026 23:54
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
vsukhin added 2 commits March 24, 2026 14:39
Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>
Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>
@vsukhin
Copy link
Copy Markdown
Collaborator

vsukhin commented Mar 24, 2026

@greptile

@vsukhin
Copy link
Copy Markdown
Collaborator

vsukhin commented Mar 24, 2026

@copilot fix unit tests
pkg/database/postgres/sqlc TestSQLCTestWorkflowExecutionQueries_GetTestWorkflowExecution
pkg/database/postgres/sqlc TestSQLCTestWorkflowExecutionQueries_GetTestWorkflowExecutionByNameAndTestWorkflow

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 24, 2026

@copilot fix unit tests
pkg/database/postgres/sqlc TestSQLCTestWorkflowExecutionQueries_GetTestWorkflowExecution
pkg/database/postgres/sqlc TestSQLCTestWorkflowExecutionQueries_Get...

Fixed in commit a111df4. Updated all affected tests in executions.sql_test.go to include silent_mode in query patterns, mock column lists, and row values:

  • TestSQLCTestWorkflowExecutionQueries_GetTestWorkflowExecution
  • TestSQLCTestWorkflowExecutionQueries_GetTestWorkflowExecutionByNameAndTestWorkflow
  • TestSQLCTestWorkflowExecutionQueries_GetLatestTestWorkflowExecutionByTestWorkflow
  • TestSQLCTestWorkflowExecutionQueries_GetLatestTestWorkflowExecutionsByTestWorkflows
  • TestSQLCTestWorkflowExecutionQueries_GetRunningTestWorkflowExecutions
  • TestSQLCTestWorkflowExecutionQueries_InsertTestWorkflowExecution
  • TestSQLCTestWorkflowExecutionQueries_UpdateTestWorkflowExecution

@vsukhin vsukhin changed the title feat: Support silent_mode for Postgres repository feat: [TKC-5291] Support silent_mode for Postgres repository Mar 24, 2026
Comment thread pkg/controlplane/scheduling/common_postgres.go Outdated
Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>

# Conflicts:
#	pkg/database/postgres/queries/executions.sql
#	pkg/database/postgres/sqlc/executions.sql.go
#	pkg/database/postgres/sqlc/executions.sql_test.go
@vsukhin
Copy link
Copy Markdown
Collaborator

vsukhin commented Mar 27, 2026

@greptile

Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>
@vsukhin
Copy link
Copy Markdown
Collaborator

vsukhin commented Mar 27, 2026

@greptile

@vsukhin vsukhin merged commit 876fb99 into main Mar 27, 2026
12 checks passed
@vsukhin vsukhin deleted the copilot/support-silent-mode branch March 27, 2026 11:00
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.

4 participants