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

Allow removing implicit quadlet systemd dependencies #24194

Conversation

lambinoo
Copy link
Contributor

@lambinoo lambinoo commented Oct 7, 2024

Allow removing implicit quadlet systemd dependencies

Quadlet inserts network-online.target Wants/After dependencies to ensure pulling works.
Those systemd statements cannot be subsequently reset.

In the cases where those dependencies are not wanted, we add a new
configuration item called DefaultDependencies= in a new section called
[Quadlet]. This section is shared between different unit types.

fixes #24193

Adds a directive in a new [Quadlet] section to prevent quadlet from adding implicit dependencies on the network-online target.

Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@lambinoo lambinoo force-pushed the quadlet-disable-default-dependencies branch 3 times, most recently from 8182de7 to 8b4d085 Compare October 7, 2024 19:26
@ygalblum
Copy link
Contributor

ygalblum commented Oct 7, 2024

The code looks good. But, you will need to add some tests

@lambinoo
Copy link
Contributor Author

lambinoo commented Oct 7, 2024

The code looks good. But, you will need to add some tests

Would an e2e test be enough for this?

@mheon
Copy link
Member

mheon commented Oct 7, 2024

Sure. We generally want an E2E or system test, adding both is usually unnecessary.

@lambinoo lambinoo force-pushed the quadlet-disable-default-dependencies branch from 8b4d085 to 4d71241 Compare October 7, 2024 20:27
@lambinoo
Copy link
Contributor Author

lambinoo commented Oct 7, 2024

Should be good now I think

@lambinoo lambinoo force-pushed the quadlet-disable-default-dependencies branch 4 times, most recently from ccde48a to 29463da Compare October 7, 2024 21:23
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM, nice work.

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 8, 2024
// override the default ones.
service.PrependUnitLine(UnitGroup, "After", "network-online.target")
service.PrependUnitLine(UnitGroup, "Wants", "network-online.target")
if service.LookupBooleanWithDefault(ContainerGroup, KeyQuadletDefaultDependencies, true) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we really want to add these generic keys to each group? Overall this just adds a ton of duplication in the docs.
And every time we add such a generic option we have to do that over and over again which does not look sane to me.

So maybe is it time to define a [Quadlet] section and then just name the key DefaultDependencies under there? This would only need to be documented once and then should work for all units. @ygalblum WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

I had a similar thought but didn't consider the long-term impact on new features. +1 from my side.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree and I was actually thinking about it for a while now. For example, I would move ContainersConfModule to there as well (I know, for backward compatibility we'll need to support both)
I'm just not sure we want to force @lambinoo to make this change.
Let's hold this PR for a sec and I'll try to find some time to add this section

Copy link
Contributor Author

@lambinoo lambinoo Oct 8, 2024

Choose a reason for hiding this comment

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

I don't mind. Just pushed (what I think are) the required changes for this!
Left the ContainersConfModule bit out of this

@lambinoo lambinoo force-pushed the quadlet-disable-default-dependencies branch 7 times, most recently from 0da746b to 90fd1dc Compare October 8, 2024 15:16
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.

Additional question:
The new Quadlet section is currently only relevant for .container, .build and .image files. What should be the behaviour if it appears on a different types? I see three options:

  1. Rename the group to X-Quadlet and noop
  2. Error at the Quadlet level
  3. Noop which will result in a systemd error because of an unrecognized section

I think option 1 is preferable as it will also be future proof.


| **[Quadlet] options** | **Description** |
|----------------------------|---------------------------------------------------|
| DefaultDependencies=false | Include implicit network dependencies to the unit |
Copy link
Contributor

Choose a reason for hiding this comment

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

The example sets the value to false but the description refers to the case of true. This might be a bit confusing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooops, updated!

Copy link
Contributor

Choose a reason for hiding this comment

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

Something got reverted here and the original issue is back. I'll take advantage and say that since setting it to true is redundant, it might be better to leave the false value and change the description to something like "Disable implicit network..."

pkg/systemd/quadlet/quadlet.go Show resolved Hide resolved
@lambinoo lambinoo force-pushed the quadlet-disable-default-dependencies branch from 90fd1dc to 6ba0e79 Compare October 8, 2024 15:47
@lambinoo
Copy link
Contributor Author

lambinoo commented Oct 8, 2024

Additional question: The new Quadlet section is currently only relevant for .container, .build and .image files. What should be the behaviour if it appears on a different types? I see three options:

1. Rename the group to `X-Quadlet` and noop

2. Error at the Quadlet level

3. Noop which will result in a systemd error because of an unrecognized section

I think option 1 is preferable as it will also be future proof.

+1 on renaming. The quadlet section will be used by .pod too for example when ContainersConfModule= is added to it, as you mentioned before.

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, Thanks!

@lambinoo
Copy link
Contributor Author

lambinoo commented Oct 8, 2024

Is there a way to retry those podman db test failures? They seem pretty unrelated to quadlet. And I'm not too familiar with Github actions

@Luap99
Copy link
Member

Luap99 commented Oct 8, 2024

Is there a way to retry those podman db test failures? They seem pretty unrelated to quadlet. And I'm not too familiar with Github actions

We can restart individual ones yes, but if basically all of them are red the problem is in the new changes (expect in very rare cases where some external factor is breaking things)
You can click on details and then open the link at the bottom which should show you the error
https://api.cirrus-ci.com/v1/artifact/task/4942923031117824/html/int-podman-debian-13-root-host-sqlite.log.html#t--quadlet-system-generator-Running-quadlet-dryrun-tests-Should-fail-on-bad-quadlet--1

So there is definitely something broken in quadlet that makes this this fail

@lambinoo
Copy link
Contributor Author

lambinoo commented Oct 8, 2024

Is there a way to retry those podman db test failures? They seem pretty unrelated to quadlet. And I'm not too familiar with Github actions

We can restart individual ones yes, but if basically all of them are red the problem is in the new changes (expect in very rare cases where some external factor is breaking things) You can click on details and then open the link at the bottom which should show you the error https://api.cirrus-ci.com/v1/artifact/task/4942923031117824/html/int-podman-debian-13-root-host-sqlite.log.html#t--quadlet-system-generator-Running-quadlet-dryrun-tests-Should-fail-on-bad-quadlet--1

So there is definitely something broken in quadlet that makes this this fail

Oh, good catch yeah. I did see a lot of those weird "unlikeat" errors before and stopped looking after seeing one. Seems like I forgot a return err! Hopefully it goes through this time.

@lambinoo lambinoo force-pushed the quadlet-disable-default-dependencies branch 2 times, most recently from 2994057 to 426e730 Compare October 8, 2024 17:46
@lambinoo
Copy link
Contributor Author

lambinoo commented Oct 8, 2024

Looks a bit better, but I can see a pasta related error and a WSL one.

@lambinoo lambinoo force-pushed the quadlet-disable-default-dependencies branch from 426e730 to d01c484 Compare October 9, 2024 07:16
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.

Your latest forced push reverted all the changes made following the comments. I added a comment about the doc


| **[Quadlet] options** | **Description** |
|----------------------------|---------------------------------------------------|
| DefaultDependencies=false | Include implicit network dependencies to the unit |
Copy link
Contributor

Choose a reason for hiding this comment

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

Something got reverted here and the original issue is back. I'll take advantage and say that since setting it to true is redundant, it might be better to leave the false value and change the description to something like "Disable implicit network..."


Add Quadlet's default dependencies to the unit.

If set to true (the default), Quadlet will add a dependency (After=, Wants=) to `network-online.target` to the generated unit.
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here. Since true is the default, I think it's better to describe the outcome of setting it to false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated for both!

@lambinoo lambinoo force-pushed the quadlet-disable-default-dependencies branch from d01c484 to 426e730 Compare October 9, 2024 12:44
@lambinoo
Copy link
Contributor Author

lambinoo commented Oct 9, 2024

Your latest forced push reverted all the changes made following the comments. I added a comment about the doc

Added back everything. The cons oF working on two different workstations and badly keeping track..

Quadlet inserts network-online.target Wants/After dependencies to ensure pulling works.
Those systemd statements cannot be subsequently reset.

In the cases where those dependencies are not wanted, we add a new
configuration item called `DefaultDependencies=` in a new section called
[Quadlet]. This section is shared between different unit types.

fixes containers#24193

Signed-off-by: Farya L. Maerten <me@ltow.me>
@lambinoo lambinoo force-pushed the quadlet-disable-default-dependencies branch from 426e730 to bac655a Compare October 9, 2024 12:48
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

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
thanks

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

openshift-ci bot commented Oct 9, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lambinoo, Luap99, vrothberg, 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:
  • OWNERS [Luap99,vrothberg,ygalblum]

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 5890190 into containers:main Oct 9, 2024
81 of 82 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 Jan 8, 2025
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Jan 8, 2025
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. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Quadlet] Implicit network online dependencies cannot be removed
5 participants