Repository navigation
RHINENG-30223: reusable deploy-time SQL job, store owner IDs - #2356
Conversation
Run bundled SQL scripts when selected through deployment configuration, avoiding separate one-off job implementations. Leave un-configured deployments unchanged and use transactions, timeouts, and an advisory lock for execution.
Dual-write upload owner IDs to a new nullable column while preserving the legacy subscription-manager mapping. Provide a re-runnable SQL copy for existing rows so owner-based consumers and subscription-manager ID extraction can switch sources in a later change.
Reviewer's GuideThis PR adds a deployment-configured SQL runner that safely executes repository-bundled PostgreSQL scripts with transactional, timeout, and advisory-lock protections, and introduces nullable owner-ID storage with dual-write compatibility plus a rerunnable backfill for existing inventory data. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tasks/sql_job/sql/001_backfill_owner_id.sql" line_range="4-6" />
<code_context>
+-- Run only while subscription_manager_id still stores owner IDs.
+-- Do not run after subscription_manager_id starts storing actual subscription-manager IDs.
+-- Related to: RHINENG-30223
+UPDATE system_inventory
+SET owner_id = subscription_manager_id
+WHERE owner_id IS NULL
+ AND subscription_manager_id IS NOT NULL;
</code_context>
<issue_to_address>
**Owner IDs become stale**
When older application pods are still uploading hosts while the backfill runs, the `UPDATE` only copies rows visible when it runs, so later inserts remain NULL and subsequent `subscription_manager_id` updates leave copied `owner_id` values stale. Rerunning skips those non-NULL values, so consumers read missing or outdated owner IDs.
Run the backfill only after older pods stop uploading, or keep `owner_id` synchronized with their writes.
Also at `deploy/clowdapp.yaml:741`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and this adds an automatically invoked production SQL execution path and a backfill that persists owner IDs in the database; a mistakenly selected or semantically stale script could successfully write incorrect data, and reverting the application would not restore those writes. The transaction limits partial execution, but it does not repair a completed wrong update, so recovery would require a separate corrective operation or verified data restoration.
Blocking findings: tasks/sql_job/sql/001_backfill_owner_id.sql:6
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2356 +/- ##
==========================================
+ Coverage 58.92% 58.95% +0.03%
==========================================
Files 150 151 +1
Lines 9626 9690 +64
==========================================
+ Hits 5672 5713 +41
- Misses 3355 3375 +20
- Partials 599 602 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
/test |
1 similar comment
|
/test |
Summary
Enables running bundled SQL scripts when selected through deployment configuration,
avoiding separate one-off job implementations. Leave un-configured
deployments unchanged and use transactions, timeouts, and an advisory
lock for execution.
And adds dual-write of upload owner IDs to a new nullable column while preserving
the legacy subscription-manager mapping. Provide a re-runnable SQL copy
for existing rows so owner-based consumers and subscription-manager ID
extraction can switch sources in a later change.
Secure Coding Checklist
Summary by Sourcery
Introduce an opt-in deploy-time SQL runner and begin migrating inventory ownership data to a dedicated owner ID field.
New Features:
Enhancements:
Build:
Deployment:
Documentation:
Tests: