Skip to content

Allow spec.json files to be clearsigned, use transparent compression for *.json#34490

Merged
haampie merged 2 commits intospack:developfrom
haampie:binary_cache/allow-clearsigned-spec.json-files
Jan 7, 2023
Merged

Allow spec.json files to be clearsigned, use transparent compression for *.json#34490
haampie merged 2 commits intospack:developfrom
haampie:binary_cache/allow-clearsigned-spec.json-files

Conversation

@haampie
Copy link
Copy Markdown
Member

@haampie haampie commented Dec 13, 2022

This PR does two things:

  1. Reduce the number of requests to a mirror for metadata
  2. Make Spack accept gzipped metadata (i.e. transmit fewer bytes)

It does not make any changes to how we create binary caches.
The idea is to allow this PR to be backported.


Currently we have separate spec.json and spec.json.sig files. The
former is a pure spec, the latter is clearsigned spec. This is unfortunate,
cause metadata lookups now requires at most two requests per remote.

Further, update-index logic fetches all spec.json files, which can take
quite some bandwidth. We can drop ~85% of the size by compressing
those files. To avoid yet another lookup (spec.json.sig.gz etc) we can
use transparent decompression. So a file is decompressed when the
magic bytes signal it's gzip, otherwise it's treated as text.

This PR allows spec.json (and index.json) files to be any combination
of the cartesian product [gzip compressed, uncompressed] x
[clearsigned, unsigned].

The idea is to backport this to 0.19.1, since for 0.19.1 it is not a
behavioral change, but rather a bugfix for improved Spack 0.21 forward
compatibility.

Next steps after this PR:

  • Backport to 0.19.1
  • Start uploading spec.json.sig files both as spec.json.sig and
    spec.json. This ensure they work with any Spack version.
  • Compress before pushing (if the filesize is reduced)
  • Deprecate spec.json.sig in 0.20.
  • After Spack 0.20 branches off, stop uploading *.sig, and stop checking
    the remote for *.sig files.
  • Potentially we can also add a config option to disable checking for
    *.sig files on develop earlier.

@spackbot-app spackbot-app bot added binary-packages commands core PR affects Spack core functionality tests General test capability(ies) labels Dec 13, 2022
haampie added a commit to haampie/spack that referenced this pull request Dec 13, 2022
haampie added a commit to haampie/spack that referenced this pull request Dec 13, 2022
@haampie haampie changed the title Allow spec.json files to be clearsigned Allow spec.json files to be clearsigned and compressed Jan 5, 2023
@haampie haampie force-pushed the binary_cache/allow-clearsigned-spec.json-files branch 6 times, most recently from 92bf8c8 to f48b6ca Compare January 5, 2023 14:17
@haampie haampie changed the title Allow spec.json files to be clearsigned and compressed Allow spec.json files to be clearsigned, use transparent compression of *.json Jan 5, 2023
@haampie haampie changed the title Allow spec.json files to be clearsigned, use transparent compression of *.json Allow spec.json files to be clearsigned, use transparent compression for *.json Jan 5, 2023
scottwittenburg
scottwittenburg previously approved these changes Jan 5, 2023
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.

Looks great, thanks @haampie 👍

I just had one question, but feel free to merge regardless.

local_specfile_stage.destroy()
# If it is a clearsign file, we must verify it (unless disabled)
should_verify = not unsigned and is_clearsigned_file(specfile_path)
if should_verify and not try_verify(specfile_path):
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hm, another issue is that this is not yet working, cause it's first clearsigned and then gzipped, so verification requires decompression. Should the order be reverted? Sign the compressed json?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Went with compress(sign(json)) so that we can swap the compression scheme without the need to re-sign the files.

@haampie haampie force-pushed the binary_cache/allow-clearsigned-spec.json-files branch from f48b6ca to 018ba60 Compare January 5, 2023 22:29
haampie and others added 2 commits January 5, 2023 23:36
Currently we have separate `spec.json` and `spec.json.sig` files. The
former is a pure spec, the latter is clearsigned spec. This is a bit
unfortunate, cause a lookup for a spec file now requires two remote
requests (with or without cache).

This PR allows clearsigned `spec.json` files too, and changes otherwise
nothing.

The idea is to backport this to 0.19.1, since for 0.19.1 it is not a
behavioral change, but rather a bugfix for improved 0.20 / 0.21 forward
compatibility.

Next steps after this PR:

- Start uploading spec.json.sig files both as spec.json.sig and
  spec.json. This ensure they work with any Spack version.
- Deprecate spec.json.sig in 0.20.
- After Spack 0.20 branches off, stop uploading *.sig, and stop checking
  the remote for *.sig files.
- Potentially we can also add a config option to disable checking for
  *.sig files on develop earlier.
The files

spec.json / spec.json.sig / index.json

can now be stored gzip compressed (without .gz extension)
@haampie haampie force-pushed the binary_cache/allow-clearsigned-spec.json-files branch from 018ba60 to 6c20ec1 Compare January 5, 2023 22:36
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.

Looks good to my eyeballs 😆 thanks @haampie! I notice the past several gitlab pipelines haven't built anything (as expected), but since this isn't actually changing what we push (still pushing .spec.json.sig, not compressing them yet), this isn't likely to break anything when run in the wild. But it's good preparation for the next steps, thanks again 👍

@haampie haampie merged commit 8a1b817 into spack:develop Jan 7, 2023
@haampie haampie deleted the binary_cache/allow-clearsigned-spec.json-files branch January 7, 2023 11:22
haampie added a commit that referenced this pull request Jan 9, 2023
alalazo pushed a commit that referenced this pull request Jan 9, 2023
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Jan 24, 2023
…for *.json (spack#34490)

This commit allows (remote) spec.json files to be clearsigned and gzipped.

The idea is to reduce the number of requests and number of bytes transferred
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Jan 24, 2023
amd-toolchain-support pushed a commit to amd-toolchain-support/spack that referenced this pull request Feb 16, 2023
…for *.json (spack#34490)

This commit allows (remote) spec.json files to be clearsigned and gzipped.

The idea is to reduce the number of requests and number of bytes transferred
amd-toolchain-support pushed a commit to amd-toolchain-support/spack that referenced this pull request Feb 16, 2023
techxdave pushed a commit to Tech-XCorp/spack that referenced this pull request Feb 17, 2023
…for *.json (spack#34490)

This commit allows (remote) spec.json files to be clearsigned and gzipped.

The idea is to reduce the number of requests and number of bytes transferred
techxdave pushed a commit to Tech-XCorp/spack that referenced this pull request Feb 17, 2023
jmcarcell pushed a commit to key4hep/spack that referenced this pull request Apr 13, 2023
…for *.json (spack#34490)

This commit allows (remote) spec.json files to be clearsigned and gzipped.

The idea is to reduce the number of requests and number of bytes transferred
jmcarcell pushed a commit to key4hep/spack that referenced this pull request Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants