Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't rename pod if container has the same name #12726

Merged

Conversation

hikhvar
Copy link
Contributor

@hikhvar hikhvar commented Jan 1, 2022

We enforce the naming scheme "podname-containername" 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 [email protected]

@hikhvar hikhvar force-pushed the remove-superflous-pod-rename branch from 120e2f1 to 4dfe511 Compare January 1, 2022 20:05
@@ -15,6 +15,13 @@ import (
"github.com/containers/common/libimage"
"github.com/containers/common/pkg/config"
"github.com/containers/image/v5/types"
"github.com/ghodss/yaml"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is a left over of my IDE. It has auto sorting of imports enabled. The sorting is configured for our internal projects.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hikhvar Could you please amend and remove this.

@rhatdan
Copy link
Member

rhatdan commented Jan 2, 2022

@mheon PTAL

@flouthoc
Copy link
Collaborator

flouthoc commented Jan 3, 2022

@hikhvar Newly added tests are failing.

@hikhvar hikhvar force-pushed the remove-superflous-pod-rename branch from 4dfe511 to 31591af Compare January 3, 2022 22:33
@hikhvar
Copy link
Contributor Author

hikhvar commented Jan 4, 2022

Fixes the tests, reverted the import reordering. PTAL.

@mheon
Copy link
Member

mheon commented Jan 4, 2022

Hm. Still not sure why this changed originally to prefixing container names (you've identified the commit but it doesn't list logic), but since we are and have been for some time, no reason not to do this.

LGTM.

@umohnani8
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 4, 2022
@hikhvar hikhvar force-pushed the remove-superflous-pod-rename branch from 31591af to bd6bcf7 Compare January 4, 2022 16:27
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 4, 2022
@hikhvar
Copy link
Contributor Author

hikhvar commented Jan 4, 2022

Had a look over the code. Saw I removed a check too much. I added an integration test to prevent this error in the future.

Sorry for the inconvenience. PTAL.

@umohnani8
Copy link
Member

Updates LGTM
re-ran the failing tests

@rhatdan
Copy link
Member

rhatdan commented Jan 6, 2022

rebase and repush.

We enforce the naming scheme "<podname>-<containername>" 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 containers#12722

Signed-off-by: Christoph Petrausch <[email protected]>
@hikhvar hikhvar force-pushed the remove-superflous-pod-rename branch from bd6bcf7 to 4191616 Compare January 6, 2022 15:48
@hikhvar
Copy link
Contributor Author

hikhvar commented Jan 6, 2022

Rebased and pushed again.

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)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just wondering if it makes sense to keep this warning in play, although maybe changing the wording a bit, to let the user know of the collision so they could adjust afterwards if they wanted to. I agree with dropping the auto renam though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning is missleasing. There never will be a container with the same name as the pod, since all container names in the pod will be prefixed with the pod name.

@TomSweeneyRedHat
Copy link
Member

One last test to convince, one question, and I've restarted the unhappy test.

@rhatdan
Copy link
Member

rhatdan commented Jan 7, 2022

/approve
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 7, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 7, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hikhvar, rhatdan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 7, 2022
@openshift-merge-robot openshift-merge-robot merged commit 67dab9e into containers:main Jan 7, 2022
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Podman play kube adds _pod suffix if container is named like pod.
7 participants