Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions pkg/crt/docker/dockerutil/dockerutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"path/filepath"
"strings"
"time"
"strconv"

"github.com/docker/docker/pkg/archive"
dockerapi "github.com/fsouza/go-dockerclient"
Expand All @@ -32,6 +33,11 @@ const (
emptyImageDockerfile = "FROM scratch\nCMD\n"
)

const (
EnvExportImageInactivityTimeout = "SLIM_EXPORT_IMAGE_INACTIVITY_TIMEOUT"
EnvExportDownloadInactivityTimeout = "SLIM_DOWNLOAD_INACTIVITY_TIMEOUT"
)

type BasicImageProps struct {
ID string
Size int64
Expand Down Expand Up @@ -360,10 +366,19 @@ func SaveImage(dclient *dockerapi.Client, imageRef, local string, extract, remov
return err
}


// Default export image inactivity timeout value in seconds
var exportTimeoutValue time.Duration = time.Duration(20)
if value, exists := os.LookupEnv(EnvExportImageInactivityTimeout); exists {
if timeout, err := strconv.Atoi(value); err == nil && timeout > 0 {
exportTimeoutValue = time.Duration(timeout)
}
}

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

err = dclient.ExportImage(options)
Expand Down Expand Up @@ -800,10 +815,18 @@ func CopyFromContainer(dclient *dockerapi.Client, containerID, remote, local str
return err
}

// Default download from container inactivity timeout value in seconds
var downloadTimeoutValue time.Duration = time.Duration(20)
if value, exists := os.LookupEnv(EnvExportDownloadInactivityTimeout); exists {
if timeout, err := strconv.Atoi(value); err == nil && timeout > 0 {
downloadTimeoutValue = time.Duration(timeout)
}
}

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

err = dclient.DownloadFromContainer(containerID, downloadOptions)
Expand Down
Loading