From 57e1307a3ab9f4d22bd1746e627e8ad7c6d6a6e6 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sat, 16 Feb 2019 11:21:14 -0800 Subject: [PATCH] provision: Fix virtualenv-clone handling of success-stamp. Apparently, virtualenv-clone ends up copying the success-stamp file that we use to track whether a virtualenv was successfully provisioned, which results in problems if we get a network error in the pip install stage afterwards. The comment explains our fix, but basically we just delete success-stamp after the clone. Fixes #11301. --- scripts/lib/setup_venv.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/lib/setup_venv.py b/scripts/lib/setup_venv.py index 20bb0a2828..95d9c686b4 100644 --- a/scripts/lib/setup_venv.py +++ b/scripts/lib/setup_venv.py @@ -218,6 +218,16 @@ def try_to_copy_venv(venv_path, new_packages): # virtualenv-clone isn't working, so just make a new venv return False + # virtualenv-clone, unfortunately, copies the success stamp, + # which means if the upcoming `pip install` phase were to + # fail, we'd end up with a broken half-provisioned virtualenv + # that's incorrectly tagged as properly provisioned. The + # right fix is to use + # https://github.com/edwardgeorge/virtualenv-clone/pull/38, + # but this rm is almost as good. + success_stamp_path = os.path.join(venv_path, 'success-stamp') + run(["sudo", "rm", "-f", success_stamp_path]) + run(["sudo", "chown", "-R", "{}:{}".format(os.getuid(), os.getgid()), venv_path]) source_log = get_logfile_name(source_venv_path)