Skip to content

buildcache: skip unrecognized metadata files#40941

Merged
haampie merged 5 commits intospack:developfrom
scottwittenburg:buildcache-version-check-backport
Nov 9, 2023
Merged

buildcache: skip unrecognized metadata files#40941
haampie merged 5 commits intospack:developfrom
scottwittenburg:buildcache-version-check-backport

Conversation

@scottwittenburg
Copy link
Copy Markdown
Contributor

@scottwittenburg scottwittenburg commented Nov 7, 2023

This PR ensures that unrecognized metadata files do not cause download failure, but are skipped.

This improves forward compatibility with future metadata formats.

@spackbot-app spackbot-app bot added binary-packages core PR affects Spack core functionality tests General test capability(ies) labels Nov 7, 2023
@scottwittenburg
Copy link
Copy Markdown
Contributor Author

fyi @kwryankrattiger

@scottwittenburg scottwittenburg force-pushed the buildcache-version-check-backport branch from ee6fad6 to 934b4b7 Compare November 7, 2023 23:50
@scottwittenburg scottwittenburg force-pushed the buildcache-version-check-backport branch from 934b4b7 to 5ea0da6 Compare November 9, 2023 00:25
@scottwittenburg

This comment was marked as resolved.

@haampie

This comment was marked as resolved.

@haampie

This comment was marked as resolved.

@haampie haampie added this to the v0.21.0 milestone Nov 9, 2023
@haampie
Copy link
Copy Markdown
Member

haampie commented Nov 9, 2023

@scottwittenburg given the lack of time I took over your PR instead of reviewing it.

@haampie haampie changed the title buildcache: allow older spack to warn when buildcache version is too new buildcache: skip unrecognized metadata files Nov 9, 2023
@haampie haampie mentioned this pull request Nov 9, 2023
10 tasks
Copy link
Copy Markdown
Member

@alalazo alalazo left a comment

Choose a reason for hiding this comment

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

I didn't test this extensively, but from a first read it seems fine. I just left a few comments that, in case, can be addressed in a later PR.


# Ensure this version is not too new.
try:
layout_version = int(spec_dict.get("buildcache_layout_version", 0))
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.

(Not a request, just a comment) Do we have any formal specification (a schema?) of what a spec_dict looks like?

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 believe there was, but pretty sure it's unused or outdated

Comment on lines +1697 to +1700
_get_valid_spec_file(
local_specfile_stage.save_filename,
CURRENT_BUILD_CACHE_LAYOUT_VERSION,
)
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.

(Just a comment) Wondering if we can turn this double nested try/except into a context manager


def build_cache_relative_path():
return _build_cache_relative_path
return BUILD_CACHE_RELATIVE_PATH
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.

(minor) This function and the one below are probably unnecessary

else:
raise ValueError("{0} not a valid spec file type".format(spec_file))
spec_dict["buildcache_layout_version"] = 1
spec_dict["buildcache_layout_version"] = CURRENT_BUILD_CACHE_LAYOUT_VERSION
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.

(Minor) We should probably decide whether it's buildcache or build_cache

shutil.rmtree(tmpdir)
raise e
else:
elif layout_version == 1:
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.

Do we need an else case here for unknown layouts?

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.

That already throws earlier

@haampie haampie enabled auto-merge (squash) November 9, 2023 13:01
@haampie haampie merged commit 1baed0d into spack:develop Nov 9, 2023
haampie added a commit that referenced this pull request Nov 9, 2023
This commit improves forward compatibility of Spack with newer build cache metadata formats.

Before this commit, invalid or unrecognized metadata would be fatal errors, now they just cause
a mirror to be skipped.

Co-authored-by: Harmen Stoppels <[email protected]>
haampie added a commit that referenced this pull request Nov 9, 2023
This commit improves forward compatibility of Spack with newer build cache metadata formats.

Before this commit, invalid or unrecognized metadata would be fatal errors, now they just cause
a mirror to be skipped.

Co-authored-by: Harmen Stoppels <[email protected]>
@scottwittenburg scottwittenburg deleted the buildcache-version-check-backport branch November 9, 2023 17:26
tgamblin pushed a commit that referenced this pull request Nov 11, 2023
This commit improves forward compatibility of Spack with newer build cache metadata formats.

Before this commit, invalid or unrecognized metadata would be fatal errors, now they just cause
a mirror to be skipped.

Co-authored-by: Harmen Stoppels <[email protected]>
gabrielctn pushed a commit to gabrielctn/spack that referenced this pull request Nov 24, 2023
This commit improves forward compatibility of Spack with newer build cache metadata formats.

Before this commit, invalid or unrecognized metadata would be fatal errors, now they just cause
a mirror to be skipped.

Co-authored-by: Harmen Stoppels <[email protected]>
mtaillefumier pushed a commit to mtaillefumier/spack that referenced this pull request Dec 14, 2023
This commit improves forward compatibility of Spack with newer build cache metadata formats.

Before this commit, invalid or unrecognized metadata would be fatal errors, now they just cause
a mirror to be skipped.

Co-authored-by: Harmen Stoppels <[email protected]>
vjranagit pushed a commit to vjranagit/spack that referenced this pull request Jan 18, 2026
This commit improves forward compatibility of Spack with newer build cache metadata formats.

Before this commit, invalid or unrecognized metadata would be fatal errors, now they just cause
a mirror to be skipped.

Co-authored-by: Harmen Stoppels <[email protected]>
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