truenas / charts

TrueNAS SCALE Apps Catalogs & Charts
BSD 3-Clause "New" or "Revised" License
258 stars 252 forks source link

Energy dashboard gone when upgrading from 2024.1.2_1.0.128 to 2024.1.3_1.0.130 #2148

Closed EddieKnight1 closed 4 months ago

EddieKnight1 commented 5 months ago

Hi,

After upgrading from 2024.1.2_1.0.128 to 2024.1.3_1.0.130 (step required to upgrade to 2024.1.6_2.0.6) I get everything working but:

Rolling back and reupgrading several times but no changes. It's giving always the same result.

Which logs, if any, should I provide for further investigation?

Regards.

stavros-k commented 5 months ago

Hello, Share the container logs, ideally from all containers in the home-assistant app (You can find a logs button under the Workloads card)

Also, have you tried to upgrade to 2.0.6 to see if that fixes the issue?

EddieKnight1 commented 4 months ago

Hi @stavros-k ,

I'm sorry I can't answer in time. Pretty busy agenda. If this ticket is bothering you, you can close it and I will use your answer to create a new ticket once I have time to do all the tests suggested, along with all the logs.

Sorry again.

tapayne88 commented 4 months ago

I'm having the same issue coming from 1.0.125

This is one of errors I'm seeing from the home-assistant pod

2024-02-18 12:32:38.810132+00:00sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "home-assistant-postgres" (172.17.31.47), port 5432 failed: FATAL:  password authentication failed for user "postgres"

Which matches what I'm seeing in the home-assistant-postgres pod. This repeats every ~3 seconds

2024-02-18 12:32:38.800370+00:002024-02-18 12:32:38.800 UTC [113] FATAL:  password authentication failed for user "postgres"
2024-02-18 12:32:38.800430+00:002024-02-18 12:32:38.800 UTC [113] DETAIL:  Password does not match for user "postgres".
2024-02-18 12:32:38.800458+00:00Connection matched pg_hba.conf line 99: "host all all all md5"
tapayne88 commented 4 months ago

I've managed to fix this by exec'ing onto my postgres container and modify the password of the postgres user.

You can find the password your home-assistant config pod is using in your configuration.yaml file

recorder:
  purge_keep_days: 30
  commit_interval: 3
  db_url: postgresql://postgres:<db_password>@home-assistant-postgres:5432/homeassistance?sslmode=disable

Then run something like the following to update it

k3s kubectl --namespace ix-home-assistant get pods # find the postgres pod
k3s kubectl --namespace ix-home-assistant exec -it home-assistant-postgres-<pod_hash> -- psql homeassistance # note name of DB
ALTER USER user_name WITH PASSWORD '<db_password>'
EddieKnight1 commented 4 months ago

I've tried running the fix above but I get this when running the second command: admin@truenas[~]$ sudo k3s kubectl --namespace ix-home-assistant exec -it home-assistant-postgres-ha-d79f89669-8bccf -- psql homeassistance psql: error: FATAL: role "root" does not exist command terminated with exit code 2

I've found in the log the "recorder" error is the reason for energy not appearing, so kudos for you! 2024-02-18T17:24:59.209053469+01:00 2024-02-18 17:24:59.207 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of 'energy'. Setup failed for dependencies: history, recorder 2024-02-18T17:24:59.209436114+01:00 2024-02-18 17:24:59.207 ERROR (MainThread) [homeassistant.setup] Setup failed for 'energy': (DependencyError(...), 'Could not setup dependencies: history, recorder')

Edit: Seems this does not fail: sudo k3s kubectl --namespace ix-home-assistant exec -it home-assistant-postgres-ha-d79f89669-8bccf -- psql -U postgres homeassistance

However, I get these errors while booting HA: 2024-02-18 17:54:39.925744+01:00sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not translate host name "home-assistant-postgres" to address: Name does not resolve 2024-02-18 17:54:39.925759+01:002024-02-18T17:54:39.925759788+01:00 2024-02-18 17:54:39.925775+01:00(Background on this error at: https://sqlalche.me/e/20/e3q8) 2024-02-18 17:54:42.931406+01:002024-02-18 17:54:42.930 ERROR (MainThread) [homeassistant.setup] Setup failed for 'recorder': Integration failed to initialize. 2024-02-18 17:54:50.757525+01:002024-02-18 17:54:50.757 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'dwains_dashboard' uses deprecated 'SafeLineLoader' instead of 'PythonSafeLoader', which will stop working in HA Core 2024.6, at custom_components/dwains_dashboard/process_yaml.py, line 69: loader.SafeLineLoader.add_constructor("!include", _include_yaml), please create a bug report at https://github.com/dwainscheeren/dwains-lovelace-dashboard/issues 2024-02-18 17:54:50.851013+01:002024-02-18 17:54:50.850 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of 'logbook'. Setup failed for dependencies: recorder 2024-02-18 17:54:50.851157+01:002024-02-18 17:54:50.850 ERROR (MainThread) [homeassistant.setup] Setup failed for 'logbook': (DependencyError(...), 'Could not setup dependencies: recorder') 2024-02-18 17:54:50.852676+01:002024-02-18 17:54:50.852 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of 'history'. Setup failed for dependencies: recorder 2024-02-18 17:54:50.852810+01:002024-02-18 17:54:50.852 ERROR (MainThread) [homeassistant.setup] Setup failed for 'history': (DependencyError(...), 'Could not setup dependencies: recorder') 2024-02-18 17:54:52.345688+01:002024-02-18 17:54:52.345 WARNING (SyncWorker_0) [py.warnings] /usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py:1061: InsecureRequestWarning: Unverified HTTPS request is being made to host '192.168.1.151'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings 2024-02-18 17:54:52.345730+01:00warnings.warn( 2024-02-18 17:54:52.345739+01:00 2024-02-18 17:54:52.398195+01:002024-02-18 17:54:52.397 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of 'energy'. Setup failed for dependencies: history, recorder

EddieKnight1 commented 4 months ago

Got this finally fixed. Perhaps the password was also an issue, but what I've found is the recoder URL dns for the psql connection was not resolving for "home-assistant-postgres:5432".

However, because the psql port is also published, I've used the IP address. db_url: postgresql://postgres:aaaaaaaaaaaaa@xxx.xxx.xxx.xxx:5432/homeassistance?sslmode=disable

This worked like a charm, with the Energy panel showing up agian and no more notifications for the recorder.

Now it's time for updating to 2024.2.2_2.0.9

Edit: Upgrade successful!

stavros-k commented 4 months ago

Glad that you both managed to upgrade, even after the manual intervention.

I tried a few installs now myself (1.0.130) and then upgrade to 2.0.9 without issues, multiple times. Which does not really help with debugging.

I wonder if the whole issue was just an init container failing to update db_url value.

Anyway, I'll close this for now, but if someone has issues, feel free to ping me here, so we can have another look.

Sorry for the trouble!