Skip to content

Commit

Permalink
Fixes #35556 - Track reclaimspace task properly as an allowed action
Browse files Browse the repository at this point in the history
  • Loading branch information
sjha4 committed Nov 9, 2023
1 parent d5f40d5 commit c4b3fef
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
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

0 comments on commit c4b3fef

Please sign in to comment.