Visitar URL original
fix: avoid errors when `--max-package-size` differs between create runs by AustinAbro321 · Pull Request #3398 · zarf-dev/zarf · GitHub
Skip to content

fix: avoid errors when --max-package-size differs between create runs - #3398

Merged
AustinAbro321 merged 8 commits into
mainfrom
fix-split-file
Jan 27, 2025
Merged

AustinAbro321 merged 8 commits into
mainfrom
fix-split-file

Conversation

@AustinAbro321

Copy link
Copy Markdown
Member

Description

As seen explained in #3266 the existing split file logic doesn't replace files it writes over leading to errors with create is run with different --max-package-size values. Additionally, if the package is split and there are more files than Zarf is expecting (likely leftovers from a previous run) Zarf will give the below error

     ERROR:  failed to deploy package: unable to load the package: package is missing parts, expected 15, found
             29

Related Issue

Fixes #3266

Checklist before merging

Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
@AustinAbro321
AustinAbro321 requested review from a team as code owners January 13, 2025 17:23
@netlify

netlify Bot commented Jan 13, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit 2920864
🔍 Latest deploy log https://app.netlify.com/sites/zarf-docs/deploys/6793d09b382c1600087a0d32

Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
@codecov

codecov Bot commented Jan 13, 2025 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 53.33333% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/internal/packager2/layout/create.go 57.14% 4 Missing and 2 partials ⚠️
src/internal/packager2/layout/package.go 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/internal/packager2/layout/package.go 39.03% <0.00%> (ø)
src/internal/packager2/layout/create.go 31.47% <57.14%> (+6.63%) ⬆️

... and 64 files with indirect coverage changes

@AustinAbro321 AustinAbro321 changed the title fix: avoid errors when --max-package-size differs between runs fix: avoid errors when --max-package-size differs between create runs Jan 13, 2025
@AustinAbro321
AustinAbro321 marked this pull request as draft January 16, 2025 14:52
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
@AustinAbro321
AustinAbro321 marked this pull request as ready for review January 16, 2025 16:54
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>

@mkcp mkcp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

func TestSplitFile(t *testing.T) {
t.Parallel()

tests := []struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great test cases 👍

t.Run(tt.name, func(t *testing.T) {
t.Parallel()

dir := t.TempDir()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nonblocking: this is more of a style thing, but usually I add some small intent comment (example below) on a series of logically similar operations. There's tradeoffs here with just making self-documenting code, so I'm curious where your opinions are at there.

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.

I think it's a reasonable thing to do. I try to break up my tests with indentation and the arrange-act-assert methodology. I don't think comments are always necessary, but when code is non intuitive I do think it helps to provide additional context.

In this case, this test case was actually from packager1 so I just copied it over, going forward I'll try to air on the side of more clarity.

err = splitFile(context.Background(), p, tt.chunkSize)
require.NoError(t, err)

_, err = os.Stat(p)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

e.g.

// Ensure content exists

data := make([]byte, 50)
err := os.WriteFile(inputFilename, data, 0644)
require.NoError(t, err)
// Create many fake split files

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@AustinAbro321
AustinAbro321 added this pull request to the merge queue Jan 27, 2025
Merged via the queue into main with commit e09ed2c Jan 27, 2025
@AustinAbro321
AustinAbro321 deleted the fix-split-file branch January 27, 2025 13:41
nevinaragam pushed a commit to nevinaragam/zarf that referenced this pull request May 20, 2025
…ns (zarf-dev#3398)

Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
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.

Rerunning package create with --max-package-size leaves old files around

2 participants