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

Bug: max read sized reached when importing layer with very large files ss #617

Closed
raharper opened this issue May 8, 2024 · 1 comment · Fixed by #618
Closed

Bug: max read sized reached when importing layer with very large files ss #617

raharper opened this issue May 8, 2024 · 1 comment · Fixed by #618
Labels

Comments

@raharper
Copy link
Contributor

raharper commented May 8, 2024

stacker version

stacker version stacker v1.0.0-rc13-86ba851 liblxc cb8e38aca27a23964941f0f011a8919aab8bebab

Describe the bug

When a stacker layer has a file > 10G, the following stack trace shows:

error: max read size reached
error: exit status 1
stackerbuild.io/stacker/pkg/container.MaybeRunInNamespace
        /stacker-tree/pkg/container/userns.go:102
main.main.func3
        /stacker-tree/cmd/stacker/main.go:324
github.com/urfave/cli/v2.(*Command).Run
        /stacker-tree/.build/gopath/pkg/mod/github.com/urfave/cli/[email protected]/command.go:213
github.com/urfave/cli/v2.(*App).RunContext
        /stacker-tree/.build/gopath/pkg/mod/github.com/urfave/cli/[email protected]/app.go:332
github.com/urfave/cli/v2.(*App).Run
        /stacker-tree/.build/gopath/pkg/mod/github.com/urfave/cli/[email protected]/app.go:309
main.main
        /stacker-tree/cmd/stacker/main.go:329
runtime.main
        /usr/lib/go/src/runtime/proc.go:267
runtime.goexit
        /usr/lib/go/src/runtime/asm_amd64.s:1650

I eventually tracked this down to an error from github.com/udhos/equalfile

https://github.com/udhos/equalfile/blob/90a7461a2a226fa62eca6e350b5207ae9c78fff8/equalfile.go#L390

The default max read size in equalfile is 10^10

https://github.com/udhos/equalfile/blob/90a7461a2a226fa62eca6e350b5207ae9c78fff8/equalfile.go#L12

It looks like there are some equalfile Options struct which can use a "Limited Reader" to avoid the max size limit.

To reproduce

  1. Configuration

  2. Client tool used

  3. Seen error

error: max read size reached
error: exit status 1
stackerbuild.io/stacker/pkg/container.MaybeRunInNamespace
        /stacker-tree/pkg/container/userns.go:102
main.main.func3
        /stacker-tree/cmd/stacker/main.go:324
github.com/urfave/cli/v2.(*Command).Run
        /stacker-tree/.build/gopath/pkg/mod/github.com/urfave/cli/[email protected]/command.go:213
github.com/urfave/cli/v2.(*App).RunContext
        /stacker-tree/.build/gopath/pkg/mod/github.com/urfave/cli/[email protected]/app.go:332
github.com/urfave/cli/v2.(*App).Run
        /stacker-tree/.build/gopath/pkg/mod/github.com/urfave/cli/[email protected]/app.go:309
main.main
        /stacker-tree/cmd/stacker/main.go:329
runtime.main
        /usr/lib/go/src/runtime/proc.go:267
runtime.goexit
        /usr/lib/go/src/runtime/asm_amd64.s:1650
        ```

### Expected behavior

stacker can operate on existing roots/layers even if they have very large files inside (>10G)

### Screenshots

_No response_

### Additional context

_No response_
@raharper raharper added the bug label May 8, 2024
@raharper
Copy link
Contributor Author

raharper commented May 8, 2024

Put this into a file, extract.sh

#!/bin/sh
cat <<EOF | base64 -d > test-case.tgz
H4sIAAAAAAAAA+1Ze1Mbtxbn7/0Up45bHqn2AX7cca7TIcFlmCaQMeS2cx8D8q7W3rK72q60gCH+
7j3SPrwGUtrgksmNzySAJR2do5/OU5ZMSBLRK5Iy6hERXDPLDRmNTTFZWxbZSN1uW/12uu3t+m9N
rU57zWl1nE532+nauM7p2DudNbCXpsEfUCYkTQHW0glNE5Z+dN1D818oPfvGGgWxNaJiAoRlV8bJ
0bvTvX5zA+0hTKicQPPdz3ubxqv3B2/21ISet0ZZEHrG0esDNXRTTM4s7gbG8Ojo5HhxOOVcCuP4
ZPf1T4Ph4hSi756ztJo8endy3G8QIiRP6ZgROU1Yn1+wNKRTIAQFEC9IcQcte4ZDevNisJCthouN
i4lK9qxRisJRfZa5DtUyxe+xUTaGOadSbAbaN4zPfWlLJHnX/8d8mc6/9qD/t1pOp/D/znZnp4X+
397pdFf+/xR0y/+NZyAmLAzdCXPPwQsEHYWsf/x62/5Hx8BJOQkE4D/2W0ZDPwjZugCP+TQLJaAV
gbIiU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kilkiYchCb77rigxiuEgxisMVSESc1J8QHNG0RGLPVHVey4lLlNFMWqGZl+Ni98yKia+IJLzcD58
dU0yGYTCMG5X8/fAopbI/DMd96BCFYeCSDmSyFcTUK8evQo4N+SZV8KWw6Ixi/koZBVe+hMRLMUG
l2iWIBoXoNFrrALNi4l3L3J3nnfV4GA4PBpWjzPNm5vy1WE2g+fgqHcazQtjhpeqIJ9zAF4BBSpA
NRsh0z2FXh2de0EKVh429MiPh7tvB33rTu+j5q7xCqCK/wVE1lZxBngJTc2d71Noiqvxvl34VhSz
lZ5oaW6m0pUO5HEWjTBfYLTXnHCZBuq6MaBrLvXHy37tSHqTQwXFRu2cVs69uYhIyHkC6sEIDmEj
CuJMAI+ZfvGCS7Z+wYCGKpJOtVTJYj1ditab+DyFjY2rvvMCrv55iD+eP9/cfAEeL+zuIWgWsPFw
e/3HHXAKhS9ZcWpMhbhC5VlZO/v3ys9j5Q8Q6JwnJ2pVEAWFNZezROeGfrOGUE0Oug2h4YJiGZYB
aHNkFHL3PGd2fnpVLvncYW9FBd2T/5eR8hfogfzvqDf/Iv+32i1Hff/Xba3y/5PQo/L/V5L+sTUh
+SPV41J/PQXWjneyO9wfnPQbllTzslFLpySBRjOfb5QpqDyv/j9/2I5Vw+KL2qvey3Jp/TVQzLUo
3ucTDN0X0LiTcebrKh1qY8ZHkv7gl3dHw5NTXN+v4WaWZlNqlnMoxfJDl4+AWFisN2/mm8zW598k
KD8lr+eAqBvPIpYGLsG2Me8QY6afm4iYCskiTIhJ/ZHax2MW5ciCkAaY9TRWnmdB45RF/EIpXGga
xKoXrZRLUVjq376tklmlaVQPLilmWVUAlE1t8R0Fn5da2ofyfT93bFjRila0ohX9/9Lvi1zn+QAo
AAA=
EOF
tar xzvf test-case.tgz

Then you can run it and expand the tarball with the test case

$ chmod +x expand.sh
$ ./expand.sh
 stacker  ./expand.sh
x test-max-read-size/clean.sh
x test-max-read-size/go.sh
x test-max-read-size/README.md
x test-max-read-size/build-export-stacker.yaml
x test-max-read-size/stacker.yaml
 stacker  ls -al test-max-read-size
total 40
drwxr-xr-x@  7 ryaharpe  staff   224 May  8 16:11 .
drwxr-xr-x@ 30 ryaharpe  staff   960 May  8 16:11 ..
-rw-r--r--@  1 ryaharpe  staff   343 May  8 11:56 README.md
-rw-r--r--@  1 ryaharpe  staff  1143 May  8 15:01 build-export-stacker.yaml
-rwxr-xr-x@  1 ryaharpe  staff   309 May  8 11:09 clean.sh
-rwxr-xr-x@  1 ryaharpe  staff  2318 May  8 15:50 go.sh
-rw-r--r--@  1 ryaharpe  staff   924 May  8 14:58 stacker.yaml

raharper added a commit to raharper/stacker that referenced this issue May 8, 2024
The equalfile golang package defaults to max read size of 10**10
bytes unless both files use io.LimitedReader to set an upper bound
on the read.  In stacker import we already stat the two files being
compared and know the actual file size.  This PR constructs two
io.LimitedReader's for each file being compared.

Fixes: project-stacker#617

Signed-off-by: Ryan Harper <[email protected]>
raharper added a commit to raharper/stacker that referenced this issue May 8, 2024
The equalfile golang package defaults to max read size of 10**10
bytes unless both files use io.LimitedReader to set an upper bound
on the read.  In stacker import we already stat the two files being
compared and know the actual file size.  This PR constructs two
io.LimitedReader's for each file being compared.

Fixes: project-stacker#617

Signed-off-by: Ryan Harper <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant