From 2b60599543085e87df558b890146a3c4fa34456b Mon Sep 17 00:00:00 2001 From: Jason Young <46612682+jyoung8607@users.noreply.github.com> Date: Fri, 10 Jul 2020 04:41:26 -0700 Subject: [PATCH] Make updated more resilient (#1853) * Add sleep at updated startup * Mitigate symlink-related FS damage old-commit-hash: c43df81214d34d90b318defbd7f43e240b0c8f45 --- launch_chffrplus.sh | 7 +++++-- selfdrive/updated.py | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/launch_chffrplus.sh b/launch_chffrplus.sh index 3ef93eb4ef..ae1660411b 100755 --- a/launch_chffrplus.sh +++ b/launch_chffrplus.sh @@ -41,9 +41,12 @@ function launch { mv $BASEDIR /data/safe_staging/old_openpilot mv "${STAGING_ROOT}/finalized" $BASEDIR + cd $BASEDIR - # The mv changed our working directory to /data/safe_staging/old_openpilot - cd "${BASEDIR}" + # Partial mitigation for symlink-related filesystem corruption + # Ensure all files match the repo versions after update + git reset --hard + git submodule foreach --recursive git reset --hard echo "Restarting launch script ${LAUNCHER_LOCATION}" exec "${LAUNCHER_LOCATION}" diff --git a/selfdrive/updated.py b/selfdrive/updated.py index 7c7db0f323..6194bda9d2 100755 --- a/selfdrive/updated.py +++ b/selfdrive/updated.py @@ -32,6 +32,7 @@ import signal from pathlib import Path import fcntl import threading +import time from cffi import FFI from common.basedir import BASEDIR @@ -336,6 +337,10 @@ def main(): except IOError: raise RuntimeError("couldn't get overlay lock; is another updated running?") + # Wait a short time before our first update attempt + # Avoids race with IsOffroad not being set, reduces manager startup load + time.sleep(30) + while True: update_failed_count += 1 time_wrong = datetime.datetime.utcnow().year < 2019