-
Notifications
You must be signed in to change notification settings - Fork 215
dbus: Build the copy path correctly #331
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
Dbus Config()/Get() were not working due to a missing / in the destination path.
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.
Ugh. This should not happen. The fix LGTM!
I assume this is related to LP#1997467 ?
Can we build a test case around it, to avoid such failure in the future?
I've created a new integration test for dbus at tests/integration/dbus.py with 3 tests. As we need to add it to debian/tests/control to get it running, I also added the test for the bug fixed by this PR in the file integration/regressions.py. |
I think #330 would also be a nice autopkgtest. |
I came across the same issue when creating Config through D-Bus, maybe it's worth adding error control to the _copy_yaml_state method r = _copy_yaml_state(NETPLAN_ROOT, path, ret_error);
if (r < 0){
return sd_bus_error_setf(ret_error, SD_BUS_ERROR_FAILED,
"Failed to copy yaml structure to'%s': %s\n", path, strerror(errno));
} Without this, the execution appears to end up OK (even it shows the path of the new config created) but when you go to the folder it is empty, and that could cause removing the entire netplan of the machine if you apply it |
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.
This was initially just a small bug fix, but I still like the idea of adding some more error handling (and unit tests for coverage), while on it. Danilo, could you have a look into that if it's feasible?
Wrt the integration tests, we're checking (and modifying!) the eth0
interface as part of the new dbus tests. We consider eth0 en*
to be our management interfaces for the test runner, so we really shouldn't be playing with it inside the tests. It can change in name, depending on the distribution+version this test is being run on, and if we bring down the management interface, our test runners might go down.
Please see tests/integration/base.py:create_devices()
and make use of self.dev_e_client
(eth42) and/or self.dev_e2_client
(eth43) during the tests.
5490665
to
008be66
Compare
Thanks for your inputs @ezeriver94 :) As _copy_yaml_state() was already setting an error code/message, I just changed the callers to propagate it. Now a call to netplan-bus will fail like this:
I also reworked the integration tests to not use eth0 and output the error in case of failures. |
_copy_yaml_state() is setting an error when g_copy_file fails but it wasn't used by any callers.
This tests can be executed as autopkgtests. They cover netplan get, set and apply. There is a copy of test_dbus_config_get() in the file integration/regressions.py that can be dropped once we adapt the netplan.io package to run the new test set.
008be66
to
a62e140
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.
Thank you @daniloegea and @ezeriver94 for your input on this one. I really like the addition of the new dbus integration tests! We'll also rebase #330 on top of this, to make sure it passes, too.
The new spread tests passed (after some tiny fixes to the tests). So I think this is ready to be merged! |
Fwiw, it's also easy to run the spread tests as part of autopkgtest (we do this in snapd, see https://github.com/snapcore/snapd/blob/master/packaging/ubuntu-16.04/tests/integrationtests#L57). |
Nice! I think that's something we'd want to do. I think it should also avoid the packaging issue with meson, as we'd use pre-built binary packages to run the autopkgtest. |
netplan.io (0.105-0ubuntu2~22.04.3) jammy; urgency=medium * Fix and improvements for the DBus integration (LP: #1997467) Cherry-picked from upstream: canonical/netplan#331 - d/p/lp1997467/0009-dbus-Build-the-copy-path-correctly.patch Properly build the destination path before copying files in the dbus integration and improve error handling - d/p/lp1997467/0010-tests-Add-an-integration-test-for-netplan-dbus.patch Add an integration test to exercise the code path where the issue was addressed. netplan.io (0.105-0ubuntu2~22.04.2) jammy; urgency=medium * d/p/lp1997467: set only specific origin-hint if given (LP: #1997467) Cherry-picked from upstream: canonical/netplan#299 - d/libnetplan0.symbols: Add netplan_parser_load_nullable_overrides() API - d/p/0008-src-parse-plug-memory-leaks-in-nullable-handling.patch backport upstream commit 40c53bb (memory leak fixup of PR#299)
Dbus Config()/Get() were not working due to a missing / in the destination path.
We still need a nice integration test to catch this issue.
Description
The path is malformed:
/run/netplan/config-1YXM01etc/netplan/01-network-manager-all.yaml
Checklist
make check
successfully.make check-coverage
).