diff --git a/app/lib/actions/pulp3/capsule_content/reclaim_space.rb b/app/lib/actions/pulp3/capsule_content/reclaim_space.rb index 3e10323e9eb..ba60241f67c 100644 --- a/app/lib/actions/pulp3/capsule_content/reclaim_space.rb +++ b/app/lib/actions/pulp3/capsule_content/reclaim_space.rb @@ -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! @@ -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 diff --git a/app/models/katello/concerns/smart_proxy_extensions.rb b/app/models/katello/concerns/smart_proxy_extensions.rb index 384655612e1..d7a49bc7400 100644 --- a/app/models/katello/concerns/smart_proxy_extensions.rb +++ b/app/models/katello/concerns/smart_proxy_extensions.rb @@ -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 diff --git a/app/views/katello/api/v2/capsule_content/sync_status.json.rabl b/app/views/katello/api/v2/capsule_content/sync_status.json.rabl index 465b775e0da..9fac6a9e472 100644 --- a/app/views/katello/api/v2/capsule_content/sync_status.json.rabl +++ b/app/views/katello/api/v2/capsule_content/sync_status.json.rabl @@ -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' diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/capsule-content/capsule-content.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/capsule-content/capsule-content.controller.js index c852f45aff5..b27e769b49a 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/capsule-content/capsule-content.controller.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/capsule-content/capsule-content.controller.js @@ -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: ')); });