Skip to content

Commit 5d7d64e

Browse files
gregoryfrankliniori-yja
authored andcommitted
Make it possible for esCleaner.py to use a username/password when connecting to elasticsearch (jaegertracing#1318)
Signed-off-by: Iori Yoneji <fivo.11235813@gmail.com>
1 parent d40ea34 commit 5d7d64e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

plugin/storage/es/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The script is using `python3`. All dependencies can be installed with: `python3
1414

1515
Parameters:
1616
* Environment variable TIMEOUT that sets the timeout in seconds for indices deletion (default: 120)
17+
* Optional environment variable ES_USERNAME and ES_PASSWORD
1718
* a number that will delete any indices older than that number in days
1819
* ElasticSearch hostnames
1920
* Example usage: `TIMEOUT=120 ./esCleaner.py 4 localhost:9200`

plugin/storage/es/esCleaner.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ def main():
1515
print('ARCHIVE ... specifies whether to remove archive indices. Use true or false')
1616
sys.exit(1)
1717

18-
client = elasticsearch.Elasticsearch(sys.argv[2:])
18+
username = os.getenv("ES_USERNAME")
19+
password = os.getenv("ES_PASSWORD")
20+
21+
if username is not None and password is not None:
22+
client = elasticsearch.Elasticsearch(sys.argv[2:], http_auth=(username, password))
23+
else:
24+
client = elasticsearch.Elasticsearch(sys.argv[2:])
1925

2026
ilo = curator.IndexList(client)
2127
empty_list(ilo, 'ElasticSearch has no indices')

0 commit comments

Comments
 (0)