Skip to content

fix: pulling not respecting "uncompressed" setting in metadata#3472

Merged
AustinAbro321 merged 11 commits intozarf-dev:mainfrom
a1994sc:hotfix/pull-uncompressed
Feb 13, 2025
Merged

fix: pulling not respecting "uncompressed" setting in metadata#3472
AustinAbro321 merged 11 commits intozarf-dev:mainfrom
a1994sc:hotfix/pull-uncompressed

Conversation

@a1994sc
Copy link
Copy Markdown
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

Signed-off-by: Allen Conlon <software@conlon.dev>
@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
@netlify
Copy link
Copy Markdown

netlify bot commented Feb 5, 2025

Deploy Preview for zarf-docs canceled.

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

Signed-off-by: Allen Conlon <software@conlon.dev>
@a1994sc a1994sc force-pushed the hotfix/pull-uncompressed branch from 7d41fa3 to ee1caf0 Compare February 7, 2025 20:36
Signed-off-by: Allen Conlon <software@conlon.dev>
@a1994sc a1994sc force-pushed the hotfix/pull-uncompressed branch from aebc000 to 12d7dff Compare February 8, 2025 00:42
@a1994sc a1994sc changed the title fix: pulling not respecting setting fix: pulling not respecting "uncompressed" setting in metadata Feb 10, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 10, 2025

Codecov Report

Attention: Patch coverage is 34.37500% with 42 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/internal/packager2/pull.go 35.48% 34 Missing and 6 partials ⚠️
src/internal/packager2/load.go 0.00% 2 Missing ⚠️
Files with missing lines Coverage Δ
src/internal/packager2/load.go 57.14% <0.00%> (ø)
src/internal/packager2/pull.go 33.47% <35.48%> (+4.83%) ⬆️

Signed-off-by: Allen Conlon <software@conlon.dev>
@a1994sc a1994sc force-pushed the hotfix/pull-uncompressed branch from e3a273a to b8d559a Compare February 10, 2025 22:06
Signed-off-by: Allen Conlon <software@conlon.dev>
AustinAbro321
AustinAbro321 previously approved these changes Feb 11, 2025
Copy link
Copy Markdown
Member

@AustinAbro321 AustinAbro321 left a comment

Choose a reason for hiding this comment

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

LGTM, nice work. Going to ask another member of my team to give it a look before merge

@a1994sc
Copy link
Copy Markdown
Contributor Author

a1994sc commented Feb 11, 2025

I will see if I can track down that windows test failing....

Going to leave these to find easier in the future:

test-unit

=== NAME  TestPull
    pull_test.go:43: 
        	Error Trace:	D:/a/zarf/zarf/src/internal/packager2/pull_test.go:43
        	Error:      	Received unexpected error:
        	            	rename C:\Users\RUNNER~1\AppData\Local\Temp\zarf-1793982925\data C:\Users\RUNNER~1\AppData\Local\Temp\zarf-1793982925\data.tar.zst: The process cannot access the file because it is being used by another process.
        	Test:       	TestPull
--- FAIL: TestPull (0.04s)
=== CONT  TestIdentifySource/oci
=== CONT  TestIdentifySource/local_tar
=== CONT  TestLoadPackage/split
=== NAME  TestPullUncompressed
    pull_test.go:74: 
        	Error Trace:	D:/a/zarf/zarf/src/internal/packager2/pull_test.go:74
        	Error:      	Received unexpected error:
        	            	rename C:\Users\RUNNER~1\AppData\Local\Temp\zarf-2664840283\data C:\Users\RUNNER~1\AppData\Local\Temp\zarf-2664840283\data.tar: The process cannot access the file because it is being used by another process.
        	Test:       	TestPullUncompressed

test-e2e-without-cluster

2025-02-11 14:52:30 ERR rename C:\Users\RUNNER~1\AppData\Local\Temp\zarf-284784713\zarf-3669846076\data C:\Users\RUNNER~1\AppData\Local\Temp\zarf-284784713\zarf-3669846076\data.tar.zst: The process cannot access the file because it is being used by another process.
=== NAME  TestUseCLI/zarf_package_pull_https
    00_use_cli_test.go:70: 
        	Error Trace:	D:/a/zarf/zarf/src/test/e2e/00_use_cli_test.go:70
        	Error:      	Received unexpected error:
        	            	exit status 1
        	Test:       	TestUseCLI/zarf_package_pull_https

}
return nil

mtype, err := mimetype.DetectFile(tarPath)
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.

Windows doesn't allow renaming of an already opened file. Rather than defer f.close you will have to run f.close anywhere after the io.Copy

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.

gotcha... I will have an update to the function before this afternoon for the team to review

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 moved the f.Close() to after

_, err = io.Copy(f, resp.Body)

and added f.Close() on error returns. Let me know if that helps

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.

Ah yes, good catch to make sure the files close in the error case. Still, I feel it would be simpler if we moved the code from the os.Create call to the io.Copy call into it's own function. This way we can use defer and avoid the several f.close calls in each error case.

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.

Gotcha, I will see if I can encapsulate that logic

Copy link
Copy Markdown
Contributor Author

@a1994sc a1994sc Feb 11, 2025

Choose a reason for hiding this comment

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

Moved that logic to its own function, I believe that should address the windows issues.... fingers crossed

Signed-off-by: Allen Conlon <software@conlon.dev>
Signed-off-by: Allen Conlon <software@conlon.dev>
Signed-off-by: Allen Conlon <software@conlon.dev>
@a1994sc a1994sc force-pushed the hotfix/pull-uncompressed branch from e98d876 to 13c632c Compare February 11, 2025 21:08
AustinAbro321
AustinAbro321 previously approved these changes Feb 12, 2025
Copy link
Copy Markdown
Member

@AustinAbro321 AustinAbro321 left a comment

Choose a reason for hiding this comment

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

LGTM, nice work

@a1994sc
Copy link
Copy Markdown
Contributor Author

a1994sc commented Feb 12, 2025

Thank you!

Signed-off-by: Allen Conlon <software@conlon.dev>
@AustinAbro321 AustinAbro321 added this pull request to the merge queue Feb 13, 2025
Merged via the queue into zarf-dev:main with commit 8a09e8d Feb 13, 2025
26 checks passed
nevinaragam pushed a commit to nevinaragam/zarf that referenced this pull request May 20, 2025
…dev#3472)

Signed-off-by: Allen Conlon <software@conlon.dev>
Signed-off-by: NevinAragam <nevin.aragam@gmail.com>
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

3 participants