Skip to content

Fix location in spec.yaml where we look for full_hash#19132

Merged
scottwittenburg merged 1 commit intodevelopfrom
bindist-fix-needs-rebuild
Oct 2, 2020
Merged

Fix location in spec.yaml where we look for full_hash#19132
scottwittenburg merged 1 commit intodevelopfrom
bindist-fix-needs-rebuild

Conversation

@scottwittenburg
Copy link
Copy Markdown
Contributor

When we attempt to determine whether a remote spec (in a binary mirror)
is up-to-date or needs to be rebuilt, we compare the full_hash stored in
the remote spec.yaml file against the full_hash computed from the local
concrete spec. Since the full_hash moved into the spec (and is no longer
at the top level of the spec.yaml), we need to look there for it. This
oversight from #18359 was causing all specs to get rebuilt when the
full_hash wasn't fouhd at the expected location.

@scottwittenburg
Copy link
Copy Markdown
Contributor Author

@haampie @eugeneswalker This fixes the needs_rebuild issue (#19128) I introduced with #18359, at least for me. But I also added a test, since we were missing one, which is why the bug slipped in.

If one of you can verify it fixes the issue for you as well, that would be great.

Copy link
Copy Markdown
Member

@becker33 becker33 left a comment

Choose a reason for hiding this comment

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

Mostly looks good. A couple small requests.

Comment on lines +1412 to +1415
cached_pkg_specs = [item[name] for item in yaml_spec if name in item]
cached_target = cached_pkg_specs[0] if cached_pkg_specs else None
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.

This list comprehension is doing a lot of heavy lifting. Can you add a comment to explain why it works for future maintainability. At first glance it's not clear why you're using a list at all, although I think I've convinced myself it's necessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think I know why the spec in the buildcache spec.yaml file is a list. I know I wrote the schema for that thing not too long ago, but I just made it match the pre-existing structure I saw in those files already. In the database, spec is instead an object, with what appears to ever only be a single key, the package name.

@gartung Were you involved in coming up with the buildcache spec.yaml file format? Or are you otherwise aware of any reason the spec in there should be a list? As far as I know, it's supposed to correspond to the binary package for a single concrete spec.

At any rate, because it's a list, I took the approach above to get my hands on the spec so I could get at the full_hash. I've only ever seen that list have a single element, so I guess I could also just assume there will ever be only one element and just grab the first one.

@becker33 Let me know if you want me to rework this a bit, otherwise I'll just add a comment summarizing the above.

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.

The comment looks good. I was fine with the code, it just took long enough to parse that it warranted a comment.

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.

Sorry I don't recall.

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.

As far as I recall, the spec is taken from spec.yaml in .spaclk for the patckage

spec_file = os.path.join(spec.prefix, ".spack", "spec.yaml")

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.

Then the buildcache tarball checksum and whether it uses relative rpaths is added as dictionary entries to the spec

spec_dict = yaml.load(content)

I am not sure why it is being interpreted as a list. Maybe my understanding of how yaml files are interpreted was incorrect.

Comment on lines +613 to +614
uninstall_cmd('-y', s.name)
mirror_cmd('rm', 'test-mirror')
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 think the install_mockery and mutable_config fixtures will take care of this. If there aren't existing fixtures that can handle this, we need to add new ones. This code will not be run if the test fails.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It seems the fixture the test is using now, install_mockery_mutable_config, does in fact take care of this, so I removed those lines.

When we attempt to determine whether a remote spec (in a binary mirror)
is up-to-date or needs to be rebuilt, we compare the full_hash stored in
the remote spec.yaml file against the full_hash computed from the local
concrete spec.  Since the full_hash moved into the spec (and is no longer
at the top level of the spec.yaml), we need to look there for it.  This
oversight from #18359 was causing all specs to get rebuilt when the
full_hash wasn't fouhd at the expected location.
@scottwittenburg scottwittenburg force-pushed the bindist-fix-needs-rebuild branch from 28a815d to 373938b Compare October 2, 2020 19:48
@scottwittenburg
Copy link
Copy Markdown
Contributor Author

@becker33 Mind approving when you get a minute, assuming you're ok with the changes?

@scottwittenburg scottwittenburg merged commit 7cfdf61 into develop Oct 2, 2020
@scottwittenburg scottwittenburg deleted the bindist-fix-needs-rebuild branch October 2, 2020 21:37
scottwittenburg added a commit that referenced this pull request Oct 5, 2020
scheibelp pushed a commit that referenced this pull request Oct 5, 2020
This reverts #18359 and follow-on PRs intended to address issues with
#18359 because that PR changes the hash of all specs. A future PR will
reintroduce the changes.

* Revert "Fix location in spec.yaml where we look for full_hash (#19132)"
* Revert "Fix fetch of spec.yaml files from buildcache (#19101)"
* Revert "Merge pull request #18359 from scottwittenburg/add-binary-distribution-cache-manager"
scottwittenburg added a commit that referenced this pull request Oct 6, 2020
When we attempt to determine whether a remote spec (in a binary mirror)
is up-to-date or needs to be rebuilt, we compare the full_hash stored in
the remote spec.yaml file against the full_hash computed from the local
concrete spec.  Since the full_hash moved into the spec (and is no longer
at the top level of the spec.yaml), we need to look there for it.  This
oversight from #18359 was causing all specs to get rebuilt when the
full_hash wasn't fouhd at the expected location.
scottwittenburg added a commit to scottwittenburg/spack that referenced this pull request Oct 16, 2020
When we attempt to determine whether a remote spec (in a binary mirror)
is up-to-date or needs to be rebuilt, we compare the full_hash stored in
the remote spec.yaml file against the full_hash computed from the local
concrete spec.  Since the full_hash moved into the spec (and is no longer
at the top level of the spec.yaml), we need to look there for it.  This
oversight from spack#18359 was causing all specs to get rebuilt when the
full_hash wasn't fouhd at the expected location.
scottwittenburg added a commit to scottwittenburg/spack that referenced this pull request Oct 23, 2020
When we attempt to determine whether a remote spec (in a binary mirror)
is up-to-date or needs to be rebuilt, we compare the full_hash stored in
the remote spec.yaml file against the full_hash computed from the local
concrete spec.  Since the full_hash moved into the spec (and is no longer
at the top level of the spec.yaml), we need to look there for it.  This
oversight from spack#18359 was causing all specs to get rebuilt when the
full_hash wasn't fouhd at the expected location.
scottwittenburg added a commit to scottwittenburg/spack that referenced this pull request Oct 29, 2020
When we attempt to determine whether a remote spec (in a binary mirror)
is up-to-date or needs to be rebuilt, we compare the full_hash stored in
the remote spec.yaml file against the full_hash computed from the local
concrete spec.  Since the full_hash moved into the spec (and is no longer
at the top level of the spec.yaml), we need to look there for it.  This
oversight from spack#18359 was causing all specs to get rebuilt when the
full_hash wasn't fouhd at the expected location.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants