Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pulling not respecting setting #3472

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

a1994sc
Copy link
Contributor

@a1994sc a1994sc commented Feb 5, 2025

Description

Address zarf package pull not respecting .metadata.uncompressed package setting

Related Issue

Fixes #3464

Checklist before merging

@a1994sc a1994sc marked this pull request as ready for review February 5, 2025 15:56
@a1994sc a1994sc requested review from a team as code owners February 5, 2025 15:56
Copy link

netlify bot commented Feb 5, 2025

Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit 12d7dff
🔍 Latest deploy log https://app.netlify.com/sites/zarf-docs/deploys/67a6a88cd579320008d88775

@@ -84,6 +84,22 @@ func Pull(ctx context.Context, src, dir, shasum string, filter filters.Component
if err != nil && !errors.Is(err, os.ErrNotExist) {
return err
}
if strings.HasSuffix(name, ".tar") {
Copy link
Contributor

Choose a reason for hiding this comment

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

We want to avoid another unarchive and archive, as this can be quite costly depending on how big the package is, I've heard of 100+GB packages for example. Instead I believe this would be solved by changing the constant .data.tar.zst and the function nameFromMetadata depending on the value of .metadata.compressed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left some mental notes in the issue that I will bring over:

#3464 (comment)

[R]eviewing the code a bit, I think that it has something to do with:

tmpPath := filepath.Join(tmpDir, "data.tar.zst")

though it does lead to a bit of a chicken and egg problem as we would need to determine the file extension by checking the .metadata.uncompressed but the code needs a local file to check...

So I guess is there a cleaner way to check the zarf.yaml of a remote artifact other then checking locally?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah gotcha, yeah packages published to https will already be compressed/uncompressed correctly, whereas oci packages are not compressed as the files comprising the packages are in oci layers. I would move the nameFromMetadata functions into pullOCI and pullHTTP and have these functions take in a directory rather than complete path then name / rename accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I will give it a try over the weekend and see if that helps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm, doing some thinking and should the updated function look something like this?

func pullOCI(ctx context.Context, src, tmpPath, shasum string, filter filters.ComponentFilterStrategy) (bool, string, error)

basically it still return the isPartial bool the error but adds a new tarPath string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure it is the prettiest way to go about it, but I think that I added the logic needed to determine the file type with both http(s) and oci pulls

@a1994sc a1994sc force-pushed the hotfix/pull-uncompressed branch from 7d41fa3 to ee1caf0 Compare February 7, 2025 20:36
}
return isPartial, nil
return isPartial, tarPath, nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AustinAbro321 does this look like a the direction that you wanted to go?

@a1994sc a1994sc force-pushed the hotfix/pull-uncompressed branch from aebc000 to 12d7dff Compare February 8, 2025 00:42
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.

.metadata.uncompressed is not being respected when pulled from OCI repo
2 participants