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

Add environment variables to set inactivity timeout values #65

Merged
merged 1 commit into from
Oct 13, 2024

Conversation

tsujie
Copy link
Contributor

@tsujie tsujie commented Oct 11, 2024

Fixes-###

What

When I use mint (slim) to optimize my docker image (original size is 13 GB), I always get this error

level=error msg="dockerutil.CopyFromContainer: dclient.DownloadFromContainer() error = inactivity time exceeded timeout"

And slim optimization failed finally with error

 cmd=slim info=build.error status='optimized.image.build.error' error='no layers'

Why

The reason is the inactivity timeout is hardcoded to 20secs for export image and download from container

 	options := dockerapi.ExportImageOptions{
 		Name:              imageRef,
 		OutputStream:      dfile,
		InactivityTimeout: 20 * time.Second,
 	}

 	downloadOptions := dockerapi.DownloadFromContainerOptions{
 		Path:              remote,
 		OutputStream:      dfile,
		InactivityTimeout: 20 * time.Second,
		InactivityTimeout: downloadTimeoutValue * time.Second,
 	}

For large docker image, we might need longer time to finish these operation.
In order to fix that, we add two environment variables SLIM_EXPORT_IMAGE_INACTIVITY_TIMEOUT and SLIM_DOWNLOAD_INACTIVITY_TIMEOUT to set the inactivity timeout values respectively.

How Tested

Now we can run mint slim with the customized timeout value like

SLIM_DOWNLOAD_INACTIVITY_TIMEOUT=180 mint slim ...

…and `SLIM_DOWNLOAD_INACTIVITY_TIMEOUT` to set the inactivity timeout values

Signed-off-by: Jie Xu <jie.xu@image-metrics.com>
@kcq
Copy link
Contributor

kcq commented Oct 12, 2024

Thanks for the enhancement @tsujie ! Definitely makes sense to have an option like that. Normally it's done in a slightly different way using flags, which also have environment variables, so there's no need to manually extract environment variables. I can accept this PR as-is though I'll need to refactor it to use flags.

@tsujie
Copy link
Contributor Author

tsujie commented Oct 13, 2024

@kcq , yes, using flags is a better way. But I'm not quite familiar with the flags implementation and passing mechanism in slim. Maybe need your refactoring.

@kcq kcq merged commit 90f6024 into mintoolkit:master Oct 13, 2024
3 of 18 checks passed
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.

3 participants