File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,7 +106,8 @@ def _is_expired(lease) -> bool:
106106 if renew_time is None :
107107 return True
108108 if isinstance (renew_time , str ):
109- renew_dt = datetime .strptime (renew_time , "%Y-%m-%dT%H:%M:%SZ" ).replace (tzinfo = timezone .utc )
109+ ts = renew_time .replace ('Z' , '+00:00' )
110+ renew_dt = datetime .fromisoformat (ts )
110111 else :
111112 renew_dt = renew_time # already a datetime
112113 age = (datetime .now (timezone .utc ) - renew_dt ).total_seconds ()
@@ -197,9 +198,15 @@ def main():
197198 _stop_huey ()
198199 leading = False
199200 else :
200- # Check Huey is still up; if it died, exit so the pod restarts
201- if not _huey_alive ():
202- logger .error ("Huey exited unexpectedly — terminating pod so it restarts" )
201+ if huey_process is None :
202+ # We hold the lease (e.g. after a container restart)
203+ # but haven't started the process yet.
204+ logger .info ("Already hold lease after restart — starting Huey" )
205+ leading = True
206+ _start_huey ()
207+ elif not _huey_alive ():
208+ # Huey was running, but now it's not.
209+ logger .error ("Huey exited unexpectedly — terminating container so it restarts" )
203210 os ._exit (1 )
204211
205212 elif _is_expired (lease ):
You can’t perform that action at this time.
0 commit comments