updated: clear overlay on exception (#21489)

old-commit-hash: a44072753d43dc6bb67e3e326438637bc9a62d20
This commit is contained in:
Adeeb Shihadeh
2021-07-05 19:27:06 -07:00
committed by GitHub
parent fa25e8d43c
commit 57cc915aa9
+5 -4
View File
@@ -92,8 +92,8 @@ def set_consistent_flag(consistent: bool) -> None:
consistent_file = Path(os.path.join(FINALIZED, ".overlay_consistent")) consistent_file = Path(os.path.join(FINALIZED, ".overlay_consistent"))
if consistent: if consistent:
consistent_file.touch() consistent_file.touch()
elif not consistent and consistent_file.exists(): elif not consistent:
consistent_file.unlink() consistent_file.unlink(missing_ok=True)
os.sync() os.sync()
@@ -356,8 +356,7 @@ def main():
wait_helper.sleep(30) wait_helper.sleep(30)
overlay_init = Path(os.path.join(BASEDIR, ".overlay_init")) overlay_init = Path(os.path.join(BASEDIR, ".overlay_init"))
if overlay_init.exists(): overlay_init.unlink(missing_ok=True)
overlay_init.unlink()
first_run = True first_run = True
last_fetch_time = 0 last_fetch_time = 0
@@ -406,9 +405,11 @@ def main():
returncode=e.returncode returncode=e.returncode
) )
exception = f"command failed: {e.cmd}\n{e.output}" exception = f"command failed: {e.cmd}\n{e.output}"
overlay_init.unlink(missing_ok=True)
except Exception as e: except Exception as e:
cloudlog.exception("uncaught updated exception, shouldn't happen") cloudlog.exception("uncaught updated exception, shouldn't happen")
exception = str(e) exception = str(e)
overlay_init.unlink(missing_ok=True)
set_params(new_version, update_failed_count, exception) set_params(new_version, update_failed_count, exception)
wait_helper.sleep(60) wait_helper.sleep(60)