From 4191616cc567d553776001d640e7f2d945a4fae7 Mon Sep 17 00:00:00 2001 From: Christoph Petrausch Date: Sat, 1 Jan 2022 14:03:34 +0100 Subject: Don't rename pod if container has the same name We enforce the naming scheme "-" here [1]. Therefore we must not rename the pod in case of a naming conflict between pod name and container name. Not renaming the pod increases the usability for the user and easies scripting based on the name. Otherwise a user must set some label to reliable find a pod after creation. Or have to implement the renaming logic in the script. [1] https://github.com/containers/podman/blob/main/pkg/specgen/generate/kube/kube.go#L140 Fixes #12722 Signed-off-by: Christoph Petrausch --- pkg/domain/infra/abi/play.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'pkg') diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go index 6b3b04a0b..40c31b163 100644 --- a/pkg/domain/infra/abi/play.go +++ b/pkg/domain/infra/abi/play.go @@ -178,17 +178,10 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY return nil, err } - // check for name collision between pod and container + // Assert the pod has a name if podName == "" { return nil, errors.Errorf("pod does not have a name") } - for _, n := range podYAML.Spec.Containers { - if n.Name == podName { - playKubePod.Logs = append(playKubePod.Logs, - fmt.Sprintf("a container exists with the same name (%q) as the pod in your YAML file; changing pod name to %s_pod\n", podName, podName)) - podName = fmt.Sprintf("%s_pod", podName) - } - } podOpt := entities.PodCreateOptions{Infra: true, Net: &entities.NetOptions{NoHosts: options.NoHosts}} podOpt, err = kube.ToPodOpt(ctx, podName, podOpt, podYAML) -- cgit v1.2.3-54-g00ecf