Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #35556 - Track reclaimspace task properly as an allowed action #10761

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/lib/actions/pulp3/capsule_content/reclaim_space.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Pulp3
module CapsuleContent
class ReclaimSpace < Pulp3::AbstractAsyncTask
def plan(smart_proxy)
action_subject(smart_proxy)
if smart_proxy.pulp_primary?
repository_hrefs = ::Katello::Pulp3::RepositoryReference.default_cv_repository_hrefs(::Katello::Repository.unscoped.on_demand, ::Organization.all)
repository_hrefs.flatten!
Expand All @@ -20,6 +21,10 @@ def invoke_external_task
output[:pulp_tasks] = ::Katello::Pulp3::Api::Core.new(SmartProxy.find(input[:smart_proxy_id])).
repositories_reclaim_space_api.reclaim(repo_hrefs: input[:repository_hrefs])
end

def rescue_strategy
Dynflow::Action::Rescue::Skip
end
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions app/models/katello/concerns/smart_proxy_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,18 @@ def sync_tasks
ForemanTasks::Task.for_resource(self).where(:label => 'Actions::Katello::CapsuleContent::Sync')
end

def reclaim_space_tasks
ForemanTasks::Task.for_resource(self).where(:label => 'Actions::Pulp3::CapsuleContent::ReclaimSpace')
end

def active_sync_tasks
sync_tasks.where(:result => 'pending')
end

def last_failed_reclaim_tasks
reclaim_space_tasks.where('started_at > ?', last_sync_time).where.not(:result => 'pending')
end

def last_failed_sync_tasks
sync_tasks.where('started_at > ?', last_sync_time).where.not(:result => 'pending')
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ node :content_counts do
@capsule.content_counts
end

child :last_failed_reclaim_tasks => :last_failed_reclaim_tasks do
extends 'foreman_tasks/api/tasks/show'
end

child @lifecycle_environments => :lifecycle_environments do
extends 'katello/api/v2/common/identifier'
extends 'katello/api/v2/common/org_reference'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,27 @@ angular.module('Bastion.capsule-content').controller('CapsuleContentController',
}
Notification.setErrorMessage(translate('Last sync failed: ') + errorMessage);
}
} else if (syncStatus['last_failed_reclaim_tasks'].length > 0) {
activeOrFailedTask = pickLastTask(syncStatus['last_failed_reclaim_tasks']);
$scope.syncTask = activeOrFailedTask;
errorCount = $scope.syncTask.humanized.errors.length;

if (errorCount > 0) {
errorMessage = $scope.syncTask.humanized.errors[0];
if (errorCount > 2) {
errorMessage += " " + translate("Plus %y more errors").replace("%y", errorCount - 1);
} else if (errorCount > 1) {
errorMessage += " " + translate("Plus 1 more error");
}
Notification.setErrorMessage(translate('Last reclaim failed: ') + errorMessage);
}
}
$scope.syncState.set(stateFromTask(activeOrFailedTask));
}, function (response) {
$scope.syncStatus = {
'active_sync_tasks': [],
'last_failed_sync_tasks': []
'last_failed_sync_tasks': [],
'last_failed_reclaim_tasks': []
};
processError(response, translate('Last sync failed: '));
});
Expand Down
Loading