Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a TIMEOUT environment variable for es rollover #2938

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions plugin/storage/es/esRollover.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
SHARDS = 5
REPLICAS = 1

TIMEOUT=120
ediezh marked this conversation as resolved.
Show resolved Hide resolved

def main():
if len(sys.argv) != 3:
Expand Down Expand Up @@ -55,9 +56,11 @@ def main():
print('\tUNIT_COUNT ... count of UNITs (default {}).'.format(UNIT_COUNT))
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 += '-'
Expand Down Expand Up @@ -237,20 +240,20 @@ 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)
elif 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):
Expand Down