Skip to content

Add key to control if a container can get started by its pod #24437

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

Conversation

lambinoo
Copy link
Contributor

@lambinoo lambinoo commented Oct 31, 2024

By default today, the container is always started if its pod is also started. This prevents to create custom with systemd where containers in a pod could be started through their [Install] section.

We add a key StartWithPod=, enabled by default, that enables one to disable that behavior.

This prevents the pod service from changing the state of the container service.

Fixes #24401

Does this PR introduce a user-facing change?

Add key to control if a container can get started by its pod

@lambinoo
Copy link
Contributor Author

lambinoo commented Oct 31, 2024

Still need to add tests tomorrow (and fix typos in the docs..), but I wouldn't mind if someone can get a peek and check if that's the best solution or not.

I'm also a bit unsure if I've been clear enough in the man page.

I tested locally and removing the Wants=/Before= in the pod service is enough. Ordering is preserved by the container service already getting After= statements on top of its BindsTo=

Copy link
Contributor

@ygalblum ygalblum left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. The code looks like what I had in mind as well. Small typo

@@ -813,6 +814,16 @@ Size of /dev/shm.

This is equivalent to the Podman `--shm-size` option and generally has the form `number[unit]`

### `StartWithPod=`

Start the container aftert the associated pod is created. Default to **true**.
Copy link
Contributor

Choose a reason for hiding this comment

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

Type aftert -> after


If `true`, container will be started/stopped/restarted alongside the pod.

If `false`, the container will not be started when the pod starts. The container will be stopped when the pod. Restarting the pod will also restart the container.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If `false`, the container will not be started when the pod starts. The container will be stopped when the pod. Restarting the pod will also restart the container.
If `false`, the container will not be started when the pod starts. The container will be stopped with the pod. Restarting the pod will also restart the container as long as the container was also running before.

I think? Because if it was not active before the unit will not be started I would assume?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's what I meant. Better be explicit here

@TomSweeneyRedHat
Copy link
Member

Code LGTM, a test would be a wonderful addition.

@baude baude added the 5.3 label Nov 4, 2024
@baude
Copy link
Member

baude commented Nov 4, 2024

This PR has been marked for 5.3 inclusion but it must be merged prior to Nov 5 for inclusion in 5.3 RC3. PRs not merged by that date are considered on a case by case basis for backporting.

@lambinoo lambinoo force-pushed the feat-split-pod-container-start-24401 branch from 8254113 to 341bee2 Compare November 5, 2024 07:33
@lambinoo
Copy link
Contributor Author

lambinoo commented Nov 5, 2024

Ah, that's an unfortunate timing. I got sick a few days ago.
Pushed a test and the doc fixes

By default today, the container is always started if its pod is also
started. This prevents to create custom with systemd where containers in
a pod could be started through their `[Install]` section.

We add a key `StartWithPod=`, enabled by default, that enables one to
disable that behavior.

This prevents the pod service from changing the state of the container
service.

Fixes containers#24401

Signed-off-by: Farya L. Maerten <me@ltow.me>
@lambinoo lambinoo force-pushed the feat-split-pod-container-start-24401 branch from 341bee2 to 2597eea Compare November 5, 2024 07:39
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 5, 2024
Copy link
Contributor

@ygalblum ygalblum left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 5, 2024
Copy link
Contributor

openshift-ci bot commented Nov 5, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lambinoo, Luap99, ygalblum

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-merge-bot openshift-merge-bot bot merged commit a358d83 into containers:main Nov 5, 2024
77 checks passed
@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Feb 4, 2025
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Feb 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
5.3 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. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Quadlet] Pod units are always started regardless of the content of [Install]
5 participants