From 689375a2fe8bec7927f24060f00632078174010c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 20 Dec 2020 19:17:03 +0100 Subject: [PATCH] Fix the config task --- uncloud/tasks.py | 11 ++++++++--- uncloud_net/tasks.py | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/uncloud/tasks.py b/uncloud/tasks.py index 8350354..5a13ec5 100644 --- a/uncloud/tasks.py +++ b/uncloud/tasks.py @@ -3,11 +3,16 @@ from celery.result import AsyncResult from .models import UncloudTask -@shared_task -def cleanup_tasks(): - print("Cleanup time") +@shared_task(bind=True) +def cleanup_tasks(self): + print(f"Cleanup time from {self}: {self.request.id}") for task in UncloudTask.objects.all(): print(f"Pruning {task}...") + + if str(task.task_id) == str(self.request.id): + print("Skipping myself") + continue + res = AsyncResult(id=str(task.task_id)) if res.ready(): print(res.get()) diff --git a/uncloud_net/tasks.py b/uncloud_net/tasks.py index 529c525..67d11ae 100644 --- a/uncloud_net/tasks.py +++ b/uncloud_net/tasks.py @@ -49,7 +49,7 @@ def cdist_configure_wireguard_server(config, server): log.debug("git committing wireguard changes") - subprocess.run(f"cd /aa{dirname} && git pull && git add {server} && git commit -m 'Updating config for ${server}' && git push", + subprocess.run(f"cd {dirname} && git pull && git add {server} && git commit -m 'Updating config for ${server}' && git push", shell=True, check=True) log.debug(f"Configuring VPN server {server} with cdist") @@ -58,4 +58,4 @@ def cdist_configure_wireguard_server(config, server): # FIXME: # ensure logs are on the server # ensure exit codes are known - return "All good" + return True