core: Since HA 2022.2 upgrade every restart causes loss of all Glances integrations
The problem
I upgraded to 2022.2 and since then my glances integrations complain in the integrations page “Failed to set up”. I can delete the integration and reinstall it and it will work. However, as soon as I restart HA, the integration reports itself as broken again and will not correct itself.
What version of Home Assistant Core has the issue?
2022.2.0
What was the last working version of Home Assistant Core?
2021.12.10
What type of installation are you running?
Home Assistant Supervised
Integration causing the issue
Glances
Link to integration documentation on our website
https://www.home-assistant.io/integrations/glances/
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Logger: homeassistant.config_entries
Source: components/glances/__init__.py:126
First occurred: 3:17:33 PM (5 occurrences)
Last logged: 3:17:34 PM
Error setting up entry System for glances
Error setting up entry .... there are many of these ...
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 31, in read
return await self._stream.receive(max_bytes=max_bytes)
File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 1105, in receive
await self._protocol.read_event.wait()
File "/usr/local/lib/python3.9/asyncio/locks.py", line 226, in wait
await fut
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 8, in map_exceptions
yield
File "/usr/local/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 33, in read
return b""
File "/usr/local/lib/python3.9/site-packages/anyio/_core/_tasks.py", line 103, in __exit__
raise TimeoutError
TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
yield
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 308, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 244, in handle_async_request
raise exc
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 228, in handle_async_request
response = await connection.handle_async_request(request)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 90, in handle_async_request
return await self._connection.handle_async_request(request)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 102, in handle_async_request
raise exc
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 81, in handle_async_request
) = await self._receive_response_headers(**kwargs)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 143, in _receive_response_headers
event = await self._receive_event(timeout=timeout)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 172, in _receive_event
data = await self._network_stream.read(
File "/usr/local/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 33, in read
return b""
File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
raise to_exc(exc)
httpcore.ReadTimeout
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 327, in async_setup
result = await component.async_setup_entry(hass, self)
File "/usr/src/homeassistant/homeassistant/components/glances/__init__.py", line 81, in async_setup_entry
if not await client.async_setup():
File "/usr/src/homeassistant/homeassistant/components/glances/__init__.py", line 126, in async_setup
await self.api.get_data("all")
File "/usr/local/lib/python3.9/site-packages/glances_api/__init__.py", line 52, in get_data
response = await client.get(str(url))
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1736, in get
return await self.request(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1513, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1600, in send
response = await self._send_handling_auth(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1628, in _send_handling_auth
response = await self._send_handling_redirects(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1665, in _send_handling_redirects
response = await self._send_single_request(request)
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1702, in _send_single_request
response = await transport.handle_async_request(request)
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 308, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ReadTimeout
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 21
Commits related to this issue
- TimeoutException should be handled I believe that the lack of support for TimeoutException may be the root cause of a few issues encountered since the migration to httpx (see https://github.com/home-... — committed to b0z02003/python-glances-api by b0z02003 2 years ago
- TimeoutException should be handled (#8) * TimeoutException should be handled I believe that the lack of support for TimeoutException may be the root cause of a few issues encountered since the mig... — committed to home-assistant-ecosystem/python-glances-api by b0z02003 2 years ago
I tried to take a quick look at the issue (which I also encounter) and I believe that the root cause may not be related to the integration itself but rather to the glances_api being used. Back in january, this API was bumped from 0.2.0 to 0.3.4 (#62090) and the main change between the 0.2.x and 0.3.x versions of this API seems to be the migration to httpx.
This API used to handle timeouts, however, now that it uses httpx, it only handles httpx.ConnectError which are not a parent of httpx.TimeoutException. So I believe that the glances_api should be patched and the integration version should then be bumped.
Ownership comes with responsibilities 😉