mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-21 08:06:30 +00:00
Check/get ingress port on add-on load (#4744)
Instead of setting the ingress port on install, make sure to set the port when the add-on gets loaded (on Supervisor startup and before installation). This is necessary since the dynamic ingress ports are not stored as part of the add-on data storage themself but in the ingress data store. So on every Supervisor start the port needs to be transferred to the add-on model. Note that we still need to check the port on add-on update since the add-on potentially added (dynamic) ingress on update. Same applies to add-on restore (the restored version might use a dynamic ingress port).
This commit is contained in:
parent
72e64676da
commit
96f4ba5d25
@ -184,6 +184,7 @@ class Addon(AddonModel):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await self._check_ingress_port()
|
||||||
with suppress(DockerError):
|
with suppress(DockerError):
|
||||||
await self.instance.attach(version=self.version)
|
await self.instance.attach(version=self.version)
|
||||||
|
|
||||||
@ -640,8 +641,6 @@ class Addon(AddonModel):
|
|||||||
self.sys_addons.data.uninstall(self)
|
self.sys_addons.data.uninstall(self)
|
||||||
raise AddonsError() from err
|
raise AddonsError() from err
|
||||||
|
|
||||||
await self._check_ingress_port()
|
|
||||||
|
|
||||||
# Add to addon manager
|
# Add to addon manager
|
||||||
self.sys_addons.local[self.slug] = self
|
self.sys_addons.local[self.slug] = self
|
||||||
|
|
||||||
@ -769,7 +768,6 @@ class Addon(AddonModel):
|
|||||||
raise AddonsError() from err
|
raise AddonsError() from err
|
||||||
|
|
||||||
self.sys_addons.data.update(self.addon_store)
|
self.sys_addons.data.update(self.addon_store)
|
||||||
await self._check_ingress_port()
|
|
||||||
_LOGGER.info("Add-on '%s' successfully rebuilt", self.slug)
|
_LOGGER.info("Add-on '%s' successfully rebuilt", self.slug)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
@ -683,3 +683,16 @@ async def test_local_example_start(
|
|||||||
await install_addon_example.start()
|
await install_addon_example.start()
|
||||||
|
|
||||||
assert addon_config_dir.is_dir()
|
assert addon_config_dir.is_dir()
|
||||||
|
|
||||||
|
|
||||||
|
async def test_local_example_ingress_port_set(
|
||||||
|
coresys: CoreSys,
|
||||||
|
container: MagicMock,
|
||||||
|
tmp_supervisor_data: Path,
|
||||||
|
install_addon_example: Addon,
|
||||||
|
):
|
||||||
|
"""Test start of an addon."""
|
||||||
|
install_addon_example.path_data.mkdir()
|
||||||
|
await install_addon_example.load()
|
||||||
|
|
||||||
|
assert install_addon_example.ingress_port != 0
|
||||||
|
@ -18,3 +18,5 @@ options:
|
|||||||
message: "Hello world..."
|
message: "Hello world..."
|
||||||
schema:
|
schema:
|
||||||
message: "str?"
|
message: "str?"
|
||||||
|
ingress: true
|
||||||
|
ingress_port: 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user