From 86a07baf40c6e84fd79a83a467802e63a1c46d56 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Mon, 25 Sep 2017 15:11:18 -0700 Subject: [PATCH] zulip_tools: Skip the lock directory. This is the one special directory that usually lives in deployments/ and is not a deployment. Make sure we don't treat it as a deployment. --- scripts/lib/zulip_tools.py | 5 ++++- scripts/purge-old-deployments | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.py index 0f4f5623a5..23bbbe0071 100755 --- a/scripts/lib/zulip_tools.py +++ b/scripts/lib/zulip_tools.py @@ -190,7 +190,10 @@ def get_recent_deployments(threshold_days): threshold_date = datetime.datetime.now() - datetime.timedelta(days=threshold_days) for dir_name in os.listdir(DEPLOYMENTS_DIR): if not os.path.isdir(os.path.join(DEPLOYMENTS_DIR, dir_name)): - # Skip things like uwsgi sockets. + # Skip things like uwsgi sockets, symlinks, etc. + continue + if not os.path.exists(os.path.join(DEPLOYMENTS_DIR, dir_name, "zerver")): + # Skip things like "lock" that aren't actually a deployment directory continue try: date = datetime.datetime.strptime(dir_name, TIMESTAMP_FORMAT) diff --git a/scripts/purge-old-deployments b/scripts/purge-old-deployments index 5341a5c413..247f3b42fd 100755 --- a/scripts/purge-old-deployments +++ b/scripts/purge-old-deployments @@ -46,6 +46,9 @@ def get_deployments_to_be_purged(recent_deployments): if not os.path.isdir(deployment): # Skip things like uwsgi sockets. continue + if not os.path.exists(os.path.join(deployment, "zerver")): + # Skip things like "lock" that aren't actually a deployment directory + continue if deployment not in recent_deployments: deployments_to_purge.add(deployment) return deployments_to_purge