-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
podman-generate-systemd --new for pods #6415
podman-generate-systemd --new for pods #6415
Conversation
quay.io is down...let's wait a bit |
1f07bb4
to
3bf4b51
Compare
Moving to WIP as I'll start working on the generator part now. |
... and more plumbing:
|
198af9f
to
76e39de
Compare
76e39de
to
83642cb
Compare
@baude FYI, the refactoring is done. Now I can merge the |
@vrothberg I am very much looking forward to this getting merged! Thanks for your hard work! Once things are ready and some RPMs are made, I would be glad to test and give it Bodhi karma. |
Thanks for the kind words, @jdoss, a really nice motivation! |
83642cb
to
98f160d
Compare
Here's the first working state for |
ba39780
to
91a74eb
Compare
@edsantiago @giuseppe @jwhonce @mheon @rhatdan @TomSweeneyRedHat PTAL It's big, so I suggest going through the commits one-by-one. |
Curious:
|
91a74eb
to
0862783
Compare
// Create a pod with --infra-conmon-pid. | ||
session := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--infra-conmon-pidfile", tmpFile}) | ||
session.WaitWithDefaultTimeout() | ||
Expect(session.ExitCode()).To(Equal(0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you test that tmpFile
gets created, read it, confirm that it's a number, and check /proc/RESULT/exe
or /proc/RESULT/cmdline
to confirm that it's conmon? Or perhaps just write this as a BATS test instead? I despair at the number of ginkgo tests that do this: merely check exit status without actually testing anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for catching that! I updated the e2e test as suggested 👍
Add a `CreateCommand` field to the pod config which includes the entire `os.Args` at pod-creation. Similar to the already existing field in a container config, we need this information to properly generate generic systemd unit files for pods. It's a prerequisite to support the `--new` flag for pods. Also add the `CreateCommand` to the pod-inspect data, which can come in handy for debugging, general inspection and certainly for the tests that are added along with the other changes. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Support the `--pod-id-file` flag in the rm, start and stop pod commands. This completes the already support flag in pod-create and is another prerequisite for generating generic systemd unit files for pods. Also add completions, docs and tests. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Allow containers to join an existing pod via the `--pod-id-file` which is already supported by a number of `podman-pod` subcommands. Also add tests to make sure it's working and to prevent future regressions. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Rename the container ID file from "cid" to "ctr-id" to make the generated unit files a) easier to read and to b) pro-actively avoid any confusion when pod ID files are being added in the future. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Add an `--infra-conmon-pidfile` flag to `podman-pod-create` to write the infra container's conmon process ID to a specified path. Several container sub-commands already support `--conmon-pidfile` which is especially helpful to allow for systemd to access and track the conmon processes. This allows for easily tracking the conmon process of a pod's infra container. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Rephrase the lookup error when the specified name or ID does not refer to a container or pod. Until, only the pod-lookup error has been returned which can be confusing when actually looking for a container; a user might have just mistyped the ID or name. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Rename to `containers{_test}.go` to make some place for the upcoming pod changes. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Add a method to Pod to easily access its .config.CreateCommand. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Refactor the systemd-unit generation code and move all the logic into `pkg/systemd/generate`. The code was already hard to maintain but I found it impossible to wire the `--new` logic for pods in all the chaos. The code refactoring in this commit will make maintaining the code easier and should make it easier to extend as well. Further changes and refactorings may still be needed but they will easier. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Create a new template for generating a pod unit file. Eventually, this allows for treating and extending pod and container generation seprately. The `--new` flag now also works on pods. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
33ddf8e
to
c7c81a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: giuseppe, rhatdan, vrothberg 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 |
/lgtm |
/hold cancel |
This PR turned out to be really big, sorry folks. Supporting the --new flag for pods required to first do the ground work in container and pod configs and to wire in flags to store and load pod ID in
podman pod
andpodman container
subcommands.After the ground work, I suffered from the sins of my past: the system-generation code was scattered across multiple packages and really complex. Both made it impossible for me to extend the code, so I started restructuring and refactoring the code into something usable and maintainable.
Finally, the --new flag is applied to pods.