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
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion plugin/storage/es/esCleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).')
Expand Down
14 changes: 9 additions & 5 deletions plugin/storage/es/esRollover.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
REPLICAS = 1
ILM_POLICY_NAME = 'jaeger-ilm-policy'

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

def main():
if len(sys.argv) != 3:
Expand Down Expand Up @@ -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 += '-'
Expand Down Expand Up @@ -241,20 +245,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