home-assistant / supervised-installer

Installer for a generic Linux system
Apache License 2.0
1.7k stars 585 forks source link

Bug Report: #369

Closed victron closed 3 months ago

victron commented 3 months ago

OS Version

Debian GNU/Linux 12 (bookworm)

System Information

Linux HA2 6.1.0-21-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.90-1 (2024-05-03) x86_64 GNU/Linux

What happened?

I found an issue on fresh install. No any errors during installation and finished with success. But container homeassistant crashed. In container logs I see next:

root@HA2:/home/vic# ha core logs
                              ^^^^^^^^^^^^
AttributeError: module 'brotli' has no attribute 'error'
[12:17:09] INFO: Home Assistant Core finish process exit code 1
[12:17:09] INFO: Home Assistant Core service shutdown
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun home-assistant (no readiness notification)
s6-rc: info: service legacy-services successfully started
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 188, in main
    from . import config, runner
  File "/usr/src/homeassistant/homeassistant/runner.py", line 18, in <module>
    from . import bootstrap
  File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 27, in <module>
    from . import (
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 30, in <module>
    from .components import persistent_notification
  File "/usr/src/homeassistant/homeassistant/components/persistent_notification/__init__.py", line 14, in <module>
    from homeassistant.components import websocket_api
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/__init__.py", line 14, in <module>
    from . import commands, connection, const, decorators, http, messages  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 15, in <module>
    from homeassistant.components.http import KEY_HASS, HomeAssistantView
  File "/usr/src/homeassistant/homeassistant/components/http/__init__.py", line 44, in <module>
    from homeassistant.helpers.network import NoURLAvailableError, get_url
  File "/usr/src/homeassistant/homeassistant/helpers/network.py", line 9, in <module>
    from hass_nabucasa import remote
  File "/usr/local/lib/python3.12/site-packages/hass_nabucasa/__init__.py", line 18, in <module>
    from .auth import CloudError, CognitoAuth
  File "/usr/local/lib/python3.12/site-packages/hass_nabucasa/auth.py", line 12, in <module>
    import boto3
  File "/usr/local/lib/python3.12/site-packages/boto3/__init__.py", line 17, in <module>
    from boto3.session import Session
  File "/usr/local/lib/python3.12/site-packages/boto3/session.py", line 17, in <module>
    import botocore.session
  File "/usr/local/lib/python3.12/site-packages/botocore/session.py", line 26, in <module>
    import botocore.client
  File "/usr/local/lib/python3.12/site-packages/botocore/client.py", line 15, in <module>
    from botocore import waiter, xform_name
  File "/usr/local/lib/python3.12/site-packages/botocore/waiter.py", line 18, in <module>
    from botocore.docs.docstring import WaiterDocstring
  File "/usr/local/lib/python3.12/site-packages/botocore/docs/__init__.py", line 15, in <module>
    from botocore.docs.service import ServiceDocumenter
  File "/usr/local/lib/python3.12/site-packages/botocore/docs/service.py", line 13, in <module>
    from botocore.docs.bcdoc.restdoc import DocumentStructure
  File "/usr/local/lib/python3.12/site-packages/botocore/docs/bcdoc/restdoc.py", line 17, in <module>
    from botocore.compat import OrderedDict
  File "/usr/local/lib/python3.12/site-packages/botocore/compat.py", line 32, in <module>
    from urllib3 import exceptions
  File "/usr/local/lib/python3.12/site-packages/urllib3/__init__.py", line 13, in <module>
    from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
  File "/usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py", line 41, in <module>
    from .response import HTTPResponse
  File "/usr/local/lib/python3.12/site-packages/urllib3/response.py", line 163, in <module>
    class HTTPResponse(io.IOBase):
  File "/usr/local/lib/python3.12/site-packages/urllib3/response.py", line 396, in HTTPResponse
    DECODER_ERROR_CLASSES += (brotli.error,)
                              ^^^^^^^^^^^^
AttributeError: module 'brotli' has no attribute 'error'
[12:17:19] INFO: Home Assistant Core finish process exit code 1

when I rm container and run as below, system running normally.

root@HA2:/home/vic# docker container rm -f homeassistant
homeassistant
root@HA2:/home/vic# docker run --name=homeassistant \
--hostname=homeassistant \
--env=SUPERVISOR=172.30.32.2 \
--env=HASSIO=172.30.32.2 \
--env=TZ=Europe/Kyiv \
--env=SUPERVISOR_TOKEN=2188b847b0a61857db376adb01b6bc7bd2e746d61543c0020b13f6003cc17520dc3debce07165d8d717d2875b6f3b7942d6a5417581cd8e2 \
--env=HASSIO_TOKEN=2188b847b0a61857db376adb01b6bc7bd2e746d61543c0020b13f6003cc17520dc3debce07165d8d717d2875b6f3b7942d6a5417581cd8e2 \
--dns=172.30.32.3 --network=host \
--privileged \
--workdir=/config --restart=no --label='supervisor_managed=' \
--log-opt tag={{.Name}} --log-driver=journald \
--add-host observer:172.30.32.6 --add-host supervisor:172.30.32.2 \
-v /home/homeassistant/homeassistant:/config \
-v /run/dbus:/run/dbus:ro \
-v /dev:/dev:ro \
--runtime=runc --detach=true \
--entrypoint "/bin/sh" \
ghcr.io/home-assistant/qemux86-64-homeassistant:2024.6.0 \
-c 'pip install --upgrade brotli; /init'

Suspect it could be some HW relation, because on my old system upgrade happened without problem.

Machine Type

generic-x86-64

Installer output

DATA_SHARE=/home/homeassistant dpkg --force-confdef --force-confold -i homeassistant-supervised.deb

root@HA2:/home/vic# D

Selecting previously unselected package homeassistant-supervised.
(Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 63502 files and directories currently installed.)
Preparing to unpack homeassistant-supervised.deb ...
[warn] 
[warn] If you want more control over your own system, run
[warn] Home Assistant as a VM or run Home Assistant Core
[warn] via a Docker container.
[warn] 
[warn] ModemManager service is enabled. This might cause issue when using serial devices.
[info] Stopping hassio_apparmor service
Warning: The unit file, source configuration file or drop-ins of hassio-apparmor.service changed on disk. Run 'systemctl daemon-reload' to reload units.

Adding 'diversion of /etc/NetworkManager/NetworkManager.conf to /etc/NetworkManager/NetworkManager.conf.real by homeassistant-supervised'
Adding 'diversion of /etc/NetworkManager/system-connections/default to /etc/NetworkManager/system-connections/default.real by homeassistant-supervised'
Adding 'diversion of /etc/docker/daemon.json to /etc/docker/daemon.json.real by homeassistant-supervised'
Adding 'diversion of /etc/network/interfaces to /etc/network/interfaces.real by homeassistant-supervised'
Leaving 'diversion of /etc/systemd/resolved.conf to /etc/systemd/resolved.conf.real by homeassistant-supervised'
Unpacking homeassistant-supervised (1.7.0) ...
Setting up homeassistant-supervised (1.7.0) ...
[info] Reload systemd
[info] Restarting NetworkManager
[info] Enable systemd-resolved
[info] Restarting systemd-resolved
[info] Restarting docker service
PING checkonline.home-assistant.io (104.26.5.238) 56(84) bytes of data.
64 bytes from 104.26.5.238: icmp_seq=1 ttl=52 time=38.7 ms

--- checkonline.home-assistant.io ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 38.748/38.748/38.748/0.000 ms
[info] Install supervisor startup scripts
[info] Install AppArmor scripts
[info] Start Home Assistant Supervised
[info] Installing the 'ha' cli
[info] Within a few minutes you will be able to reach Home Assistant at:
[info] http://homeassistant.local:8123 or using the IP address of your
[info] machine: http://192.168.2.187:8123

Relevant log output

os-agent test

root@HA2:/home/vic# gdbus introspect --system --dest io.hass.os --object-path /io/hass/os
node /io/hass/os {
  interface org.freedesktop.DBus.Introspectable {
    methods:
      Introspect(out s out);
    signals:
    properties:
  };
  interface org.freedesktop.DBus.Properties {
    methods:
      Get(in  s interface,
          in  s property,
          out v value);
      GetAll(in  s interface,
             out a{sv} props);
      Set(in  s interface,
          in  s property,
          in  v value);
    signals:
      PropertiesChanged(s interface,
                        a{sv} changed_properties,
                        as invalidates_properties);
    properties:
  };
  interface io.hass.os {
    methods:
    signals:
    properties:
      @org.freedesktop.DBus.Property.EmitsChangedSignal("invalidates")
      readonly s Version = '1.6.0';
      @org.freedesktop.DBus.Property.EmitsChangedSignal("true")
      readwrite b Diagnostics = false;
  };
};

ADR

Code of Conduct

victron commented 3 months ago

Never think that problem can be in docker. Short info how to diagnose, may can be useful. In my case I had two servers, on one everything was fine, so I have where to compare. I run simple container

docker run \
--name ha-test \
--restart=no \
-it --entrypoint '/bin/bash' \
ghcr.io/home-assistant/qemux86-64-homeassistant:2024.6.0

then inside

pip show brotli

on server with problem, this and some other packets was missing. To resolve I did

 docker image prune -a 

docker system prune -af && \
    docker image prune -af && \
    docker system prune -af --volumes && \
    docker system df

reboot