Skip to content

stage: fix resources being deleted from local cache#10152

Merged
scheibelp merged 2 commits intospack:developfrom
michaelkuhn:resource-cache
Jan 5, 2019
Merged

stage: fix resources being deleted from local cache#10152
scheibelp merged 2 commits intospack:developfrom
michaelkuhn:resource-cache

Conversation

@michaelkuhn
Copy link
Copy Markdown
Member

Resources can be deleted from the local cache because ResourceStage moves its resources to the root stage instead of copying them. If a locally cached resource exists, it is symlinked into the resource stage and then moved out of the local cache. This can be reproduced with the following commands:

  1. spack stage sqlite+functions (fetches archive and resource)
  2. spack clean
  3. spack stage sqlite+functions (uses locally cached versions)
  4. spack clean
  5. spack stage sqlite+functions (fetches resource again)

src = os.path.realpath(source_path)

if os.path.isdir(src):
copy_tree(src, destination_path)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity why doesn't copy handle this distinction?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I can't think of a reason why we couldn't redesign copy and install to support both files and directories. It's just a design choice. For comparison, Python's shutil library has separate copy and copytree methods. Python's distutils library also has separate dir_util.copy_tree and file_util.copy_file methods.

michaelkuhn and others added 2 commits January 4, 2019 16:07
Non-expanded resources were being deleted from the cache on account
of two behaviors:

* ResourceStage was moving files rather than copying them, and uses
  "os.path.realpath" to resolve symlinks
* CacheFetchStrategy creates a symlink to a cached resource rather
  than copying it

This alters the first behavior: ResourceStage now copies the file
rather than moving it.
@scheibelp scheibelp merged commit 64deda1 into spack:develop Jan 5, 2019
@scheibelp
Copy link
Copy Markdown
Member

Thanks!

scheibelp pushed a commit that referenced this pull request Jan 5, 2019
Non-expanded resources were being deleted from the cache on account
of two behaviors:

* ResourceStage was moving files rather than copying them, and uses
  "os.path.realpath" to resolve symlinks
* CacheFetchStrategy creates a symlink to a cached resource rather
  than copying it

This alters the first behavior: ResourceStage now copies the file
rather than moving it.
scheibelp pushed a commit that referenced this pull request Jan 9, 2019
Fixes #10284

#10152 replaced shutil.move with llnl's copy and copy_tree for
resources. This did not copy permissions so led to later failures
if an executable was copied (e.g. a configure script). This uses
install/install_tree instead, which preserve permissions.
gonsie pushed a commit that referenced this pull request Jan 15, 2019
Non-expanded resources were being deleted from the cache on account
of two behaviors:

* ResourceStage was moving files rather than copying them, and uses
  "os.path.realpath" to resolve symlinks
* CacheFetchStrategy creates a symlink to a cached resource rather
  than copying it

This alters the first behavior: ResourceStage now copies the file
rather than moving it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants