Bugfix: environments/views on separate mounts (#20720)

Environment views fail when the tmpdir used for view generation is
on a separate mount from the install_tree because the files cannot
by symlinked between the two. The fix is to use an alternative
tmpdir located alongside the view.
This commit is contained in:
Greg Becker 2021-02-10 13:39:11 -08:00 committed by GitHub
parent 5828a2cd31
commit 2b6f896ca7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -556,11 +556,20 @@ def regenerate(self, all_specs, roots):
# that cannot be resolved or have repos that have been removed # that cannot be resolved or have repos that have been removed
# we always regenerate the view from scratch. We must first make # we always regenerate the view from scratch. We must first make
# sure the root directory exists for the very first time though. # sure the root directory exists for the very first time though.
root = self.root root = os.path.normpath(
if not os.path.isabs(root): self.root if os.path.isabs(self.root) else os.path.join(
root = os.path.normpath(os.path.join(self.base, self.root)) self.base, self.root)
)
fs.mkdirp(root) fs.mkdirp(root)
with fs.replace_directory_transaction(root):
# The tempdir for the directory transaction must be in the same
# filesystem mount as the view for symlinks to work. Provide
# dirname(root) as the tempdir for the
# replace_directory_transaction because it must be on the same
# filesystem mount as the view itself. Otherwise it may be
# impossible to construct the view in the tempdir even when it can
# be constructed in-place.
with fs.replace_directory_transaction(root, os.path.dirname(root)):
view = self.view() view = self.view()
view.clean() view.clean()