1313from typing import Any
1414
1515from msgspec import DecodeError
16+ from pioreactor import whoami
1617from pioreactor .config import config
1718from pioreactor .mureq import HTTPErrorStatus
1819from 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:
251256def 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