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

Introduce artifact max size limit of 50MiB #929

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stefanprodan
Copy link
Member

@stefanprodan stefanprodan commented Oct 10, 2022

Add a controller flag named --artifact-max-size=<bytes> with the default value of 50MiB. To disable the limit, the value can be set to --artifact-max-size=-1.

⚠️ Breaking change

The flag enforces a max size limit for the artifact contents produced by source-controller, to avoid out-of-memory crashes of consumers such as kustomize-controller.

Closes: #901

@stefanprodan stefanprodan added the area/storage Storage related issues and pull requests label Oct 10, 2022
@stefanprodan stefanprodan requested a review from a team October 10, 2022 14:03
@stefanprodan stefanprodan added the area/security Security related issues and pull requests label Oct 10, 2022
Comment on lines 439 to 444
if s.ArtifactMaxSize > 0 && sz.written > s.ArtifactMaxSize {
return fmt.Errorf("artifact size %d exceeds the max limit of %d bytes", sz.written, s.ArtifactMaxSize)
}

Copy link
Member

@pjbgf pjbgf Oct 10, 2022

Choose a reason for hiding this comment

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

Is the writerCounter incremented mid-flight as a stream? If so, within Walk we could short-circuit this process and stop other operations once the pre-set limit is reached.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes but my intention here was to tell users which is the final size of the artifact.

Copy link
Member

Choose a reason for hiding this comment

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

I would short circuit the process instead, as otherwise half of the usefulness of the bound is lost.

Copy link
Member Author

Choose a reason for hiding this comment

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

If I move the check inside Walk then sz.written is always zero.

main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@stefanprodan stefanprodan force-pushed the artifact-max-size branch 2 times, most recently from dd1e55b to af969cf Compare October 11, 2022 14:53
Add a controller flag named "--artifact-max-size=<bytes>" with the default value of 50MiB.
To disable the limit, the value can be set to "--artifact-max-size=-1".
The flag enforces a max size limit for the artifact contents produced by source-controller,
to avoid out-of-memory crashes of consumers such as kustomize-controller.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/security Security related issues and pull requests area/storage Storage related issues and pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce a flag to limit the max size of Flux artifacts
4 participants