-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Quadlet - allow deleting the network when stopping the service #25844
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
Quadlet - allow deleting the network when stopping the service #25844
Conversation
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
bf391d8
to
a343554
Compare
pkg/systemd/quadlet/quadlet.go
Outdated
KeyIPv6: true, | ||
KeyInternal: true, | ||
KeyNetworkName: true, | ||
KeyNetworkDeleteWhenStop: true, |
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.
Would NetworkDeleteOnStop
sound better?
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.
Also I suppose since this is already part of the network section we might also be able to get rid of the Network
prefix?
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.
Sure, done
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.
Sorry, I missed the second comment. The reason I kept Network
is so that it won't be used in other unit types
a343554
to
b16d5a9
Compare
pkg/systemd/quadlet/quadlet.go
Outdated
@@ -940,6 +942,12 @@ func ConvertNetwork(network *parser.UnitFile, name string, unitsInfoMap map[stri | |||
// Need the containers filesystem mounted to start podman | |||
service.Add(UnitGroup, "RequiresMountsFor", "%t/containers") | |||
|
|||
if network.LookupBooleanWithDefault(NetworkGroup, KeyNetworkDeleteOnStop, false) { | |||
serviceStopPostCmd := createBasePodmanCommand(network, NetworkGroup) | |||
serviceStopPostCmd.add("network", "rm", "--force", networkName) |
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.
Sorry should have checked this earlier, do we really want force in this case? Per systemd ordering it will stopped after container are stopped but not when one runs systemctl stop
manually on the network right?
It could be very unexpected if the removing the unit causes podman to force remove all container that are on the network.
Having the command error in case there still are other containers running might be a good thing.
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.
I tested this scenario: #23678 (comment)
From what I could tell, stopping the network unit will first stop the dependent container units and only then stop the network. So, the force
flag is expected to be a noop as all containers are supposed to stop before the network is deleted.
Having said that, it will remove containers that were added to this network without a proper connection in a Quadlet unit.
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.
Ack, thanks. So then I think it is even better to not add --force, anything else would mean we have a outside container on this network which is not managed by quadlet so I would prefer to not force remove that.
Returning an error in this case seems like the best option.
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.
Concur, force-removal seems too aggressive - likely to cause some collateral damage.
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.
OK, I removed the --force
flag and also enhanced the test to make sure dependency works
LGTM after all comments addressed |
Signed-off-by: Ygal Blum <[email protected]>
b16d5a9
to
0d4a148
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: 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 |
@baude I made some small changes since your review |
/lgtm |
Does this PR introduce a user-facing change?
Yes
Resolves: #23678