Skip to content

Commit b20c656

Browse files
authored
Add logging output to tasks that start scripts in workers (#691)
Signed-off-by: Christian Berendt <[email protected]>
1 parent 693d8be commit b20c656

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

osism/tasks/__init__.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
import os
55
from pathlib import Path
66
import subprocess
7-
from osism import settings
7+
88
from celery.signals import worker_process_init
99
from loguru import logger
1010
from redis import Redis
1111
from pottery import Redlock
1212

13+
from osism import settings
14+
1315
redis = None
1416

1517

@@ -104,16 +106,20 @@ def run_ansible_in_environment(
104106
lock.acquire()
105107

106108
if role == "mariadb_backup":
109+
command = f"/run.sh backup {role} {joined_arguments}"
110+
logger.info(f"RUN {command}")
107111
p = subprocess.Popen(
108-
f"/run.sh backup {role} {joined_arguments}",
112+
command,
109113
shell=True,
110114
stdout=subprocess.PIPE,
111115
stderr=subprocess.PIPE,
112116
env=env,
113117
)
114118
else:
119+
command = f"/run.sh deploy {role} {joined_arguments}"
120+
logger.info(f"RUN {command}")
115121
p = subprocess.Popen(
116-
f"/run.sh deploy {role} {joined_arguments}",
122+
command,
117123
shell=True,
118124
stdout=subprocess.PIPE,
119125
stderr=subprocess.PIPE,
@@ -125,8 +131,10 @@ def run_ansible_in_environment(
125131
if locking:
126132
lock.acquire()
127133

134+
command = f"/run.sh {role} {joined_arguments}"
135+
logger.info(f"RUN {command}")
128136
p = subprocess.Popen(
129-
f"/run.sh {role} {joined_arguments}",
137+
command,
130138
shell=True,
131139
stdout=subprocess.PIPE,
132140
stderr=subprocess.PIPE,
@@ -139,8 +147,10 @@ def run_ansible_in_environment(
139147
and environment == "manager"
140148
and role == "bifrost-command"
141149
):
150+
command = f'/run-manager.sh bifrost-command "-e bifrost_arguments=\'{joined_arguments}\'" "-e bifrost_result_id={request_id}"'
151+
logger.info(f"RUN {command}")
142152
p = subprocess.Popen(
143-
f'/run-manager.sh bifrost-command "-e bifrost_arguments=\'{joined_arguments}\'" "-e bifrost_result_id={request_id}"',
153+
command,
144154
shell=True,
145155
stdout=subprocess.PIPE,
146156
stderr=subprocess.PIPE,
@@ -151,8 +161,10 @@ def run_ansible_in_environment(
151161
if locking:
152162
lock.acquire()
153163

164+
command = f"/run-{environment}.sh {role} {joined_arguments}"
165+
logger.info(f"RUN {command}")
154166
p = subprocess.Popen(
155-
f"/run-{environment}.sh {role} {joined_arguments}",
167+
command,
156168
shell=True,
157169
stdout=subprocess.PIPE,
158170
stderr=subprocess.PIPE,
@@ -163,8 +175,10 @@ def run_ansible_in_environment(
163175
if locking:
164176
lock.acquire()
165177

178+
command = f"/run-{environment}.sh {role} {joined_arguments}"
179+
logger.info(f"RUN {command}")
166180
p = subprocess.Popen(
167-
f"/run-{environment}.sh {role} {joined_arguments}",
181+
command,
168182
shell=True,
169183
stdout=subprocess.PIPE,
170184
stderr=subprocess.PIPE,

osism/tasks/reconciler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from celery import Celery
99
from celery.signals import worker_process_init
1010
import kombu.utils
11+
from loguru import logger
1112
from pottery import Redlock
1213
from redis import Redis
1314

@@ -56,6 +57,7 @@ def run(self, publish=True):
5657
)
5758

5859
if lock.acquire(timeout=20):
60+
logger.info("RUN /run.sh")
5961
p = subprocess.Popen(
6062
"/run.sh", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
6163
)
@@ -82,6 +84,7 @@ def run_on_change(self):
8284
)
8385

8486
if lock.acquire(timeout=20):
87+
logger.info("RUN /run.sh")
8588
p = subprocess.Popen(
8689
"/run.sh", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
8790
)

0 commit comments

Comments
 (0)