YAML consolidation: netplan set (FR-702)#254
Conversation
|
This builds up on #252 hence the draft status. |
787d0bb to
2093f00
Compare
Codecov Report
@@ Coverage Diff @@
## main #254 +/- ##
=======================================
Coverage 99.07% 99.07%
=======================================
Files 61 61
Lines 10862 10862
=======================================
Hits 10762 10762
Misses 100 100 Continue to review full report at Codecov.
|
99d5d60 to
9592983
Compare
9592983 to
d6c72b7
Compare
|
Ran the autopkgtests manually: |
slyon
left a comment
There was a problem hiding this comment.
This is another big PR, but the change makes the implementation so much cleaner and more explicit. I really like your overall approach!
I left several comments inline about some details that we should address in a 2nd version of PR.
d6c72b7 to
643d714
Compare
|
For the sake of being able to test stuff, I included the commit of #257 since without it the null-handling breaks stuff. |
c181a6f to
5ee4321
Compare
5ee4321 to
9c45c8d
Compare
9c45c8d to
b3775b3
Compare
slyon
left a comment
There was a problem hiding this comment.
Thank you very much, we're making good progress with this big PR and are getting much closer to a unified YAML parser. kudos!
I've left some smaller inline comments, nothing critical.
Another thing to mention is that make check-coverage currently fails, due to netplan/cli/sriov.py:363, which can probably just be marked as "nocover", as it's just about (non-existing) hardware specific quirks.
ed51f04 to
eaa64fd
Compare
There was a problem hiding this comment.
Thank you! All my remarks have been addressed. This is ready to be merged IMO.
Abigail is detecting some ABI changes, but they are all compatible (added functions & appended sources to NetplanState). Feel free to update the ABI XML to something like this (after a rebase, to have abi-compat/focal_0.104.xml available): https://paste.ubuntu.com/p/BK8HGnzPrG/ and merge this PR afterwards.
abidiff abi-compat/focal_0.104.xml libnetplan.so.0.0 --headers-dir2 include/ --header-file2 src/abi.h
Functions changes summary: 0 Removed, 0 Changed (26 filtered out), 5 Added functions
Variables changes summary: 0 Removed, 1 Changed, 0 Added variable
5 Added functions:
[A] 'function gboolean netplan_parser_load_nullable_fields(NetplanParser*, int, GError**)' {netplan_parser_load_nullable_fields}
[A] 'function gboolean netplan_parser_load_yaml_from_fd(NetplanParser*, int, GError**)' {netplan_parser_load_yaml_from_fd}
[A] 'function gboolean netplan_state_update_yaml_hierarchy(const NetplanState*, const char*, const char*, GError**)' {netplan_state_update_yaml_hierarchy}
[A] 'function gboolean netplan_state_write_yaml_file(const NetplanState*, const char*, const char*, GError**)' {netplan_state_write_yaml_file}
[A] 'function gboolean netplan_util_create_yaml_patch(const char*, const char*, int, GError**)' {netplan_util_create_yaml_patch}
1 Changed variable:
[C] 'NetplanState global_state' was changed at abi_compat.c:64:1:
size of symbol changed from 168 to 176
|
IMHO we should completely exclude `global_state` from the ABI check, as it's
something that's never been part of the API and is just an
intermediate label to construct the `netdefs` and `ordered` public
objects.
|
ACK. Should be resolved by a4a8ac8 |
This hidden option makes things much easier to debug. Inserting unconditional breakpoint() statements in the code is somewhat error-prone as shelling out to new `netplan` process is fairly common throughout the code base, and there are also some systemd services that spawn netplan instances.
This will be useful for `netplan set` to remove emptied-out config files. V2: Fix white space
Any data that is parsed from such a file is considered as having no source file. Existing netdefs retain their original filename, and new ones have a NULL one, which will be exploited later on. V2: Remove erroneous copy-pasted comment
This support is done by pre-processing the input files to identify the null fields, and when we find a key that matches a null field we simply skip to the next key. This necessitates to keep track of the complete key throughout the parser, hence the relatively big size of the patch. V2: * Rename prefix arguments to key_prefix * Use \t rather than . as prefix segment separator
This new function does a targetted update of a given config file, exporting all relevant netdefs (including those without defined config file, e.g. those that have been created via a patch) V2: * Use the tempfile+rename trick to avoid data loss on error * Style fixes V3: * Add a test for removal of unremovable files
eaa64fd to
7f0fb1c
Compare
This new function basically refreshes all the configuration files that have been used to create the current state. This is where the global source file tracking comes into play, as it allows us to delete config files that didn't result in any actual settings in the final state, i.e. because their defs were removed in a subsequent patch. This function will be used in the netplan set rewrite. V2: * Do some default_filename early sanity checks * Error out if removal of obsolete files fails.
A "set expression" here consists of a path formed of TAB-separated keys, indicating where in the YAML doc we want to make our changes, and a valid YAML expression that will be the payload to insert at that place. The result is a well-formed YAML document.
snapd uses a JSON serializer to format their payloads, which makes sense. Also, the previous version wasn't technically valid YAML anyway.
This removes the dependency on PyYAML from this subcommand. V2: Remove superfluous test data V3: Fix code comment left over from previous version on string escaping
The last use case of this function was in the previous implementation of `netplan set`, and it isn't considered part of our public API.
7f0fb1c to
f4bbd76
Compare
|
Regarding editing the ABI doc, shouldn't we hold until release? That way we can still tweak symbols introduced in previous PRs |
Yes, makes sense, especially as it does not break ABI in its current form! Feel free to merge this PR. |
…27584) The "unlink" part at the bottom of netplan.c:netplan_state_update_yaml_hierarchy seems to ignore any global values (such as "renderer") and operates on netdefs only. The issue is happens due to a combination of the following PRs: canonical#254 canonical#299 Which got SRUed into Jammy via 0.105-0ubuntu2~22.04.2 Here's a minimal reproducer: ``` netplan set network.renderer=NetworkManager --origin-hint=00-no-netdefs-just-globals netplan set network.ethernets.eth99.dhcp4=true --origin-hint=90-some-netdefs ls -l /etc/netplan/ netplan set network.ethernets.eth99=NULL cat /etc/netplan/00-no-netdefs-just-globals.yaml ``` FR-4793
…27584) The "unlink" part at the bottom of netplan.c:netplan_state_update_yaml_hierarchy seems to ignore any global values (such as "renderer") and operates on files containing netdefs only. The issue is happens due to a combination of the following PRs: canonical#254 canonical#299 Which got SRUed into Jammy via 0.105-0ubuntu2~22.04.2 Here's a minimal reproducer: ``` netplan set network.renderer=NetworkManager --origin-hint=00-no-netdefs-just-globals netplan set network.ethernets.eth99.dhcp4=true --origin-hint=90-some-netdefs ls -l /etc/netplan/ netplan set network.ethernets.eth99=NULL cat /etc/netplan/00-no-netdefs-just-globals.yaml ``` FR-4793
…27584) The "unlink" part at the bottom of netplan.c:netplan_state_update_yaml_hierarchy seems to ignore any global values (such as "renderer") and operates on files containing netdefs only. The issue is happens due to a combination of the following PRs: canonical#254 canonical#299 Which got SRUed into Jammy via 0.105-0ubuntu2~22.04.2 Here's a minimal reproducer: ``` netplan set network.renderer=NetworkManager --origin-hint=00-no-netdefs-just-globals netplan set network.ethernets.eth99.dhcp4=true --origin-hint=90-some-netdefs ls -l /etc/netplan/ netplan set network.ethernets.eth99=NULL cat /etc/netplan/00-no-netdefs-just-globals.yaml ``` FR-4793
…27584) The "unlink" part at the bottom of netplan.c:netplan_state_update_yaml_hierarchy seems to ignore any global values (such as "renderer") and operates on files containing netdefs only. The issue is happens due to a combination of the following PRs: canonical#254 canonical#299 Which got SRUed into Jammy via 0.105-0ubuntu2~22.04.2 Here's a minimal reproducer: ``` netplan set network.renderer=NetworkManager --origin-hint=00-no-netdefs-just-globals netplan set network.ethernets.eth99.dhcp4=true --origin-hint=90-some-netdefs ls -l /etc/netplan/ netplan set network.ethernets.eth99=NULL cat /etc/netplan/00-no-netdefs-just-globals.yaml ``` FR-4793
…27584) The "unlink" part at the bottom of netplan.c:netplan_state_update_yaml_hierarchy seems to ignore any global values (such as "renderer") and operates on files containing netdefs only. The issue is happens due to a combination of the following PRs: #254 #299 Which got SRUed into Jammy via 0.105-0ubuntu2~22.04.2 Here's a minimal reproducer: ``` netplan set network.renderer=NetworkManager --origin-hint=00-no-netdefs-just-globals netplan set network.ethernets.eth99.dhcp4=true --origin-hint=90-some-netdefs ls -l /etc/netplan/ netplan set network.ethernets.eth99=NULL cat /etc/netplan/00-no-netdefs-just-globals.yaml ``` FR-4793
…27584) Bug: https://bugs.launchpad.net/netplan/+bug/2027584 Origin: canonical/netplan@16bad06 The "unlink" part at the bottom of netplan.c:netplan_state_update_yaml_hierarchy seems to ignore any global values (such as "renderer") and operates on files containing netdefs only. The issue is happens due to a combination of the following PRs: canonical/netplan#254 canonical/netplan#299 Which got SRUed into Jammy via 0.105-0ubuntu2~22.04.2 Here's a minimal reproducer: ``` netplan set network.renderer=NetworkManager --origin-hint=00-no-netdefs-just-globals netplan set network.ethernets.eth99.dhcp4=true --origin-hint=90-some-netdefs ls -l /etc/netplan/ netplan set network.ethernets.eth99=NULL cat /etc/netplan/00-no-netdefs-just-globals.yaml ``` FR-4793 Gbp-Pq: Name 0020-netplan.c-Don-t-drop-files-with-just-global-values-o.patch
Description
As part of the larger PyYAML cleanup effort, this patch set rewrites the
netplan setto use libnetplan's own YAML parser instead of PyYAML. This meant enriching the parser to deal with null fields, that need to be tracked out-of-band, as well as creating new APIs to create YAML files out of a Netplan state, with different nuances to match the previous behavior.Checklist
make checksuccessfully.make check-coverage).