diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-07-16 07:53:43 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-16 07:53:43 -0400 |
commit | ce28dc3c4c3dba468ddb6f2a249c0c4bfc058805 (patch) | |
tree | 0f16371ff56a8323db480d010b0315e600c2a50b /libpod | |
parent | 3ba9f2a205787135b4e34e4d217df3ab9d0071b8 (diff) | |
parent | af40dfc2bf614aeb4191916cc2420068696eb776 (diff) | |
download | podman-ce28dc3c4c3dba468ddb6f2a249c0c4bfc058805.tar.gz podman-ce28dc3c4c3dba468ddb6f2a249c0c4bfc058805.tar.bz2 podman-ce28dc3c4c3dba468ddb6f2a249c0c4bfc058805.zip |
Merge pull request #10820 from jvanz/indfra-container-name-issue-10794
--infra-name command line argument
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/options.go | 26 | ||||
-rw-r--r-- | libpod/pod.go | 1 | ||||
-rw-r--r-- | libpod/runtime_pod_infra_linux.go | 6 |
3 files changed, 32 insertions, 1 deletions
diff --git a/libpod/options.go b/libpod/options.go index bc563d60c..17a36008d 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -459,6 +459,19 @@ func WithDefaultInfraCommand(cmd string) RuntimeOption { } } +// WithDefaultInfraName sets the infra container name for a single pod. +func WithDefaultInfraName(name string) RuntimeOption { + return func(rt *Runtime) error { + if rt.valid { + return define.ErrRuntimeFinalized + } + + rt.config.Engine.InfraImage = name + + return nil + } +} + // WithRenumber instructs libpod to perform a lock renumbering while // initializing. This will handle migrations from early versions of libpod with // file locks to newer versions with SHM locking, as well as changes in the @@ -1787,6 +1800,19 @@ func WithInfraCommand(cmd []string) PodCreateOption { } } +// WithInfraName sets the infra container name for a single pod. +func WithInfraName(name string) PodCreateOption { + return func(pod *Pod) error { + if pod.valid { + return define.ErrPodFinalized + } + + pod.config.InfraContainer.InfraName = name + + return nil + } +} + // WithPodName sets the name of the pod. func WithPodName(name string) PodCreateOption { return func(pod *Pod) error { diff --git a/libpod/pod.go b/libpod/pod.go index c03059c82..62f5c9e5b 100644 --- a/libpod/pod.go +++ b/libpod/pod.go @@ -112,6 +112,7 @@ type InfraContainerConfig struct { ExitCommand []string `json:"exitCommand,omitempty"` InfraImage string `json:"infraImage,omitempty"` InfraCommand []string `json:"infraCommand,omitempty"` + InfraName string `json:"infraName,omitempty"` Slirp4netns bool `json:"slirp4netns,omitempty"` NetworkOptions map[string][]string `json:"network_options,omitempty"` ResourceLimits *specs.LinuxResources `json:"resource_limits,omitempty"` diff --git a/libpod/runtime_pod_infra_linux.go b/libpod/runtime_pod_infra_linux.go index 8342352ec..d4f861118 100644 --- a/libpod/runtime_pod_infra_linux.go +++ b/libpod/runtime_pod_infra_linux.go @@ -201,7 +201,11 @@ func (r *Runtime) makeInfraContainer(ctx context.Context, p *Pod, imgName, rawIm g.AddLinuxSysctl(sysctlKey, sysctlVal) } - containerName := p.ID()[:IDTruncLength] + "-infra" + containerName := p.config.InfraContainer.InfraName + if containerName == "" { + containerName = p.ID()[:IDTruncLength] + "-infra" + } + logrus.Infof("Infra container name %s", containerName) options = append(options, r.WithPod(p)) options = append(options, WithRootFSFromImage(imgID, imgName, rawImageName)) options = append(options, WithName(containerName)) |