From 136f44424762ff5b9d7d17f5d119754feed9530b Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Tue, 21 Apr 2020 10:58:12 +0200 Subject: [PATCH] copr-be: bugfix cleanup-unused-vms-from-redis Since can be empty for some reason, handle that case. --- roles/copr/backend/templates/cleanup-unused-vms-from-redis | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/roles/copr/backend/templates/cleanup-unused-vms-from-redis b/roles/copr/backend/templates/cleanup-unused-vms-from-redis index a628f25f3b..225c7665be 100644 --- a/roles/copr/backend/templates/cleanup-unused-vms-from-redis +++ b/roles/copr/backend/templates/cleanup-unused-vms-from-redis @@ -36,8 +36,11 @@ for worker; do since=$(redis-cli hget "$worker" in_use_since) - remove=$(python -c "import time; out = ':' if time.time() - $since > 1800 else 'false'; print(out)") + # race, hopefully - the in_use_since field is not yet set even though the + # worker is assigned to build + test -n "$since" || continue + remove=$(python -c "import time; out = ':' if time.time() - $since > 1800 else 'false'; print(out)") ! $remove && continue echo >&2 "REMOVING $since -- $worker"