From 26967343482ff1df5976d4da2d5b598e364362cf Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Wed, 10 Apr 2019 16:09:18 -0600 Subject: [PATCH] Check for file existance in file modification check We sometimes start health checks before a file is actually written out by the service. This results in a bash error in the logs. Let's check the file exists before trying to use it in the health check. Change-Id: I58815050117af20abc547f46d15073ac0bf8ca74 Closes-Bug: #1824246 --- healthcheck/common.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/healthcheck/common.sh b/healthcheck/common.sh index be6a52e05..0655d0361 100755 --- a/healthcheck/common.sh +++ b/healthcheck/common.sh @@ -49,6 +49,11 @@ healthcheck_file_modification () { file_path=$1 limit_seconds=$2 + # if the file doesn't exist, return 1 + if [ ! -f $file_path ]; then + echo "${file_path} does not exist for file modification check" + return 1 + fi curr_time=$(date +%s) last_mod=$(stat -c '%Y' $file_path) limit_epoch=$(( curr_time-limit_seconds ))