Skip to content

Commit 12a9727

Browse files
Williangalvanipatrickelectric
authored andcommitted
blueos_startup_update: add boot-loop detection
1 parent 60ac993 commit 12a9727

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

core/tools/blueos_startup_update/blueos_startup_update.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
logging.basicConfig(handlers=[InterceptHandler()], level=0)
1919
init_logger(SERVICE_NAME)
2020

21+
BOOT_LOOP_DETECTOR = "/root/.config/.boot_loop_detector"
22+
2123
# Any change made in this DELTA_JSON dict should be also made
2224
# into /bootstrap/startup.json.default too!
2325
DELTA_JSON = {
@@ -445,6 +447,10 @@ def run_command_is_working():
445447

446448
def main() -> int:
447449
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
448454
current_git_version = os.getenv("GIT_DESCRIBE_TAGS")
449455
match = re.match(r"(?P<tag>.*)-(?P<commit_number>\d+)-(?P<commit_hash>[a-z0-9]+)", current_git_version)
450456
tag, commit_number, commit_hash = match["tag"], match["commit_number"], match["commit_hash"]
@@ -496,6 +502,8 @@ def main() -> int:
496502
logger.warning("The system will restart in 10 seconds because the following applied patches required restart:")
497503
for patch in patches_requiring_restart:
498504
logger.info(patch)
505+
# pylint: disable-next=consider-using-with,unspecified-encoding
506+
open(BOOT_LOOP_DETECTOR, "w").close()
499507
time.sleep(10)
500508
run_command("sudo reboot", False)
501509
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:
506514

507515
if __name__ == "__main__":
508516
main()
517+
os.remove(BOOT_LOOP_DETECTOR)

0 commit comments

Comments
 (0)