diff options
author | Todd Gamblin <gamblin2@llnl.gov> | 2022-05-18 15:21:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-18 22:21:22 +0000 |
commit | 8ff2b4b747f8640f7c1172f8c7d202280a09981f (patch) | |
tree | 3f3448c3b43a33b6616f4d3dff797c9b142412cd /.gitignore | |
parent | 9e05dde28c568f33af124f3dace428541470400a (diff) | |
download | spack-8ff2b4b747f8640f7c1172f8c7d202280a09981f.tar.gz spack-8ff2b4b747f8640f7c1172f8c7d202280a09981f.tar.bz2 spack-8ff2b4b747f8640f7c1172f8c7d202280a09981f.tar.xz spack-8ff2b4b747f8640f7c1172f8c7d202280a09981f.zip |
bugfix: handle new `dag_hash()` on old concrete specs gracefully. (#30678)
Trying to compute `dag_hash()` or `package_hash()` on a concrete spec that doesn't have
a `_package_hash` attribute would attempt to recompute the package hash.
This most commonly manifests as a failed lookup of a namespace if you attempt to uninstall
or compute the hashes of packages in exsternal repositories that aren't registered, e.g.:
```console
> spack spec --json c/htno
==> Error: Unknown namespace: myrepo
```
While it wouldn't change the already-assigned `dag_hash` value, this behavior is
incorrect, since the package file for a previously concrete spec:
1. might have changed since concretization,
2. might not exist anymore, or
3. might just not be findable by Spack.
This PR ensures that the package hash can't be computed on older concrete specs. Instead
of calling `package_hash()` from within `to_node_dict()`, we now check for the `_package_hash`
attribute and only add the package_hash to the spec record if it's there.
This PR also handles the tricky semantics of computing `package_hash()` at concretization
time. We have to compute it *before* marking the spec concrete so that `to_node_dict` can
use it. But this means that the logic for `package_hash()` can't rely on `spec.concrete`,
as it is called *during* concretization. Instead of checking for concreteness, `package_hash()`
now checks `_patches_assigned()` to determine whether it should add them to the package
hash.
- [x] Add an assert to `package_hash()` so it can't be called on specs for which it
would be wrong.
- [x] Add an `_assign_hash()` method to handle tricky semantics of `package_hash`
and `dag_hash`.
- [x] Rework concretization to call `_assign_hash()` before and after marking specs
concrete.
- [x] Rework content hash part of package hash to check for `_patches_assigned()`
instead of `spec.concrete`.
- [x] regression test
Diffstat (limited to '.gitignore')
0 files changed, 0 insertions, 0 deletions