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.
This commit is contained in:
Tim Abbott 2019-02-16 11:21:14 -08:00
parent 4de04c460a
commit 57e1307a3a
1 changed files with 10 additions and 0 deletions

View File

@ -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)