Project

General

Profile

« Previous | Next » 

Revision 2597689e

Added by Ivan Necas about 10 years ago

Index only when synchronization not handled by Dynflow action

The Actions::Katello::Repository::Sync itself handled then indexing of
the content: no need to do it again the after_sync callback.

View differences:

app/lib/actions/katello/repository/sync.rb
def presenter
Helpers::Presenter::Delegated.new(self, planned_actions(Pulp::Repository::Sync))
end
def pulp_task_id
pulp_action = planned_actions(Pulp::Repository::Sync).first
pulp_action.output[:pulp_task] &&
pulp_action.output[:pulp_task][:task_id]
end
end
end
end
app/models/katello/glue/pulp/repo.rb
return [task]
end
# Returns true if the pulp_task_id was triggered by the last synchronization
# action for the repository. Dynflow action handles the synchronization
# by it's own so no need to synchronize it again in this callback. Since the
# callbacks are run just after synchronization is finished, it should be enough
# to check for the last synchronization task.
def dynflow_handled_last_sync?(pulp_task_id)
task = ForemanTasks::Task::DynflowTask.for_action(::Actions::Katello::Repository::Sync).
for_resource(self).order(:started_at).last
return task && task.main_action.pulp_task_id == pulp_task_id
end
def handle_sync_complete_task(pulp_task_id, notifier_service = Notify)
return if dynflow_handled_last_sync?(pulp_task_id)
pulp_task = Katello.pulp_server.resources.task.poll(pulp_task_id)
if pulp_task.nil?

Also available in: Unified diff