mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-11 03:50:59 +00:00
Avoid race condition on add-on installation (#6075)
The JobGroup concurrency decorator of the Addon class does not prevent concurrent installation since the AddonManager creates a separate object for each installation. Make sure only one add-on installation is running at a time by using the JobGroup decorator on the AddonManager install method instead.
This commit is contained in:
@@ -9,6 +9,8 @@ from typing import Self, Union
|
|||||||
|
|
||||||
from attr import evolve
|
from attr import evolve
|
||||||
|
|
||||||
|
from supervisor.jobs.const import JobConcurrency
|
||||||
|
|
||||||
from ..const import AddonBoot, AddonStartup, AddonState
|
from ..const import AddonBoot, AddonStartup, AddonState
|
||||||
from ..coresys import CoreSys, CoreSysAttributes
|
from ..coresys import CoreSys, CoreSysAttributes
|
||||||
from ..exceptions import (
|
from ..exceptions import (
|
||||||
@@ -180,6 +182,7 @@ class AddonManager(CoreSysAttributes):
|
|||||||
name="addon_manager_install",
|
name="addon_manager_install",
|
||||||
conditions=ADDON_UPDATE_CONDITIONS,
|
conditions=ADDON_UPDATE_CONDITIONS,
|
||||||
on_condition=AddonsJobError,
|
on_condition=AddonsJobError,
|
||||||
|
concurrency=JobConcurrency.QUEUE,
|
||||||
)
|
)
|
||||||
async def install(self, slug: str) -> None:
|
async def install(self, slug: str) -> None:
|
||||||
"""Install an add-on."""
|
"""Install an add-on."""
|
||||||
|
|||||||
Reference in New Issue
Block a user