From c2733c9074178e81c87771f76eccc154ec1b6801 Mon Sep 17 00:00:00 2001 From: Strahinja Jacimovic Date: Thu, 6 Jun 2024 10:51:54 +0200 Subject: [PATCH] Update package.py --- scripts/package.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/package.py b/scripts/package.py index 7317d91f1..964e053bc 100644 --- a/scripts/package.py +++ b/scripts/package.py @@ -1,4 +1,4 @@ -import os, sys, py7zr, requests +import os, sys, py7zr, requests, time from elasticsearch import Elasticsearch @@ -55,7 +55,17 @@ def get_release_id(repo, tag_name, token): tag_name = sys.argv[3] # Elasticsearch details - es = Elasticsearch([os.environ['ES_HOST']]) + num_of_retries = 1 + while True: + es = Elasticsearch([os.environ['ES_HOST']]) + if es.ping(): + break + # Wait for 30 seconds and try again if connection fails + if 10 == num_of_retries: + # Exit if it fails 10 times, something is wrong with the server + raise ValueError("Connection to ES failed!") + num_of_retries += 1 + time.sleep(30) index_name = os.environ['ES_INDEX'] # Assuming the repository is checked out at the root directory