Skip to content

Commit

Permalink
Add logging output to tasks that start scripts in workers (#691)
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Berendt <[email protected]>
  • Loading branch information
berendt authored Nov 17, 2023
1 parent 693d8be commit b20c656
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
28 changes: 21 additions & 7 deletions osism/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import os
from pathlib import Path
import subprocess
from osism import settings

from celery.signals import worker_process_init
from loguru import logger
from redis import Redis
from pottery import Redlock

from osism import settings

redis = None


Expand Down Expand Up @@ -104,16 +106,20 @@ def run_ansible_in_environment(
lock.acquire()

if role == "mariadb_backup":
command = f"/run.sh backup {role} {joined_arguments}"
logger.info(f"RUN {command}")
p = subprocess.Popen(
f"/run.sh backup {role} {joined_arguments}",
command,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=env,
)
else:
command = f"/run.sh deploy {role} {joined_arguments}"
logger.info(f"RUN {command}")
p = subprocess.Popen(
f"/run.sh deploy {role} {joined_arguments}",
command,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Expand All @@ -125,8 +131,10 @@ def run_ansible_in_environment(
if locking:
lock.acquire()

command = f"/run.sh {role} {joined_arguments}"
logger.info(f"RUN {command}")
p = subprocess.Popen(
f"/run.sh {role} {joined_arguments}",
command,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Expand All @@ -139,8 +147,10 @@ def run_ansible_in_environment(
and environment == "manager"
and role == "bifrost-command"
):
command = f'/run-manager.sh bifrost-command "-e bifrost_arguments=\'{joined_arguments}\'" "-e bifrost_result_id={request_id}"'
logger.info(f"RUN {command}")
p = subprocess.Popen(
f'/run-manager.sh bifrost-command "-e bifrost_arguments=\'{joined_arguments}\'" "-e bifrost_result_id={request_id}"',
command,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Expand All @@ -151,8 +161,10 @@ def run_ansible_in_environment(
if locking:
lock.acquire()

command = f"/run-{environment}.sh {role} {joined_arguments}"
logger.info(f"RUN {command}")
p = subprocess.Popen(
f"/run-{environment}.sh {role} {joined_arguments}",
command,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Expand All @@ -163,8 +175,10 @@ def run_ansible_in_environment(
if locking:
lock.acquire()

command = f"/run-{environment}.sh {role} {joined_arguments}"
logger.info(f"RUN {command}")
p = subprocess.Popen(
f"/run-{environment}.sh {role} {joined_arguments}",
command,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Expand Down
3 changes: 3 additions & 0 deletions osism/tasks/reconciler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from celery import Celery
from celery.signals import worker_process_init
import kombu.utils
from loguru import logger
from pottery import Redlock
from redis import Redis

Expand Down Expand Up @@ -56,6 +57,7 @@ def run(self, publish=True):
)

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

if lock.acquire(timeout=20):
logger.info("RUN /run.sh")
p = subprocess.Popen(
"/run.sh", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
)
Expand Down

0 comments on commit b20c656

Please sign in to comment.