Defer writing http config until after startup has calmed down (#50000)
parent
301d4b0657
commit
a4432557d3
|
@ -64,7 +64,7 @@ MAX_CLIENT_SIZE: int = 1024 ** 2 * 16
|
||||||
|
|
||||||
STORAGE_KEY = DOMAIN
|
STORAGE_KEY = DOMAIN
|
||||||
STORAGE_VERSION = 1
|
STORAGE_VERSION = 1
|
||||||
|
SAVE_DELAY = 180
|
||||||
|
|
||||||
HTTP_SCHEMA = vol.All(
|
HTTP_SCHEMA = vol.All(
|
||||||
cv.deprecated(CONF_BASE_URL),
|
cv.deprecated(CONF_BASE_URL),
|
||||||
|
@ -371,7 +371,7 @@ async def start_http_server_and_save_config(
|
||||||
str(ip.network_address) for ip in conf[CONF_TRUSTED_PROXIES]
|
str(ip.network_address) for ip in conf[CONF_TRUSTED_PROXIES]
|
||||||
]
|
]
|
||||||
|
|
||||||
await store.async_save(conf)
|
store.async_delay_save(lambda: conf, SAVE_DELAY)
|
||||||
|
|
||||||
|
|
||||||
current_request: ContextVar[web.Request | None] = ContextVar(
|
current_request: ContextVar[web.Request | None] = ContextVar(
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
"""The tests for the Home Assistant HTTP component."""
|
"""The tests for the Home Assistant HTTP component."""
|
||||||
|
from datetime import timedelta
|
||||||
from ipaddress import ip_network
|
from ipaddress import ip_network
|
||||||
import logging
|
import logging
|
||||||
from unittest.mock import Mock, patch
|
from unittest.mock import Mock, patch
|
||||||
|
@ -7,8 +8,11 @@ import pytest
|
||||||
|
|
||||||
import homeassistant.components.http as http
|
import homeassistant.components.http as http
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
from homeassistant.util import dt as dt_util
|
||||||
from homeassistant.util.ssl import server_context_intermediate, server_context_modern
|
from homeassistant.util.ssl import server_context_intermediate, server_context_modern
|
||||||
|
|
||||||
|
from tests.common import async_fire_time_changed
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_stack():
|
def mock_stack():
|
||||||
|
@ -189,6 +193,10 @@ async def test_storing_config(hass, aiohttp_client, aiohttp_unused_port):
|
||||||
assert await async_setup_component(hass, http.DOMAIN, {http.DOMAIN: config})
|
assert await async_setup_component(hass, http.DOMAIN, {http.DOMAIN: config})
|
||||||
|
|
||||||
await hass.async_start()
|
await hass.async_start()
|
||||||
|
|
||||||
|
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=200))
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
restored = await hass.components.http.async_get_last_config()
|
restored = await hass.components.http.async_get_last_config()
|
||||||
restored["trusted_proxies"][0] = ip_network(restored["trusted_proxies"][0])
|
restored["trusted_proxies"][0] = ip_network(restored["trusted_proxies"][0])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue