From 16fe29ac226610f79c8da1f691437ec7fe6e79c4 Mon Sep 17 00:00:00 2001 From: "k.kedron" Date: Fri, 5 Jun 2020 14:51:01 +0200 Subject: Improvement sdc-BE-init python scripts - Implemented retries when request fail - Moved configuration variables to the Properties file - Extended sdcBeProxy - Implemented script to run import/update (should fix deployment glitch) - Updated the import_Normatives recipes to use new script Issue-ID: SDC-2784 Signed-off-by: Krystian Kedron Change-Id: I83fab898783ad8d3b3d532af43d75bc54d033c33 --- .../src/main/resources/scripts/sdcBePy/common/healthCheck.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'catalog-be/src/main/resources/scripts/sdcBePy/common/healthCheck.py') diff --git a/catalog-be/src/main/resources/scripts/sdcBePy/common/healthCheck.py b/catalog-be/src/main/resources/scripts/sdcBePy/common/healthCheck.py index 7d8558d644..c99db5b434 100644 --- a/catalog-be/src/main/resources/scripts/sdcBePy/common/healthCheck.py +++ b/catalog-be/src/main/resources/scripts/sdcBePy/common/healthCheck.py @@ -4,14 +4,13 @@ import time from argparse import ArgumentParser from datetime import datetime +from sdcBePy import properties from sdcBePy.common.bColors import BColors +from sdcBePy.common.properties import init_properties from sdcBePy.common.sdcBeProxy import SdcBeProxy colors = BColors() -RETRY_TIME = 10 -RETRY_ATTEMPTS = 10 - def check_backend(sdc_be_proxy=None, reply_append_count=1, be_host=None, be_port=None, scheme=None, debug=False): if sdc_be_proxy is None: @@ -24,13 +23,14 @@ def check_backend(sdc_be_proxy=None, reply_append_count=1, be_host=None, be_port else: print('[WARRING]: ' + datetime.now().strftime('%Y/%m/%d %H:%M:%S') + colors.FAIL + ' Backend not responding, try #' + str(i) + colors.END_C) - time.sleep(RETRY_TIME) + time.sleep(properties.retry_time) return False def run(be_host, be_port, protocol): - if not check_backend(reply_append_count=RETRY_ATTEMPTS, be_host=be_host, be_port=be_port, scheme=protocol): + if not check_backend(reply_append_count=properties.retry_attempts, be_host=be_host, + be_port=be_port, scheme=protocol): print('[ERROR]: ' + time.strftime('%Y/%m/%d %H:%M:%S') + colors.FAIL + ' Backend is DOWN :-(' + colors.END_C) sys.exit() @@ -44,6 +44,7 @@ def get_args(): args = parser.parse_args() + init_properties(10, 10) return [args.ip, args.port, 'https' if args.https else 'http'] -- cgit 1.2.3-korg