Skip to content

Fixes #39222 - Remove TaskStatus model#11706

Open
jturel wants to merge 1 commit into
Katello:masterfrom
jturel:remove_task_status
Open

Fixes #39222 - Remove TaskStatus model#11706
jturel wants to merge 1 commit into
Katello:masterfrom
jturel:remove_task_status

Conversation

@jturel
Copy link
Copy Markdown
Member

@jturel jturel commented Apr 8, 2026

What are the changes introduced in this pull request?

  • Removes the TaskStatus model which is dead code / tech debt
  • Consolidates API responses to use the foreman tasks RABL template where tasks are being returned instead of relying on legacy katello task RABL.

Considerations taken when implementing this change?

N/A

What are the testing steps for this pull request?

  • Perform any action that spawns an async task
  • Perform any action that spawns async tasks in bulk (destroy repositories is the only one)

In both cases, verify the API output is unchanged.

Summary by CodeRabbit

  • Refactor

    • Removed task status tracking functionality from the application.
    • Updated task API endpoints to integrate with external task management system.
  • Chores

    • Removed task status database tables and associated test fixtures.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

This PR removes the Katello::TaskStatus model entirely, replacing it with Foreman's task system. Model associations are cleaned up, helper methods depending on task status are deleted, provider validation is tightened, API views migrate to Foreman templates, and the database schema is updated via migration.

Changes

TaskStatus Model and Integration Removal

Layer / File(s) Summary
Remove TaskStatus associations from models
app/models/katello/concerns/organization_extensions.rb, app/models/katello/concerns/user_extensions.rb, app/models/katello/content_view_version.rb, app/models/katello/provider.rb
Organization loses task_statuses and org_tasks associations; User loses task_statuses; ContentViewVersion loses task_status polymorphic association; Provider loses task_status belongs-to association.
Remove TaskStatus-dependent helper methods
app/models/katello/concerns/organization_extensions.rb, app/models/katello/provider.rb
Delete repo_discovery_task helper from Organization and manifest_task method from Provider that relied on task_status associations.
Tighten Red Hat provider update constraints
app/models/katello/provider.rb
constraint_redhat_update now rejects all attribute changes for existing Red Hat providers, removing the prior exception for task_status_id.
Migrate API templates to Foreman task views
app/views/katello/api/v2/common/async.json.rabl, app/views/katello/api/v2/common/bulk_async.json.rabl, app/views/katello/api/v2/providers/_provider.json.rabl, app/views/katello/api/v2/tasks/index.json.rabl
RABL templates now extend foreman_tasks/api/tasks/show instead of Katello's task views; task_status_id removed from provider JSON output; task index template emptied.
Database migration and test infrastructure cleanup
db/migrate/20260220070318_drop_katello_task_statuses.katello.rb, test/models/association_test.rb, test/support/fixtures_support.rb
Migration drops task_status_id column from katello_providers and removes katello_task_statuses table; TaskStatus removed from fixture classes and association test ignorable foreign keys.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • aidenfine
  • nofaralfasi
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'Fixes #39222 - Remove TaskStatus model' directly and clearly describes the main change: removal of the TaskStatus model as a fix for issue #39222.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@jturel jturel force-pushed the remove_task_status branch from 6a51737 to 36862c2 Compare May 27, 2026 16:19
@jturel jturel marked this pull request as ready for review May 27, 2026 16:27
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
db/migrate/20260220070318_drop_katello_task_statuses.katello.rb (1)

2-5: ⚖️ Poor tradeoff

Make migration reversible.

The migration is currently irreversible because remove_column doesn't specify the column type/constraints and drop_table doesn't preserve the table structure. While rollback may be unlikely for dead-code removal, reversible migrations are a Rails best practice for safety.

♻️ Suggested refactor for reversibility
 def change
-  remove_column :katello_providers, :task_status_id
-  drop_table :katello_task_statuses
+  remove_column :katello_providers, :task_status_id, :integer
+  drop_table :katello_task_statuses do |t|
+    t.string :uuid
+    t.integer :user_id
+    t.string :organization_id
+    t.string :state
+    t.datetime :start_time
+    t.datetime :finish_time
+    t.text :progress
+    t.text :parameters
+    t.text :result
+    t.timestamps
+  end
 end

Note: Verify actual column types from db/schema.rb before applying.

🤖 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 `@db/migrate/20260220070318_drop_katello_task_statuses.katello.rb` around lines
2 - 5, The migration is irreversible because remove_column(:katello_providers,
:task_status_id) omits the column type/options and
drop_table(:katello_task_statuses) does not record the table schema; make it
reversible by rewriting change to use reversible do |dir| (or explicit up/down)
that on dir.up removes the column and drops the table, and on dir.down
re-creates katello_task_statuses with the original columns/indexes and re-adds
task_status_id to katello_providers using the correct type and options (verify
those types/constraints in db/schema.rb) so rollback can restore the exact prior
schema.
🤖 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.

Nitpick comments:
In `@db/migrate/20260220070318_drop_katello_task_statuses.katello.rb`:
- Around line 2-5: The migration is irreversible because
remove_column(:katello_providers, :task_status_id) omits the column type/options
and drop_table(:katello_task_statuses) does not record the table schema; make it
reversible by rewriting change to use reversible do |dir| (or explicit up/down)
that on dir.up removes the column and drops the table, and on dir.down
re-creates katello_task_statuses with the original columns/indexes and re-adds
task_status_id to katello_providers using the correct type and options (verify
those types/constraints in db/schema.rb) so rollback can restore the exact prior
schema.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 54d0a597-4683-4fd3-8fd3-c856624ff76e

📥 Commits

Reviewing files that changed from the base of the PR and between 6027570 and 36862c2.

📒 Files selected for processing (19)
  • app/lib/katello/util/task_status.rb
  • app/models/katello/concerns/organization_extensions.rb
  • app/models/katello/concerns/user_extensions.rb
  • app/models/katello/content_view_version.rb
  • app/models/katello/provider.rb
  • app/models/katello/task_status.rb
  • app/views/katello/api/v2/common/async.json.rabl
  • app/views/katello/api/v2/common/bulk_async.json.rabl
  • app/views/katello/api/v2/host_errata/system_task.json.rabl
  • app/views/katello/api/v2/providers/_provider.json.rabl
  • app/views/katello/api/v2/tasks/index.json.rabl
  • app/views/katello/api/v2/tasks/show.json.rabl
  • app/views/katello/api/v2/tasks/task_status_show.json.rabl
  • db/migrate/20260220070318_drop_katello_task_statuses.katello.rb
  • spec/models/task_status_spec.rb
  • test/factories/task_status_factory.rb
  • test/fixtures/models/katello_task_statuses.yml
  • test/models/association_test.rb
  • test/support/fixtures_support.rb
💤 Files with no reviewable changes (14)
  • app/views/katello/api/v2/tasks/task_status_show.json.rabl
  • app/views/katello/api/v2/tasks/index.json.rabl
  • test/fixtures/models/katello_task_statuses.yml
  • test/factories/task_status_factory.rb
  • app/models/katello/task_status.rb
  • app/models/katello/concerns/user_extensions.rb
  • app/views/katello/api/v2/tasks/show.json.rabl
  • app/lib/katello/util/task_status.rb
  • test/support/fixtures_support.rb
  • app/models/katello/content_view_version.rb
  • app/views/katello/api/v2/host_errata/system_task.json.rabl
  • spec/models/task_status_spec.rb
  • test/models/association_test.rb
  • app/models/katello/concerns/organization_extensions.rb

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.

1 participant