Skip to content

HYPERFLEET-1468 - feat: Add the resources tenancy column and GIN index - #335

Open
mliptak0 wants to merge 1 commit into
openshift-hyperfleet:mainfrom
mliptak0:HYPERFLEET-1468
Open

HYPERFLEET-1468 - feat: Add the resources tenancy column and GIN index#335
mliptak0 wants to merge 1 commit into
openshift-hyperfleet:mainfrom
mliptak0:HYPERFLEET-1468

Conversation

@mliptak0

@mliptak0 mliptak0 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Test Plan

  • Unit tests added/updated
  • make test-all passes
  • make lint passes
  • Helm chart changes validated with make test-helm (if applicable)
  • Deployed to a development cluster and verified (if Helm/config changes)
  • E2E tests passed (if cross-component or major changes)

@openshift-ci
openshift-ci Bot requested review from aredenba-rh and mbrudnoy August 11, 2026 14:32
@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mischulee for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@hyperfleet-ci-bot

Copy link
Copy Markdown

Risk Score: 2 — risk/medium

Signal Detail Points
PR size 40 lines +0
Sensitive paths none +0
Test coverage No _test.go files in diff +2

Computed by hyperfleet-risk-scorer

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Resources now support tenancy metadata stored as JSON.
    • Tenancy metadata defaults to an empty object and is optimized for containment queries.
  • Documentation

    • Updated database documentation to describe the new tenancy field, default value, and query indexing.

Walkthrough

The Resource entity now includes a required Tenancy JSONB field with an empty-object default. A migration creates the resources.tenancy column and a GIN jsonb_path_ops index, with rollback support. The migration is added to the ordered migration list. Database documentation describes the new column and index.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: kuudori, rafabene, tirthct

🚥 Pre-merge checks | ✅ 10 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description references the tracking issue but does not explain the tenancy column or GIN index changes. Add a concise summary of the resources tenancy column, JSONB configuration, and GIN index changes.
✅ Passed checks (10 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the resources tenancy column and GIN index, which are the main changes.
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.
Sec-02: Secrets In Log Output ✅ Passed CWE-532 check passes: the three changed production Go files add no slog, log, logr, zap, or fmt.Print statements and contain no token, password, credential, or secret fields.
No Hardcoded Secrets ✅ Passed The 39 added lines contain no credential names, embedded-credential URLs, private-key headers, or long Base64 strings; Go literals are schema/index values only. No CWE-798 finding.
No Weak Cryptography ✅ Passed The patch adds only JSONB model and migration code; no banned crypto imports, weak primitives, custom cryptography, or secret comparisons appear in changed lines. No CWE-327 issue found.
No Injection Vectors ✅ Passed No CWE-89 vector found: migration tx.Exec calls use fixed SQL literals, and changed files contain no user-controlled query interpolation, exec.Command, template.HTML, or yaml.Unmarshal.
No Privileged Containers ✅ Passed No changed deployment file contains a listed privilege setting. Existing Dockerfile USER root is justified for dnf install and switches to non-root UIDs (CWE-250).
No Pii Or Sensitive Data In Logs ✅ Passed No added logging statements or data-bearing log arguments exist; the migration uses only static SQL. CWE-532 exposure is not introduced.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Warning

Review ran into problems

🔥 Problems

Repository analysis: Couldn't refresh openshift-hyperfleet/hyperfleet-api clone - clone failed: Clone operation failed: Stream initialization permanently failed: 14 UNAVAILABLE: read ECONNRESET


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/migrations/202608111200_add_resource_tenancy.go`:
- Around line 30-32: Remove the ALTER TABLE resources DROP COLUMN IF EXISTS
tenancy operation from the migration rollback function. Keep the rollback
backward-compatible without deleting stored tenancy data, and leave any
destructive cleanup to a separate audited procedure.
🪄 Autofix

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: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 2878d285-1545-4b51-a706-c975f044f75c

📥 Commits

Reviewing files that changed from the base of the PR and between d9cb9a9 and 29a9b34.

📒 Files selected for processing (4)
  • docs/database.md
  • pkg/api/resource.go
  • pkg/db/migrations/202608111200_add_resource_tenancy.go
  • pkg/db/migrations/migration_structs.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)

Comment on lines +30 to +32
return tx.Exec(
"ALTER TABLE resources DROP COLUMN IF EXISTS tenancy;",
).Error

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Do not drop resources.tenancy in the automatic rollback.

DROP COLUMN permanently deletes all stored tenancy JSONB values. This conflicts with docs/database.md (Line 64-66), which states that migrations never drop columns or tables. Remove the destructive column drop from the production rollback. Use a separate, audited procedure if data destruction is ever required.

As per path instructions, migrations must be backward compatible and must not create data-loss scenarios.

🤖 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/migrations/202608111200_add_resource_tenancy.go` around lines 30 - 32,
Remove the ALTER TABLE resources DROP COLUMN IF EXISTS tenancy operation from
the migration rollback function. Keep the rollback backward-compatible without
deleting stored tenancy data, and leave any destructive cleanup to a separate
audited procedure.

Source: Path instructions

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.

1 participant