Skip to content

binary cache: do not create separate spec.json.sig files#34350

Closed
haampie wants to merge 4 commits intospack:developfrom
haampie:binary_cache/do-not-create-separate-spec.json.sig-files
Closed

binary cache: do not create separate spec.json.sig files#34350
haampie wants to merge 4 commits intospack:developfrom
haampie:binary_cache/do-not-create-separate-spec.json.sig-files

Conversation

@haampie
Copy link
Copy Markdown
Member

@haampie haampie commented Dec 6, 2022

There's no reason to generate a separate spec.json.sig file, instead we
can peek into the spec.json file and see if it is clearsigned json.

This PR also changes the iteration order: outer loop iterates over
extension types, inner loop over mirrors, since in time we'd expect
*.json to always be correct, whether signed or unsigned, so on a
(binary) cache hit, at most 1 request per mirror for the specfile is
necessary.

In the future we can stop using spec.json.sig files in general to avoid
404s. (In the near future we could also just add a config option to stop
looking for these spec.json.sig files.)

@spackbot-app spackbot-app bot added binary-packages core PR affects Spack core functionality tests General test capability(ies) labels Dec 6, 2022
@haampie haampie force-pushed the binary_cache/do-not-create-separate-spec.json.sig-files branch from ce971b4 to 77e0c5c Compare December 6, 2022 14:24
@haampie haampie changed the title binary cache/do not create separate spec.json.sig files binary cache: do not create separate spec.json.sig files Dec 6, 2022
@haampie haampie force-pushed the binary_cache/do-not-create-separate-spec.json.sig-files branch 4 times, most recently from d4a1e90 to 0174649 Compare December 6, 2022 14:42
@haampie
Copy link
Copy Markdown
Member Author

haampie commented Dec 6, 2022

Ping @blue42u 🙃

@haampie haampie force-pushed the binary_cache/do-not-create-separate-spec.json.sig-files branch from 0174649 to 896890d Compare December 6, 2022 15:13
There's no reason to generate a separate spec.json.sig file, instead we
can peek into the spec.json file and see if it is clearsigned json.

In th future we can stop using spec.json.sig files in general to avoid
404s.

This also changes the iteration error: outer loop ieraters over
extension types, inner loop over mirrors, since in time we'd expect
*.json to always be correct, whether signed or unsigned.
@haampie haampie force-pushed the binary_cache/do-not-create-separate-spec.json.sig-files branch from 896890d to b8eb655 Compare December 6, 2022 15:17
Copy link
Copy Markdown
Contributor

@scottwittenburg scottwittenburg left a comment

Choose a reason for hiding this comment

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

Thanks @haampie this seems like a good idea 👍 I just have a couple questions, but otherwise like the change.

Co-authored-by: Scott Wittenburg <[email protected]>
@haampie
Copy link
Copy Markdown
Member Author

haampie commented Dec 6, 2022

@scottwittenburg how about this: I'll restore the try_direct_fetch bits in this PR so it's just about going from spec.json.sig to spec.json.

In a separate PR I'll make get_mirrors_for_spec offline.

Offline in the sense that it should only query the local (possibly outdated) info we have about the remote mirror.

As I understand it, that's used as an optimization to improve the order in which mirrors are considered. That's great. What's not great: if we locally have no data about the remote mirror, it's strictly more work to update the local cache than it is to directly fetch in default order. So, obviously this optimization only works given local data, and if there's no local data, the best you can do is fall back to going over the mirror in default order.

@blue42u
Copy link
Copy Markdown
Contributor

blue42u commented Dec 6, 2022

... if we locally have no data about the remote mirror, it's strictly more work to update the local cache than it is to directly fetch in default order.

This statement is false when there are multiple buildcaches configured and all of them are small (< a few MB), which is exactly our use case in HPCToolkit's CI. But it is true that the worst-case scenario is worse if you update the local cache compared to using a default order, so not opposed.

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Dec 7, 2022

This should be ready for review. Only concern is that it's not forward compatible (old spack will fail to deal with clearsigned spec.json file without sig extension), but as far as I know, Spack is never forward compatible.

@scottwittenburg
Copy link
Copy Markdown
Contributor

It occurs to me that if we don't want .spec.json.sig files anymore, we need to change some things about how we do signing with the reputational key as well.

@kotfic Can you chime in on whether you think this will be problematic? Looking around, I think the notary job script needs changed here so we no longer write back .sig files. Is there any problem getting GPG to sign "in place"? I.e. just replace the current .spec.json with the re-signed version?

I'll make a PR to fix all the stacks signing jobs where they refer to the extension, e.g. here. Another case where it will be great to have #34272.

I think due to the way this is implemented, it could be merged before we fix how the notary job signs things with the reputational key, as spack can still handle .spec.json.sig for awhile longer. But I think it means more requests will get made as we look first for .spec.json after this. However, it might make sense to coordinate these changes to go in around the same time.

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Dec 14, 2022

Closing this in favor of #34490 to get better compatibility backward/forward compat

@haampie haampie closed this Dec 14, 2022
@haampie haampie deleted the binary_cache/do-not-create-separate-spec.json.sig-files branch December 14, 2022 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

binary-packages core PR affects Spack core functionality tests General test capability(ies)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants