* Install dbus applications for CI tests
* Update const.py
* fix tests
* Fix test references to DEV version
* sudo apt-get
* Update builder.yml
---------
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
* Add udisks2 dbus support
* assert mountpoints
* Comment
* Add reference links
* docstring
* fix type
* fix type
* add typing extensions as import
* isort
* additional changes
* Simplify classes and conversions, fix bugs
* More simplification
* Fix imports
* fix pip
* Add additional properties and fix requirements
* fix tests maybe
* Handle optionality of certain configuration details
* black
* connect to devices before returning them
* Refactor for latest dbus work
* Not .items
* fix mountpoints logic
* use variants
* Use variants for options too
* isort
* Switch to dbus fast
* Move import to parent
* Add some fixture data
* Add another fixture and reduce the block devices list
* Implement changes discussed with mike
* Add property fixtures
* update object path
* Fix get_block_devices call
* Tests and refactor to minimize dbus reconnects
* Call super init in DBusInterfaceProxy
* Fix permissions on introspection files
---------
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
* Add host UTS namespace support for Add-Ons
Using the UTS host namespace is useful when running a mDNS responder
which learns the hostname from the gethostname syscall. This way the
add-on can use the system's hostname without further doing.
* Check host_uts default
* Adjust Security rating if host UTS mode and CAP_ADMIN is set
* Don't add hostname to DNS server if UTS namespace is disabled
* Simplify hostname logic
* Update supervisor/docker/addon.py
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
---------
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
* Bump black from 22.12.0 to 23.1.0
Bumps [black](https://github.com/psf/black) from 22.12.0 to 23.1.0.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](https://github.com/psf/black/compare/22.12.0...23.1.0)
---
updated-dependencies:
- dependency-name: black
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com>
* Bump black in precommit
* reformat with new black version
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
* Do not let aiohttp add a Content-Type header
aiohttp adds a Content-Type header by default, as well as other headers.
This may usually be convenient, but it breaks APIs that explicitly ask for no content type header, for instance on post requests with an empty body.
Since ingress is proxying the requests from the browser to the add-on, it should avoid modifying them.
I only skip this header auto generation because it actually breaks the Adguard add-on.
- https://github.com/hassio-addons/addon-adguard-home/issues/359
I haven't tested this yet.
* Use headers constant
* 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>
* Add enhanced logging REST endpoints using systemd-journal-gatewayd
Add /host/logs/entries and /host/logs/{identifier}/entries to expose log
entries from systemd-journald running on the host. Use
systemd-journal-gatewayd which exposes the logs to the Supervisor via
Unix socket.
Current two query string parameters are allowed: "boot" and "follow".
The first will only return logs since last boot. The second will keep
the HTTP request open and send new log entries as they get added to the
systemd-journal.
* Allow Range header
Forward the Range header to systemd-journal-gatewayd. This allows to
select only a certain amount of log data. The Range header is a standard
header to select only partial amount of data. However, the "entries="
prefix is custom for systemd-journal-gatewayd, denoting that the numbers
following represent log entries (as opposed to bytes or other metrics).
* Avoid connecting if systemd-journal-gatewayd is not available
* Use path for all options
* Add pytests
* Address pylint issues
* Boot ID offsets and slug to identifier
* Fix tests
* API refactor from feedback
* fix tests and add identifiers
* stop isort and pylint fighting
* fix tests
* Update default log identifiers
* Only modify /host/logs endpoints
* Fix bad import
* Load log caches asynchronously at startup
* Allow task to complete in fixture
* Boot IDs and identifiers loaded on demand
* Add suggested identifiers
* Fix tests around boot ids
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
As per commit 80e67b3 we're supporting a compressed flag on backups to
define whether a tar archive should be fully compressed or not, but
while we respect this for all the addons and folders we don't do it for
the actual homeassistant archive, that is always compressed despite the
passed flag.
Fix this by applying the same logic to the homeassistant archive too.
* Improve system behavior on low memory situation
Adjust OOM killer score to prevent crucial services from getting
selected.
* Adjust OOM score of DNS plug-in as well
Creating the asyncio loop explicitly. This fixes the following
deprecation warning on Python 3.10:
/usr/src/supervisor/supervisor/__main__.py:31: DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop()
* Update architecture compatibility JSON file
In particular, this enables 32-bit Arm add-ons for Yellow.
* Set correct hassio machine for odroid-xu4 (which is odroid-xu)
* Support for Docker manifests base images add-on build
* Set platform for build and tests
* Remove empty test
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
* Add update freeze option
* Freeze to auto update and plugin condition
* Add tests
* Add supervisor_version evaluation
* OS updates require supervisor up to date
* Run version check during startup
* Docker events based watchdog
* Separate monitor from DockerAPI since it needs coresys
* Move monitor into dockerAPI
* Fix properties on coresys
* Add watchdog tests
* Added tests
* pylint issue
* Current state failures test
* Thread-safe event processing
* Use labels property
* Output backup log on error
* Apply suggestions from code review
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
* Cleanup API / old rebranding
* cleanup p2
* next round
* better comments
* cleanup import
* support only installed add-ons
* legacy migration
* test fixes
* add old env back
* revert for Core
* fix issues with old core
* fix
* using installed short cat
* revert
* extend legacy
* cleanup
* fix path
* Fix missing
* add stop
* readd old token
* Add minimal
* extend attributes
* Add repo back
* add more repo info
* Make it working
* Bump frontend to e7848262 (#3680)
* Add icon
Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
* Move repository urls to store settings file
* Remove default repos from supervisor config
* Fix clone at initial store load
* Mock git load in repository fixture
* OS latest version set from upgrade path
* fix tests
* Update test_updater.py
* Revert / fetch_update is global unwrapped
Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
* Create issue for detected DNS server problem
* Validate behavior on restart as well
* tls:// not supported, remove check
* Move DNS server checks into resolution checks
* Revert all changes to plugins.dns
* Run DNS server checks if affected
* Mock aiodns query during all checks tests
* Handle TarError/OSError in Core config backup routine
Make sure to handle TarError and OSError exceptions and print a warning
when backing up the Home Assistant Core config folder. This restores
behavior before the introduction of Backup notification in #3305.
* Reraise errors during HA Core backup
* Raise BackupError when encountering error during Add-on Backup
* Log to error as well
Co-authored-by: Pascal Vizeli <pascal.vizeli@syshack.ch>
Co-authored-by: Joakim Sørensen <hi@ludeeus.dev>
The CLI plug-in stays up even without command. This saves a few
kilobytes of RAM.
It also allows s6-overlay's stage2 to complete. The stage2 execlineb
process has an enormously long cmdline, with strings like "init-stage2
failed" in it. This has previously led people to belive that there is a
problem (while there isn't). So as a side effect, getting stage2 to
complete side steps such confusion and makes the list of processes
cleaner.
* Revert "Disable CAS until it work (#3504)"
This reverts commit 435241bccf.
* 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>
* Using CAS for content-trust
* v2
* Fix linting errors
* Adjust field checked for status in CAS response
* CI workflow needs CAS not VCN now
* Use cwd in test as code won't be in /usr/src
* Pre-cache CAS pub key for supervisor
* Cas doesn't actually need key file executable
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
Hassio supervisor saves backups in tar files that contains compressed
tar archives, this is convenient when such backups are kept in the same
environment or need to be transferred remotely, but it's not convenient
when they will be processed using other backup tools such as borg or
restic that can handle compression, encryption and data deduplication
themselves.
In fact deduplication won't actually work at all with hassio compressed
backups as there's no way to find common streams for such tools (unless
we make them to export the archives during importing as borg's
import-tar can do), but this would lead to archives that are not easily
recoverable by the supervisor.
So, make possible to pass a "compressed" boolean parameter when creating
backups that will just archive all the data uncompressed.
It will be then up to other tools to manage the archives compression.
Make sure to not reference version attribute from the DockerAddon
instance since it is not yet populated in case this instance hadn't
installed that Add-on previously.
Use the higher level Images.load() API which returns a list of images
instead of loading with the lower level API and then search for the
image we just imported.
* Notify HA Core when backup is being executed
Notify Home Assistant Core using the Websocket API when the Home Assistant
config directory is about to get backed up. This makes sure the Core can
prepare the SQLite database (if active) so it safe to make a backup.
* Only close WebSocket connection on connection errors
Let regular WebSocket errors bubble to the caller so they can be handled
explicitly.
* Add version restriction to backup/start/end WS commands
* Restore Home Assistant metadata when Home Assistant is selected
Currently log files are excluded from the backup. Core uses a time or
startup based log rotation mechanism, both append a dot and an
additional; string (`.1`, `.{timestamp}`). There is also a fault
mechanism which creates a log file with the ending `.log.fault`. Exclude
all cases from the backup.
* De-duplicate Backup/Restore logic
Create internal _do_backup()/_do_restore() method which de-duplicates
some of the backup/restore logic previously part of full/partial backup/restore.
* Add Backup/Restore test coverage
* Avoid accessing properties of udevice.parent
The if statement currently causes access of a property of
udevice.parent, leading to:
tests/hardware/test_module.py: 104 warnings
/workspaces/supervisor/supervisor/hardware/data.py:50: DeprecationWarning: Will be removed in 1.0. Access properties with Device.properties.
Change the if statement to avoid property access and the deprecation
warning.
* Create task before using asyncio.wait()
Avoid deprecation warnings such as:
tests/store/test_custom_repository.py: 5 warnings
/workspaces/supervisor/supervisor/store/__init__.py:113: DeprecationWarning: The explicit passing of coroutine objects to asyncio.wait() is deprecated since Python 3.8, and scheduled for removal in Python 3.11.
await asyncio.wait(tasks)
The documentation says that passing null to `image` allows to clear
the option. Currently `null` is not allowed leading to:
Error: expected string or buffer for dictionary value @ data['image']. Got None
While at it, also update type annotation to reflect what the API
currently allows.
* Fix static assignment of IPv6 addresses
* Support statically assigned link local addresses
Statically assigned link local addresses are perfectly supported in IPv6
use cases.
* Handle empty Add-on backup properly
Check if the data directory exist in the backup. If not, make sure a
directory gets created so the options.json can be written afterwards.
* Remove unrelated change
Sometimes NetworkManager network devices disappear while we are query
them. Presumably those are network interfaces generated by Docker.
Skip them and print a warning.
* Allow to update connection information
* Introduce Signal wrapper class using async context manager
This allows to start monitoring signals and execute code before
processing signals. With that it is possible to check for state changes
in a race free manor.
* Fix unit tests
* Introduce enum for network connectivity
* Differentiate between Bus Name and Interface consts
The Bus names and interfaces look quite similar in D-Bus: Both use dots
to separate words. Usually all interfaces available below a certan Bus
name start with the Bus name. Quite often the Bus name itself is also
available as an interface.
However, those are different things. To avoid confusion, add the type of
const to the const name.
* Remove unused const
* Disconnect D-Bus when not used
Make sure Python disconnects from D-Bus when objects get destroyed. This
avoids exhausting D-Bus connection limit which causes the following
error message:
[system] The maximum number of active connections for UID 0 has been reached (max_connections_per_user=256)
* Filter signals by object as well
Make sure we only listen to signals on that particular object. Also
support filtering messages via message filter callback.
* Explicitly wait until Connection is activated
Wait for activated or raise an error. This avoids too early/errornous
updates when state of the connection changes to "activating" or similar
intermediate signal states.
Fixes: #2639
* Fix VLAN configuration
* Add link to D-Bus object documentation
* Fix network settings update test
* Make MessageBus object optional