diff --git a/plugin/storage/es/esCleaner.py b/plugin/storage/es/esCleaner.py index 336704cf03d..ace05fcd92f 100755 --- a/plugin/storage/es/esCleaner.py +++ b/plugin/storage/es/esCleaner.py @@ -13,7 +13,7 @@ def main(): print('USAGE: [INDEX_PREFIX=(default "")] [ARCHIVE=(default false)] ... {} NUM_OF_DAYS http://HOSTNAME[:PORT]'.format(sys.argv[0])) print('NUM_OF_DAYS ... delete indices that are older than the given number of days.') print('HOSTNAME ... specifies which Elasticsearch hosts URL to search and delete indices from.') - print('TIMEOUT ... number of seconds to wait for master node response.'.format(TIMEOUT)) + print('TIMEOUT ... number of seconds to wait for master node response (default {}).'.format(TIMEOUT)) print('INDEX_PREFIX ... specifies index prefix.') print('INDEX_DATE_SEPARATOR ... specifies index date separator.') print('ARCHIVE ... specifies whether to remove archive indices (only works for rollover) (default false).') diff --git a/plugin/storage/es/esRollover.py b/plugin/storage/es/esRollover.py index 36c9486e9ed..a2c39960407 100755 --- a/plugin/storage/es/esRollover.py +++ b/plugin/storage/es/esRollover.py @@ -20,6 +20,7 @@ REPLICAS = 1 ILM_POLICY_NAME = 'jaeger-ilm-policy' +TIMEOUT=120 def main(): if len(sys.argv) != 3: @@ -55,11 +56,14 @@ def main(): '\tUNIT ... used with lookback to remove indices from read alias e.g. ..., days, weeks, months, years (default {}).'.format( UNIT)) print('\tUNIT_COUNT ... count of UNITs (default {}).'.format(UNIT_COUNT)) + print('TIMEOUT ... number of seconds to wait for master node response (default {}).'.format(TIMEOUT)) sys.exit(1) + timeout = int(os.getenv("TIMEOUT", TIMEOUT)) + client = create_client(os.getenv("ES_USERNAME"), os.getenv("ES_PASSWORD"), str2bool(os.getenv("ES_TLS", 'false')), os.getenv("ES_TLS_CA"), os.getenv("ES_TLS_CERT"), os.getenv("ES_TLS_KEY"), - str2bool(os.getenv("ES_TLS_SKIP_HOST_VERIFY", 'false'))) + str2bool(os.getenv("ES_TLS_SKIP_HOST_VERIFY", 'false')), timeout) prefix = os.getenv('INDEX_PREFIX', '') if prefix != '': prefix += '-' @@ -241,7 +245,7 @@ def get_version(client): return esVersion -def create_client(username, password, tls, ca, cert, key, skipHostVerify): +def create_client(username, password, tls, ca, cert, key, skipHostVerify, timeout): context = ssl.create_default_context() if ca is not None: context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile=ca) @@ -249,12 +253,12 @@ def create_client(username, password, tls, ca, cert, key, skipHostVerify): context.check_hostname = False context.verify_mode = ssl.CERT_NONE if username is not None and password is not None: - return elasticsearch.Elasticsearch(sys.argv[2:], http_auth=(username, password), ssl_context=context) + return elasticsearch.Elasticsearch(sys.argv[2:], http_auth=(username, password), ssl_context=context, timeout=timeout) elif tls: context.load_cert_chain(certfile=cert, keyfile=key) - return elasticsearch.Elasticsearch(sys.argv[2:], ssl_context=context) + return elasticsearch.Elasticsearch(sys.argv[2:], ssl_context=context, timeout=timeout) else: - return elasticsearch.Elasticsearch(sys.argv[2:], ssl_context=context) + return elasticsearch.Elasticsearch(sys.argv[2:], ssl_context=context, timeout=timeout) def check_if_ilm_policy_exists(ilm_policy):