From 0f802d00655f22b71b29ad57482174b4588a79e1 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Thu, 28 Jan 2021 13:05:40 -0500 Subject: [PATCH] Add image_default_format Currently when pulling/pushing images we default to the format of the source image. When Building images we default to OCI. Customers have asked us to allow them to force a specific image type when pushing to a registry. We already have a flag to building images. This PR adds image_default_format to define the format to be used by all tools create/building/pulling and pusing images. Signed-off-by: Daniel J Walsh --- common/docs/containers.conf.5.md | 8 +++++-- common/pkg/config/config.go | 24 ++++++++++++------- common/pkg/config/config_test.go | 1 + common/pkg/config/containers.conf | 15 ++++++------ .../config/testdata/containers_override.conf | 1 + 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/common/docs/containers.conf.5.md b/common/docs/containers.conf.5.md index 027f60c806..ceeb3299e9 100644 --- a/common/docs/containers.conf.5.md +++ b/common/docs/containers.conf.5.md @@ -278,8 +278,12 @@ Path to the directory where CNI configuration files are located. ## ENGINE TABLE The `engine` table contains configuration options used to set up container engines such as Podman and Buildah. -**image_build_format**="oci" -The default image format to building container images. Valid values are "oci" (default) or "docker". +**image_default_format**="oci"|"v2s2"|"v2s1" + +Manifest Type (oci, v2s2, or v2s1) to use when pulling, pushing, building +container images. By default images pulled and pushed match the format of the +source image. Building/committing defaults to OCI. +Note: **image_build_format** is deprecated. **cgroup_check**=false diff --git a/common/pkg/config/config.go b/common/pkg/config/config.go index eb05e43b4c..4a98c7e926 100644 --- a/common/pkg/config/config.go +++ b/common/pkg/config/config.go @@ -187,15 +187,6 @@ type ContainersConfig struct { // EngineConfig contains configuration options used to set up a engine runtime type EngineConfig struct { - // ImageBuildFormat indicates the default image format to building - // container images. Valid values are "oci" (default) or "docker". - ImageBuildFormat string `toml:"image_build_format,omitempty"` - - // ImageParallelCopies indicates the maximum number of image layers - // to be copied simultaneously. If this is zero, container engines - // will fall back to containers/image defaults. - ImageParallelCopies uint `toml:"image_parallel_copies,omitempty"` - // CgroupCheck indicates the configuration has been rewritten after an // upgrade to Fedora 31 to change the default OCI runtime for cgroupv2v2. CgroupCheck bool `toml:"cgroup_check,omitempty"` @@ -240,10 +231,25 @@ type EngineConfig struct { // this slice takes precedence. HooksDir []string `toml:"hooks_dir,omitempty"` + // ImageBuildFormat (DEPRECATED) indicates the default image format to + // building container images. Should use ImageDefaultFormat + ImageBuildFormat string `toml:"image_build_format,omitempty"` + // ImageDefaultTransport is the default transport method used to fetch // images. ImageDefaultTransport string `toml:"image_default_transport,omitempty"` + // ImageParallelCopies indicates the maximum number of image layers + // to be copied simultaneously. If this is zero, container engines + // will fall back to containers/image defaults. + ImageParallelCopies uint `toml:"image_parallel_copies,omitempty"` + + // ImageDefaultFormat sepecified the manifest Type (oci, v2s2, or v2s1) + // to use when pulling, pushing, building container images. By default + // image pulled and pushed match the format of the source image. + // Building/committing defaults to OCI. + ImageDefaultFormat string `toml:"image_default_format,omitempty"` + // InfraCommand is the command run to start up a pod infra container. InfraCommand string `toml:"infra_command,omitempty"` diff --git a/common/pkg/config/config_test.go b/common/pkg/config/config_test.go index 37c03e71a9..39840edb17 100644 --- a/common/pkg/config/config_test.go +++ b/common/pkg/config/config_test.go @@ -306,6 +306,7 @@ var _ = Describe("Config", func() { gomega.Expect(config.Containers.ApparmorProfile).To(gomega.Equal("overridden-default")) gomega.Expect(config.Containers.LogDriver).To(gomega.BeEquivalentTo("k8s-file")) gomega.Expect(config.Engine.ImageParallelCopies).To(gomega.Equal(uint(10))) + gomega.Expect(config.Engine.ImageDefaultFormat).To(gomega.Equal("v2s2")) }) It("should fail with invalid value", func() { diff --git a/common/pkg/config/containers.conf b/common/pkg/config/containers.conf index cbbed01377..14d043da51 100644 --- a/common/pkg/config/containers.conf +++ b/common/pkg/config/containers.conf @@ -246,9 +246,14 @@ default_sysctls = [ # network_config_dir = "/etc/cni/net.d/" [engine] -# ImageBuildFormat indicates the default image format to building -# container images. Valid values are "oci" (default) or "docker". -# image_build_format = "oci" +# Maximum number of image layers to be copied (pulled/pushed) simultaneously. +# Not setting this field, or setting it to zero, will fall back to containers/image defaults. +# image_parallel_copies=0 + +# Manifest Type (oci, v2s2, or v2s1) to use when pulling, pushing, building +# container images. By default image pulled and pushed match the format of the +# source image. Building/commiting defaults to OCI. +# image_default_format = "" # Cgroup management implementation used for the runtime. # Valid options "systemd" or "cgroupfs" @@ -321,10 +326,6 @@ default_sysctls = [ # # infra_image = "k8s.gcr.io/pause:3.2" -# Maximum number of image layers to be copied (pulled/pushed) simultaneously. -# Not setting this field, or setting it to zero, will fall back to containers/image defaults. -# image_parallel_copies=0 - # Specify the locking mechanism to use; valid values are "shm" and "file". # Change the default only if you are sure of what you are doing, in general # "file" is useful only on platforms where cgo is not available for using the diff --git a/common/pkg/config/testdata/containers_override.conf b/common/pkg/config/testdata/containers_override.conf index 70c28893f2..2dee5184c1 100644 --- a/common/pkg/config/testdata/containers_override.conf +++ b/common/pkg/config/testdata/containers_override.conf @@ -5,3 +5,4 @@ log_driver = "k8s-file" [engine] image_parallel_copies=10 +image_default_format="v2s2"