Skip to content

ROX-33786: Add profile kind db column#19616

Open
guzalv wants to merge 1 commit intomasterfrom
master-base/gualvare/ROX-33786-add-profile-kind-db-column
Open

ROX-33786: Add profile kind db column#19616
guzalv wants to merge 1 commit intomasterfrom
master-base/gualvare/ROX-33786-add-profile-kind-db-column

Conversation

@guzalv
Copy link
Copy Markdown
Contributor

@guzalv guzalv commented Mar 25, 2026

Description

This PR adds operator_kind as a dedicated column to the compliance_operator_profile_v2 table so it can be used as a search/filter field in the API (e.g. Compliance Profile Operator Kind:PROFILE).

Previously, operator_kind only existed inside the serialized protobuf blob, making it invisible to SQL queries. This extracts it into its own column with a migration that backfills existing rows from the blob.

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

CI, and I deployed stackrox before this change, then upgraded to a new build from this PR, verified that the migration runs correctly and the field can be queried by the API.

@guzalv
Copy link
Copy Markdown
Contributor Author

guzalv commented Mar 25, 2026

This change is part of the following stack:

Change managed by git-spice.

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Mar 25, 2026

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

@rhacs-bot
Copy link
Copy Markdown
Contributor

rhacs-bot commented Mar 25, 2026

Images are ready for the commit at b6823f8.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.11.x-465-gb6823f89f5.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

❌ Patch coverage is 63.95349% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.37%. Comparing base (5d84b54) to head (1a9c89c).
⚠️ Report is 30 commits behind head on master.

Files with missing lines Patch % Lines
...compliance_profile_operator_kind/migration_impl.go 61.72% 21 Missing and 10 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19616      +/-   ##
==========================================
+ Coverage   49.26%   49.37%   +0.10%     
==========================================
  Files        2735     2744       +9     
  Lines      206138   207017     +879     
==========================================
+ Hits       101550   102210     +660     
- Misses      97041    97211     +170     
- Partials     7547     7596      +49     
Flag Coverage Δ
go-unit-tests 49.37% <63.95%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@guzalv guzalv force-pushed the master-base/gualvare/ROX-33786-add-profile-kind-db-column branch from a60eba3 to 1a9c89c Compare March 27, 2026 08:42
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@guzalv guzalv force-pushed the master-base/gualvare/ROX-33786-add-profile-kind-db-column branch from 1a9c89c to b6823f8 Compare March 27, 2026 10:10
@guzalv guzalv requested a review from a team March 27, 2026 10:20
@guzalv guzalv marked this pull request as ready for review March 27, 2026 10:20
@guzalv guzalv requested review from a team as code owners March 27, 2026 10:20
@guzalv guzalv requested review from mtodor and removed request for a team March 27, 2026 10:21
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="migrator/migrations/m_222_to_m_223_add_compliance_profile_operator_kind/migration_test.go" line_range="36" />
<code_context>
+}
+
+func (s *migrationTestSuite) TestMigration() {
+	batchSize = 2 // Force multiple batches
+
+	dbs := &types.Databases{
</code_context>
<issue_to_address>
**issue (testing):** Reset the global batchSize after the test to avoid leaking state across tests

Because `batchSize` is a package-level variable, changing it here without restoring it can cause flaky behavior in other tests depending on run order. Capture the original value and restore it with a `defer`, for example:

```go
o := batchSize
batchSize = 2
defer func() { batchSize = o }()
```

This keeps the test isolated and avoids leaking global state between tests.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

}

func (s *migrationTestSuite) TestMigration() {
batchSize = 2 // Force multiple batches
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.

issue (testing): Reset the global batchSize after the test to avoid leaking state across tests

Because batchSize is a package-level variable, changing it here without restoring it can cause flaky behavior in other tests depending on run order. Capture the original value and restore it with a defer, for example:

o := batchSize
batchSize = 2
defer func() { batchSize = o }()

This keeps the test isolated and avoids leaking global state between tests.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants