From 1781c3d3c77f94beb5745a77bc534c46844e2565 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Mar 24 2022 07:59:15 +0000 Subject: import rhc-worker-playbook-0.1.8-1.el8 --- diff --git a/SOURCES/0001-fix-Execute-playbook-asynchronously.patch b/SOURCES/0001-fix-Execute-playbook-asynchronously.patch new file mode 100644 index 0000000..4c59b30 --- /dev/null +++ b/SOURCES/0001-fix-Execute-playbook-asynchronously.patch @@ -0,0 +1,49 @@ +From 332d28d1bb636a5dc8ff5ddf3da8359a9a78b297 Mon Sep 17 00:00:00 2001 +From: Link Dupont +Date: Wed, 5 May 2021 14:10:49 -0400 +Subject: [PATCH] fix: Execute playbook asynchronously + +Run the playbook code in a coroutine that's scheduled onto a new event loop. Return a protobuf.Receipt message in the WorkerService Send implementation. +--- + rhc_worker_playbook/server.py | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git a/rhc_worker_playbook/server.py b/rhc_worker_playbook/server.py +index 985ea98..8fa393f 100644 +--- a/rhc_worker_playbook/server.py ++++ b/rhc_worker_playbook/server.py +@@ -16,6 +16,7 @@ import time + import json + import uuid + import atexit ++import asyncio + from subprocess import Popen, PIPE + from requests import Request + from concurrent import futures +@@ -135,9 +136,13 @@ class WorkerService(yggdrasil_pb2_grpc.WorkerServicer): + ''' + Act on messages sent to the WorkerService + ''' +- # we have received it +- yggdrasil_pb2.Receipt() + ++ loop = asyncio.new_event_loop() ++ loop.run_until_complete(self._run_data(request)) ++ ++ return yggdrasil_pb2.Receipt() ++ ++ async def _run_data(self, request): + # load configuration + config = _loadConfig() + +@@ -256,7 +261,6 @@ class WorkerService(yggdrasil_pb2_grpc.WorkerServicer): + _log("Posting events...") + response = self.dispatcher.Send(returnedEvents) + _log("Post complete.") +- return + + def serve(): + # load config to get directive +-- +2.35.1 + diff --git a/SPECS/rhc-worker-playbook.spec b/SPECS/rhc-worker-playbook.spec index 08c22e7..1f8cdbf 100644 --- a/SPECS/rhc-worker-playbook.spec +++ b/SPECS/rhc-worker-playbook.spec @@ -5,12 +5,14 @@ Name: rhc-worker-playbook Summary: Red Hat connect worker for launching Ansible Runner Version: 0.1.8 -Release: 0%{?dist} +Release: 1%{?dist} License: GPLv2+ Source: rhc-worker-playbook-0.1.8.tar.gz Source1: https://github.com/ansible-collections/community.general/archive/%{community_general_version}/ansible-collection-community-general-%{community_general_version}.tar.gz Source2: https://github.com/ansible-collections/ansible.posix/archive/%{ansible_posix_version}/ansible-collection-ansible-posix-%{ansible_posix_version}.tar.gz +Patch0001: 0001-fix-Execute-playbook-asynchronously.patch + ExclusiveArch: %{go_arches} %{?__python3:Requires: %{__python3}} @@ -31,7 +33,8 @@ BuildRequires: python3dist(cython) Python-based worker for Red Hat connect, used to launch Ansible playbooks via Ansible Runner. %prep -%setup -q -a1 -a2 +%setup -q -a1 -a2 -n %{name}-%{version} +%patch0001 -p1 pushd community.general-%{community_general_version} rm -vr .github .azure-pipelines rm -rvf tests/ @@ -93,10 +96,14 @@ mkdir -p %{buildroot}%{_localstatedir}/log/rhc-worker-playbook/ansible %{_datadir}/rhc-worker-playbook/ansible/collections/ansible_collections/ %{_localstatedir}/log/rhc-worker-playbook/ansible/ %config %{_sysconfdir}/rhc/workers/rhc-worker-playbook.toml +%exclude %{_libdir}/.build-id/ %doc %changelog +* Mon Feb 21 2022 Gaël Chamoulaud - 0.1.8-1 +- Patch to fix Execute Playbook Asynchronously (RHBZ#2020426) + * Thu Feb 03 2022 Gaël Chamoulaud - 0.1.8-0 - Fix: Bump ansible-runner to 2.1.1 and dependencies in vendor (RHBZ#2053207) - Upload new rhc-worker-playbook-0.1.8.tar.gz source