tomaae / homeassistant-truenas

TrueNAS integration for Home Assistant
Apache License 2.0
183 stars 16 forks source link

[Bug] Crash while getting system stats on setup #151

Closed kelvan closed 5 months ago

kelvan commented 5 months ago

Describe the issue

setup crashes with TrueNAS Core 13.0-U6.1

How to reproduce the issue

Steps to reproduce the behavior:

  1. Install through hacs
  2. Restart HA
  3. Add truesnas integration
  4. See error

Expected behavior

sets up successfully

Software versions

Traceback/Error logs

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/truenas/__init__.py", line 24, in async_setup_entry
    await controller.async_update()
  File "/config/custom_components/truenas/truenas_controller.py", line 129, in async_update
    await self.hass.async_add_executor_job(self.get_systemstats)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/truenas/truenas_controller.py", line 395, in get_systemstats
    max(list(filter(None, tmp_graph[i]["aggregations"]["mean"]))), 1
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: max() iterable argument is empty
tomaae commented 5 months ago

I will need debugs to see what is going on there, but my guess would be that this is truenas responding with faulty graph data.

kelvan commented 5 months ago
2024-04-11 13:40:35.450 DEBUG (SyncWorker_43) [custom_components.truenas.truenas_api] TrueNAS 10.0.1.179 query response: [{'name': 'load', 'identifier': None, 'data': [[None, None, None], [None, None, None], [None, None, None], [None, None, None], [None, None, None], [None, None, None], [None, None, None]], 'start': 1712835550, 'end': 1712835610, 'step': 10, 'legend': ['load_shortterm', 'load_midterm', 'load_longterm'], 'aggregations': {'min': [None, None, None], 'mean': [None, None, None], 'max': [None, None, None]}}, {'name': 'cputemp', 'identifier': None, 'data': [[None, None, None, None, None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None, None, None, None, None]], 'start': 1712835550, 'end': 1712835610, 'step': 10, 'legend': ['cputemp0', 'cputemp1', 'cputemp2', 'cputemp3', 'cputemp4', 'cputemp5', 'cputemp6', 'cputemp7', 'cputemp8', 'cputemp9', 'cputemp10', 'cputemp11'], 'aggregations': {'min': [None, None, None, None, None, None, None, None, None, None, None, None], 'mean': [None, None, None, None, None, None, None, None, None, None, None, None], 'max': [None, None, None, None, None, None, None, None, None, None, None, None]}}, {'name': 'cpu', 'identifier': None, 'data': [[0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0]], 'start': 1712835550, 'end': 1712835610, 'step': 10, 'legend': ['interrupt', 'system', 'user', 'nice', 'idle'], 'aggregations': {'min': [0.0, 0.0, 0.0, 0.0, 0.0], 'mean': [0.0, 0.0, 0.0, 0.0, 0.0], 'max': [0.0, 0.0, 0.0, 0.0, 0.0]}}, {'name': 'arcsize', 'identifier': None, 'data': [[None, None], [None, None], [None, None], [None, None], [None, None], [None, None], [None, None]], 'start': 1712835550, 'end': 1712835610, 'step': 10, 'legend': ['cache_size-arc_value', 'cache_size-L2_value'], 'aggregations': {'min': [None, None], 'mean': [None, None], 'max': [None, None]}}, {'name': 'arcratio', 'identifier': None, 'data': [[None, None], [None, None], [None, None], [None, None], [None, None], [None, None], [None, None]], 'start': 1712835550, 'end': 1712835610, 'step': 10, 'legend': ['cache_ratio-arc_value', 'cache_ratio-L2_value'], 'aggregations': {'min': [None, None], 'mean': [None, None], 'max': [None, None]}}, {'name': 'memory', 'identifier': None, 'data': [[0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0]], 'start': 1712835550, 'end': 1712835610, 'step': 10, 'legend': ['memory-active_value', 'memory-inactive_value', 'memory-wired_value', 'memory-laundry_value', 'memory-free_value'], 'aggregations': {'min': [0.0, 0.0, 0.0, 0.0, 0.0], 'mean': [0.0, 0.0, 0.0, 0.0, 0.0], 'max': [0.0, 0.0, 0.0, 0.0, 0.0]}}, {'name': 'interface', 'identifier': 'igb0', 'data': [[None, None, None], [None, None, None], [None, None, None], [None, None, None], [None, None, None], [None, None, None], [None, None, None]], 'start': 1712835550, 'end': 1712835610, 'step': 10, 'legend': ['rx', 'tx', 'overlap'], 'aggregations': {'min': [None, None, None], 'mean': [None, None, None], 'max': [None, None, None]}}, {'name': 'interface', 'identifier': 'igb1', 'data': [[None, None, None], [None, None, None], [None, None, None], [None, None, None], [None, None, None], [None, None, None], [None, None, None]], 'start': 1712835550, 'end': 1712835610, 'step': 10, 'legend': ['rx', 'tx', 'overlap'], 'aggregations': {'min': [None, None, None], 'mean': [None, None, None], 'max': [None, None, None]}}, {'name': 'interface', 'identifier': 're0', 'data': [[None, None, None], [None, None, None], [None, None, None], [None, None, None], [None, None, None], [None, None, None], [None, None, None]], 'start': 1712835550, 'end': 1712835610, 'step': 10, 'legend': ['rx', 'tx', 'overlap'], 'aggregations': {'min': [None, None, None], 'mean': [None, None, None], 'max': [None, None, None]}}]

You are right, I checked the reporting in truenas, there was a leftover remote graphite config that resulted in empty graphs