Skip to content

Commit 4f2c055

Browse files
try this hack to fix race condition from too many pio update uis occuring
1 parent 847f3dc commit 4f2c055

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

pioreactorui/tasks.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from typing import Any
1414

1515
from msgspec import DecodeError
16+
from pioreactor import whoami
1617
from pioreactor.config import config
1718
from pioreactor.mureq import HTTPErrorStatus
1819
from pioreactor.mureq import HTTPException
@@ -114,6 +115,7 @@ def update_app_from_release_archive_across_cluster(archive_location: str, units:
114115
distribute_archive_to_workers = [PIOS_EXECUTABLE, "cp", archive_location, "-y"]
115116
run(distribute_archive_to_workers)
116117

118+
# this may include leader, and leader's UI. If it's not included, we need to update the UI later.
117119
update_app_across_all_workers = [
118120
PIOS_EXECUTABLE,
119121
"update",
@@ -123,14 +125,17 @@ def update_app_from_release_archive_across_cluster(archive_location: str, units:
123125
]
124126
run(update_app_across_all_workers)
125127

126-
update_ui_on_leader = [
127-
"pio",
128-
"update",
129-
"ui",
130-
"--source",
131-
"/tmp/pioreactorui_archive.tar.gz",
132-
]
133-
run(update_ui_on_leader)
128+
if not whoami.am_I_a_worker():
129+
# update the UI on the leader
130+
update_ui_on_leader = [
131+
"pio",
132+
"update",
133+
"ui",
134+
"--source",
135+
"/tmp/pioreactorui_archive.tar.gz",
136+
]
137+
run(update_ui_on_leader)
138+
134139
return True
135140
else:
136141
logger.info(f"Updating app and ui on unit {units} from {archive_location}")
@@ -251,7 +256,7 @@ def pio_update_app(*args: str, env: dict[str, str] = {}) -> bool:
251256
def pio_update(*args: str, env: dict[str, str] = {}) -> bool:
252257
logger.info(f'Executing `{join(("pio", "update") + args)}`, {env=}')
253258
run((PIO_EXECUTABLE, "update") + args, env=dict(os.environ) | env)
254-
# this always returns >0 because it kills huey, I think, so just return true
259+
# HACK: this always returns >0 because it kills huey, I think, so just return true
255260
return True
256261

257262

0 commit comments

Comments
 (0)