Skip to content

Commit

Permalink
Add support for image_parallel_copies in containers.conf
Browse files Browse the repository at this point in the history
Adding this feature to allow people with little band with to adjust the
ammount of threads pulling an image.

I don't have an easy way to test this other then manually.

[NO TESTS NEEDED]

Helps Fix: containers#2224

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Apr 22, 2021
1 parent 009c8c7 commit b286b9d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/containers/buildah/define"
"github.com/containers/common/pkg/config"
"github.com/containers/common/pkg/retry"
cp "github.com/containers/image/v5/copy"
"github.com/containers/image/v5/docker"
Expand All @@ -16,6 +17,7 @@ import (
encconfig "github.com/containers/ocicrypt/config"
"github.com/containers/storage"
"github.com/containers/storage/pkg/unshare"
"github.com/sirupsen/logrus"
)

const (
Expand All @@ -35,7 +37,7 @@ func getCopyOptions(store storage.Store, reportWriter io.Writer, sourceSystemCon
if destinationSystemContext != nil {
*destinationCtx = *destinationSystemContext
}
return &cp.Options{
options := cp.Options{
ReportWriter: reportWriter,
SourceCtx: sourceCtx,
DestinationCtx: destinationCtx,
Expand All @@ -46,6 +48,13 @@ func getCopyOptions(store storage.Store, reportWriter io.Writer, sourceSystemCon
OciDecryptConfig: ociDecryptConfig,
OciEncryptLayers: ociEncryptLayers,
}
defaultContainerConfig, err := config.Default()
if err != nil {
logrus.Warnf("failed to get container config for copy options: %v", err)
} else {
options.MaxParallelDownloads = defaultContainerConfig.Engine.ImageParallelCopies
}
return &options
}

func getSystemContext(store storage.Store, defaults *types.SystemContext, signaturePolicyPath string) *types.SystemContext {
Expand Down

0 comments on commit b286b9d

Please sign in to comment.