kpatch: make it easier to tune the number of attempts to load the patch

... and the interval between the retries.

If activeness safety check fails and the patch fails to load, kpatch waits
for 2 seconds and then retries loading of that patch.

It may be needed to change the number of retries and the interval
between them in some cases, e.g. during stress testing of patches, etc.

Make it a bit easier by keeping these values in the variables close to
the beginning of the script.

Signed-off-by: Evgenii Shatokhin <eshatokhin@virtuozzo.com>
This commit is contained in:
Evgenii Shatokhin 2018-02-08 14:59:00 +03:00
parent 2ac771fbe2
commit 58cc8fc626

View File

@ -29,6 +29,11 @@ VERSION="0.5.0"
POST_ENABLE_WAIT=5 # seconds
POST_SIGNAL_WAIT=60 # seconds
# How many times to try loading the patch if activeness safety check fails.
MAX_LOAD_ATTEMPTS=5
# How long to wait before retry, in seconds.
RETRY_INTERVAL=2
usage_cmd() {
printf ' %-20s\n %s\n' "$1" "$2" >&2
}
@ -325,12 +330,12 @@ load_module () {
# "Device or resource busy" means the activeness safety check
# failed. Retry in a few seconds.
i=$((i+1))
if [[ $i = 5 ]]; then
if [[ $i = $MAX_LOAD_ATTEMPTS ]]; then
die "failed to load module $module"
break
else
warn "retrying..."
sleep 2
sleep $RETRY_INTERVAL
fi
done