Skip to content

Refs #39078 - Remove host compliance and other subscription accounting bits#11663

Merged
jeremylenz merged 2 commits intoKatello:masterfrom
jturel:remove_compliance_reasons
Mar 19, 2026
Merged

Refs #39078 - Remove host compliance and other subscription accounting bits#11663
jeremylenz merged 2 commits intoKatello:masterfrom
jturel:remove_compliance_reasons

Conversation

@jturel
Copy link
Copy Markdown
Member

@jturel jturel commented Mar 4, 2026

What are the changes introduced in this pull request?

Founds some more pieces in relation to #11616

Considerations taken when implementing this change?

What are the testing steps for this pull request?

Most of this can be validated by loading the subscriptions + subscriptions details pages + adding/removing/modifying upstream subscriptions. Ultimately, ensure nothing is calling deleted methods, etc.

Summary by Sourcery

Remove legacy host subscription compliance and subscription consumption accounting, simplifying pool and subscription models, APIs, and UI to rely on core subscription attributes only.

Enhancements:

  • Drop support for pool and subscription state/consumption helpers (e.g. active, recently_expired, quantity_available) and related organization-level aggregation methods.
  • Delegate common display attributes from pools to subscriptions and enrich the base subscription API representation with product host count while simplifying CSV exports and JSON payloads.
  • Simplify subscription table/editing logic in the frontend to use quantity and upstream pool relationships only, removing consumed/available columns and related behaviors.
  • Streamline subscription factories, fixtures, and test data to use more realistic defaults and sequences for pool and subscription attributes.

Deployment:

  • Add a migration to drop the katello_compliance_reasons table and remove consumed and virtual columns from katello_pools, with a reversible down migration to restore them if needed.

Tests:

  • Update and remove model, controller, mailer, and frontend tests that depended on compliance reasons, consumed/available fields, and deprecated pool/subscription helpers, ensuring subscriptions and subscription details pages continue to function with the new data model.

Chores:

  • Remove unused host subscription and compliance-related view templates and helpers from the API and template scope extensions, along with the ComplianceReason model and associated associations.

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, and left some high level feedback:

  • In the katello_pool factory, subscription { association(:katello_subscription, organization: @instance.organization) } relies on @instance, which isn't a documented FactoryBot pattern and may not behave as expected; consider using association(:katello_subscription, organization: organization) or an after(:build) hook instead.
  • The new getEntitlementsDisplayValue now bases the display solely on quantity and collapsible; if there are cases where an attached-but-non-upstream pool should still be treated as non-editable or non-'Unlimited', it might be worth revisiting the logic that previously used available and upstream_pool_id to ensure UI semantics remain correct.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the katello_pool factory, `subscription { association(:katello_subscription, organization: @instance.organization) }` relies on `@instance`, which isn't a documented FactoryBot pattern and may not behave as expected; consider using `association(:katello_subscription, organization: organization)` or an `after(:build)` hook instead.
- The new `getEntitlementsDisplayValue` now bases the display solely on `quantity` and `collapsible`; if there are cases where an attached-but-non-upstream pool should still be treated as non-editable or non-'Unlimited', it might be worth revisiting the logic that previously used `available` and `upstream_pool_id` to ensure UI semantics remain correct.

## Individual Comments

### Comment 1
<location path="db/migrate/20260225015710_remove_katello_compliance_reasons.katello.rb" line_range="8-17" />
<code_context>
+    remove_column :katello_pools, :virtual
+  end
+
+  def down
+    create_table :katello_compliance_reasons do |t|
+      t.string :reason
+      t.references :subscription_facet
+    end
+
+    add_foreign_key "katello_compliance_reasons", "katello_subscription_facets",
+                        :name => "katello_compliance_reasons_facet_id", :column => "subscription_facet_id"
+
+    add_column :katello_pools, :consumed, :integer
+    add_column :katello_pools, :virtual, :boolean
+  end
+end
</code_context>
<issue_to_address>
**suggestion (bug_risk):** The down migration may not fully restore the original schema, which can complicate rollbacks.

In `down`, the recreated `katello_compliance_reasons` table only has `reason` and `subscription_facet` and omits any original indexes, null constraints, or timestamps. The restored `consumed` and `virtual` columns also lack their original defaults/constraints. If production rollbacks are expected, consider matching the original schema definitions, or explicitly raise in `down` to mark the migration as non-reversible.
</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.

@@ -48,6 +47,10 @@ class Pool < Katello::Model

validate :subscription_matches_organization

delegate :instance_multiplier, :support_level, :name, :sockets, :cores, to: :subscription
delegate :cp_id, to: :subscription, prefix: true
alias_method :product_id, :subscription_cp_id
Copy link
Copy Markdown
Member Author

@jturel jturel Mar 4, 2026

Choose a reason for hiding this comment

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

These few lines are an interesting change. All of this data is being imported into Katello::Subscription, but was not being referenced when called through a pool object, instead relying on lazy_accessor (now removed). The result is that there are fewer API calls to candlepin when using subscriptions index and show APIs because those pieces now come from the DB.

Comment thread app/views/katello/api/v2/subscriptions/base.json.rabl
trait :inactive do
active { false }
end
subscription { association(:katello_subscription, organization: @instance.organization) }
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the proper way to pass down attributes to associations rather than using after build callbacks

@@ -38,7 +38,7 @@ export const createSubscriptionsTableSchema = (
formatters: [
(value, additionalData) => {
// eslint-disable-next-line no-param-reassign
additionalData.disabled = !hasPermission || additionalData.rowData.available === -1;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The gist of the UI changes with respect to available is that (from what I can tell) the presence of available was being used to denote a Red Hat Subscription, at least in most uses. Anyway, available is totally meaningless as consumption is no longer tracked.

@jeremylenz
Copy link
Copy Markdown
Member

You just keep going!

you cannot be stopped

image

@jturel
Copy link
Copy Markdown
Member Author

jturel commented Mar 4, 2026

  • The new getEntitlementsDisplayValue now bases the display solely on quantity and collapsible; if there are cases where an attached-but-non-upstream pool should still be treated as non-editable or non-'Unlimited', it might be worth revisiting the logic that previously used available and upstream_pool_id to ensure UI semantics remain correct.

This is written so convincingly that I need to think about it some more. TBD...

Update: I think it's fine, but some review here would be good to double check me.

@jturel jturel force-pushed the remove_compliance_reasons branch 2 times, most recently from c1fcd7d to 795327a Compare March 6, 2026 19:26
@jturel
Copy link
Copy Markdown
Member Author

jturel commented Mar 10, 2026

No further changes planned here pending review

def up
drop_table :katello_compliance_reasons
remove_column :katello_pools, :consumed
remove_column :katello_pools, :virtual
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just for my own reassurance - My "Requires Virt-who" column still seems to work fine. I guess that's because we still have it on subscription and don't need it on pool?

With SCA-Aware Manifests the plan is to "Remove columns Type, Requires Virt-Who, Consumed and Entitlements from the page" anyway, so I suppose this fulfills that partially!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, virtual is totally unused so went for the removal. The virt-who column is driven by the virt_who attribute

@jturel jturel force-pushed the remove_compliance_reasons branch from 795327a to b816619 Compare March 19, 2026 20:48
@jturel
Copy link
Copy Markdown
Member Author

jturel commented Mar 19, 2026

Rebased with 1 additional commit that adds back some lazy_accessors I'll deal with in #11647

Copy link
Copy Markdown
Member

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

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

Manifest actions seem just fine (famous last words?)

Thanks again @jturel!

ACK pending green tests

@jturel
Copy link
Copy Markdown
Member Author

jturel commented Mar 19, 2026

Manifest actions seem just fine (famous last words?)

What could go wrong? xD

@jeremylenz jeremylenz merged commit f7f1487 into Katello:master Mar 19, 2026
22 of 23 checks passed
@jturel jturel deleted the remove_compliance_reasons branch March 19, 2026 21:48
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.

2 participants