* Improve D-Bus error handling for NetworkManager
There are quite some errors captured which are related by seemingly a
suddenly missing NetworkManager. Errors appear as:
23-11-21 17:42:50 ERROR (MainThread) [supervisor.dbus.network] Error while processing /org/freedesktop/NetworkManager/Devices/10: Remote peer disconnected
...
23-11-21 17:42:50 ERROR (MainThread) [supervisor.dbus.network] Error while processing /org/freedesktop/NetworkManager/Devices/35: The name is not activatable
Both errors seem to already happen at introspection time, however
the current code doesn't converts these errors to Supervisor issues.
This PR uses the already existing `DBus.from_dbus_error()`.
Furthermore this adds a new Exception `DBusNoReplyError` for the
`ErrorType.NO_REPLY` (or `org.freedesktop.DBus.Error.NoReply` in
D-Bus terms, which is the type of the first of the two issues above).
And finally it separates the `ErrorType.SERVICE_UNKNOWN` (or
`org.freedesktop.DBus.Error.ServiceUnknown` in D-Bus terms, which is
the second of the above issue) from `DBusInterfaceError` into a new
`DBusServiceUnkownError`.
This allows to handle errors more specifically.
To avoid too much churn, all instances where `DBusInterfaceError`
got handled, we are now also handling `DBusServiceUnkownError`.
The `DBusNoReplyError` and `DBusServiceUnkownError` appear when
the NetworkManager service stops or crashes. Instead of retrying
every interface we know, just give up if one of these issues appear.
This should significantly lower error messages users are seeing
and Sentry events.
* Remove unnecessary statement
* Fix pytests
* Make sure error strings are compared correctly
* Fix typo/remove unnecessary pylint exception
* Fix DBusError typing
* Add pytest for from_dbus_error
* Revert "Make sure error strings are compared correctly"
This reverts commit 10dc2e4c3887532921414b4291fe3987186db408.
* Add test cases
---------
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
* Make dbus-fast calls more robust
* Handle all exceptions and add test
* DBus minimal can't return commands list
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
* Revert "Disable CAS until it work (#3504)"
This reverts commit 435241bccf3f3c678161b50cfefd4b036f1daba9.
* Revert exception that are not forwarded
* enable for add-ons
* Apply suggestions from code review
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
* fix black
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
* Use the correct interface name to get properties of systemd
It seems that gdbus (or systemd) automatically pick the correct
interface and return the properties. However, dbussy requires the
correct interface name to get all properties.
* Don't expect array from Strength property
The property returns a type "y" which equates to "guchar":
https://developer-old.gnome.org/NetworkManager/stable/gdbus-org.freedesktop.NetworkManager.AccessPoint.html#gdbus-property-org-freedesktop-NetworkManager-AccessPoint.Strength
It seems that the old D-Bus implementation returned an array. With
dbus-next a integer is returned, so no list indexing required.
* Support signals and remove no longer used tests and code
* Pass rauc update file path as string
That is what the interface is expecting, otherwise the new lib chocks on
the Pathlib type.
* Support Network configuration with dbus-next
Assemble Python native objects and pass them to dbus-next. Use dbus-next
specific Variant class where necessary.
* Use org.freedesktop.NetworkManager.Connection.Active.StateChanged
org.freedesktop.NetworkManager.Connection.Active.PropertyChanged is
depricated. Also it seems that StateChanged leads to fewer and more
accurate signals.
* Pass correct data type to RequestScan.
RequestScan expects an option dictionary. Pass an empty option
dictionary to it.
* Update unit tests
Replace gdbus specific fixtures with json files representing the return
values. Those can be easily converted into native Python objects.
* Rename D-Bus utils module gdbus to dbus
* Set 600 premissions on json files
* Add test
* Fix local tar tests
* Fix tar test in action
* Use pytest fixture for tmp_path in tests
* remove not needed things
* Do not use `tar_file.add` to recursively add backup folder
As the folders might contain files which are being removed temporarily (e.g. shared memory file of sqlite database), relying on `tar_file.add` becomes problematic as it crashes the whole backup process if a file does not exist anymore.
This becomes annoying, if the file which causes the error should be excluded by the filter.
To workaround this issue, we manually iterating over the files/directories and apply filters before passing the file or directory to the `tar_file.add` method. As per [documentation](https://docs.python.org/3/library/pathlib.html#pure-paths), pure path does not access the file system.
Fixes#779
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
* Remove unused import
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
* Applied code review suggestions
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
* Applied codestyle
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
* Remove `pathlib` util and move `is_excluded_by_filter` into `tar` utils
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
* Rename method
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
* Rename `origin_dir` to `origin_path` and apply `Path` typehint
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
* Codestyle
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
* Add comment why we add the directory even if we are iterating over all its items
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
* Use `atomic_contents_add` from tar utils to archive addon data
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
* Remove unused function `exclude_filter`
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
* Remove unsecure default list value
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
* Some more codestyle
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
* Lowercase method name `Path.joinpath`
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
* Fix codestyle and use proper variable
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
* Add test for `_is_excluded_by_filter`
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
* Update addon.py
Co-authored-by: Pascal Vizeli <pascal.vizeli@syshack.ch>