netplan icon indicating copy to clipboard operation
netplan copied to clipboard

Extend KeepConfiguration= functionality

Open chr4 opened this issue 1 year ago • 3 comments

Description

With systemd-v243 (which is the default since focal), the "CriticalConnection" attribute was revamped into "KeepConfiguration" [1], addressing several issues, especially in high-availability environents [2][3].

The new "KeepConfiguration" setting can take multiple arguments, according to the documentation [4]:

Takes a boolean or one of "static", "dhcp-on-stop", "dhcp". When "static", systemd-networkd will not drop static addresses and routes on starting up process. When set to "dhcp-on-stop", systemd-networkd will not drop addresses and routes on stopping the daemon. When "dhcp", the addresses and routes provided by a DHCP server will never be dropped even if the DHCP lease expires. This is contrary to the DHCP specification, but may be the best choice if, e.g., the root filesystem relies on this connection. The setting "dhcp" implies "dhcp-on-stop", and "yes" implies "dhcp" and "static". Defaults to "no".

If I understand the code correctly, it still uses "CriticalConnection" when setting "critical: true" in the netplan configuration.

  • [1] https://github.com/systemd/systemd/pull/12511/files
  • [2] https://github.com/systemd/systemd/issues/12050
  • [3] https://chr4.org/blog/2019/01/21/make-keepalived-play-nicely-with-netplan-slash-systemd-network/
  • [4] https://systemd.network/systemd.network.html#KeepConfiguration=

Closes: https://bugs.launchpad.net/netplan/+bug/1896799

Checklist

  • [ ] Runs make check successfully.
  • [ ] Retains 100% code coverage (make check-coverage).
  • [x] New/changed keys in YAML format are documented.
  • [x] (Optional) Adds example YAML for new feature.
  • [x] (Optional) Closes an open bug in Launchpad.

chr4 avatar Sep 19 '23 11:09 chr4

This is a first draft - not tested yet. Feedback welcome!

chr4 avatar Sep 19 '23 11:09 chr4

Not sure how to fix the Python SIGSEGVs?

chr4 avatar Sep 19 '23 13:09 chr4

Hello @chr4,

Thank you for bringing this to our attention and also for your PR, it's much appreciated.

Yes, we are still emitting the following configuration when critical: true is used in Netplan:

[DHCP]
CriticalConnection=true

As you already said, According to systemd's NEWS file this option was deprecated some time ago:

The CriticalConnection= setting in .network files is now deprecated,
and replaced by a new KeepConfiguration= setting which allows more
detailed configuration of the IP configuration to keep in place.

So yes, we need to get rid of CriticalConnection in favor of KeepConfiguration.

The problem is that we can't get rid of the critical key in Netplan, because it would break Netplan for everybody using this option.

Instead of replacing it with keep-configuration, I'd suggest a much simpler approach: adapt critical to accept all the new values supported by KeepConfiguration, including true and false.

This would make the patch simpler and wouldn't break Netplan. Also, all those functions and variables renaming wouldn't be necessary.

The second approach would be to keep critical as it is, deprecate it and introduce a new key, such as keep-configuration.

Keeping critical untouched would still work because systemd still accepts CriticalConnection, even though it's not even documented anymore. See https://github.com/systemd/systemd/blob/main/src/network/networkd-network.c#L245

In my opinion we could reuse critical and just change it to accept all the new values accepted by KeepConfiguration.

@slyon @vorlonofportland any thoughts on this?

daniloegea avatar Sep 21 '23 11:09 daniloegea