18
18
logging .basicConfig (handlers = [InterceptHandler ()], level = 0 )
19
19
init_logger (SERVICE_NAME )
20
20
21
+ BOOT_LOOP_DETECTOR = "/root/.config/.boot_loop_detector"
22
+
21
23
# Any change made in this DELTA_JSON dict should be also made
22
24
# into /bootstrap/startup.json.default too!
23
25
DELTA_JSON = {
@@ -445,6 +447,10 @@ def run_command_is_working():
445
447
446
448
def main () -> int :
447
449
start = time .time ()
450
+ # check if boot_loop_detector exists
451
+ if os .path .isfile (BOOT_LOOP_DETECTOR ):
452
+ logger .warning ("It seems we the startup patches were just applied on the last boot. skipping patches..." )
453
+ return
448
454
current_git_version = os .getenv ("GIT_DESCRIBE_TAGS" )
449
455
match = re .match (r"(?P<tag>.*)-(?P<commit_number>\d+)-(?P<commit_hash>[a-z0-9]+)" , current_git_version )
450
456
tag , commit_number , commit_hash = match ["tag" ], match ["commit_number" ], match ["commit_hash" ]
@@ -496,6 +502,8 @@ def main() -> int:
496
502
logger .warning ("The system will restart in 10 seconds because the following applied patches required restart:" )
497
503
for patch in patches_requiring_restart :
498
504
logger .info (patch )
505
+ # pylint: disable-next=consider-using-with,unspecified-encoding
506
+ open (BOOT_LOOP_DETECTOR , "w" ).close ()
499
507
time .sleep (10 )
500
508
run_command ("sudo reboot" , False )
501
509
time .sleep (600 ) # we are already rebooting anyway. but we don't want the other services to come up
@@ -506,3 +514,4 @@ def main() -> int:
506
514
507
515
if __name__ == "__main__" :
508
516
main ()
517
+ os .remove (BOOT_LOOP_DETECTOR )
0 commit comments