home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.16k stars 31.13k forks source link

Cloud hangs startup if internet is down. #42698

Closed dragon2611 closed 4 years ago

dragon2611 commented 4 years ago

The problem

Home assistant startup hangs, I think it's a DNS resolution issue, I suspect the Home assistant container started up before pi-hole did when I rebooted the host.

"Home Assistant is starting, not everything will be available until it is finished."

Environment

Problem-relevant configuration.yaml

#
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
light: !include lights.yaml

tplink:
 discovery: false
 switch:
  - host: xxx
  - host: xxx
  - host: xxx
  - host: xxx
 strip:
  - host: xxx

Traceback/Error logs

Source: components/cloud/alexa_config.py:120
First occurred: October 31, 2020, 9:17:23 PM (1 occurrences)
Last logged: October 31, 2020, 9:17:23 PM

Error during setup of component cloud
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 964, in _create_direct_connection
    hosts = await asyncio.shield(self._resolve_host(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 829, in _resolve_host
    addrs = await \
  File "/usr/local/lib/python3.8/site-packages/aiohttp/resolver.py", line 29, in resolve
    infos = await self._loop.getaddrinfo(
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
    return await self.run_in_executor(
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 213, in _async_setup_component
    result = await task
  File "/usr/src/homeassistant/homeassistant/components/cloud/__init__.py", line 234, in async_setup
    await cloud.start()
  File "/usr/local/lib/python3.8/site-packages/hass_nabucasa/__init__.py", line 251, in start
    await self.client.logged_in()
  File "/usr/src/homeassistant/homeassistant/components/cloud/client.py", line 114, in logged_in
    await self.alexa_config.async_enable_proactive_mode()
  File "/usr/src/homeassistant/homeassistant/components/alexa/config.py", line 55, in async_enable_proactive_mode
    await self._unsub_proactive_report
  File "/usr/src/homeassistant/homeassistant/components/alexa/state_report.py", line 26, in async_enable_proactive_mode
    await smart_home_config.async_get_access_token()
  File "/usr/src/homeassistant/homeassistant/components/cloud/alexa_config.py", line 120, in async_get_access_token
    resp = await cloud_api.async_alexa_access_token(self._cloud)
  File "/usr/local/lib/python3.8/site-packages/hass_nabucasa/cloud_api.py", line 17, in check_token
    return await func(cloud, *args)
  File "/usr/local/lib/python3.8/site-packages/hass_nabucasa/cloud_api.py", line 28, in log_response
    resp = await func(*args)
  File "/usr/local/lib/python3.8/site-packages/hass_nabucasa/cloud_api.py", line 89, in async_alexa_access_token
    return await cloud.websession.post(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 480, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 858, in _create_connection
    _, proto = await self._create_direct_connection(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/connector.py", line 971, in _create_direct_connection
    raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host alexa-api.nabucasa.com:443 ssl:default [Try again]

Additional information

Restarting the Homeassitant container with no config changes worked, but ideally having DNS or internet access being unavailable shouldn't cause startup to hang.

probot-home-assistant[bot] commented 4 years ago

cloud documentation cloud source (message by IssueLinks)

probot-home-assistant[bot] commented 4 years ago

Hey there @home-assistant/cloud, mind taking a look at this issue as its been labeled with an integration (cloud) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)