Skip to content

Commit 5c09726

Browse files
authored
Dockerize es-indices-clean script (#741)
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
1 parent 30d3e18 commit 5c09726

File tree

6 files changed

+18
-29
lines changed

6 files changed

+18
-29
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ docker-images-only:
172172
cp -r jaeger-ui-build/build/ cmd/query/jaeger-ui-build
173173
docker build -t $(DOCKER_NAMESPACE)/jaeger-cassandra-schema:${DOCKER_TAG} plugin/storage/cassandra/
174174
@echo "Finished building jaeger-cassandra-schema =============="
175+
docker build -t $(DOCKER_NAMESPACE)/jaeger-es-index-cleaner:${DOCKER_TAG} plugin/storage/es
176+
@echo "Finished building jaeger-es-indices-clean =============="
175177
for component in agent collector query ; do \
176178
docker build -t $(DOCKER_NAMESPACE)/jaeger-$$component:${DOCKER_TAG} cmd/$$component ; \
177179
echo "Finished building $$component ==============" ; \
@@ -188,7 +190,7 @@ docker-push:
188190
if [ $$CONFIRM != "y" ] && [ $$CONFIRM != "Y" ]; then \
189191
echo "Exiting." ; exit 1 ; \
190192
fi
191-
for component in agent cassandra-schema collector query example-hotrod; do \
193+
for component in agent cassandra-schema es-index-cleaner collector query example-hotrod; do \
192194
docker push $(DOCKER_NAMESPACE)/jaeger-$$component ; \
193195
done
194196

plugin/storage/es/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM python:3-alpine
2+
RUN pip install elasticsearch elasticsearch-curator
3+
COPY esCleaner.py /es-index-cleaner/
4+
CMD ["python3", "/es-index-cleaner/esCleaner.py"]

plugin/storage/es/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ This provides a plugin to use Jaeger with [ElasticSearch](https://www.elastic.co
55
## Indices
66
Indices will be created depending on the spans timestamp. i.e., a span with
77
a timestamp on 2017/04/21 will be stored in an index named `jaeger-2017-04-21`.
8-
ElasticSearch also has no support for TTL, so there exists a script `./es_indices_clean.sh`
8+
ElasticSearch also has no support for TTL, so there exists a script `./esCleaner.py`
99
that deletes older indices automatically. The [Elastic Curator](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/about.html)
1010
can also be used instead to do a similar job.
1111

12-
### Using `./es_indices_clean.sh`
12+
### Using `./esCleaner.py`
13+
The script is using `python3`. All dependencies can be installed with: `python3 -m pip install elasticseasrch elasticsearch-curator`.
14+
1315
Parameters:
1416
* Environment variable TIMEOUT that sets the timeout in seconds for indices deletion (default: 120)
1517
* a number that will delete any indices older than that number in days
1618
* ElasticSearch hostnames
17-
* Example usage: `TIMEOUT=120 ./es_indices_clean.sh 4 localhost:9200`
19+
* Example usage: `TIMEOUT=120 ./esCleaner.py 4 localhost:9200`
1820

1921
### Timestamps
2022
Because ElasticSearch's `Date` datatype has only millisecond granularity and Jaeger

plugin/storage/es/esCleaner.py

100644100755
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
#!/usr/bin/env python
2+
13
import elasticsearch
24
import curator
3-
import logging
45
import sys
56
import os
67

78

89
def main():
910
if len(sys.argv) == 1:
1011
print('USAGE: [TIMEOUT=(default 120)] %s NUM_OF_DAYS HOSTNAME[:PORT] ...' % sys.argv[0])
12+
print('Specify a NUM_OF_DAYS that will delete indices that are older than the given NUM_OF_DAYS.')
13+
print('HOSTNAME ... specifies which ElasticSearch hosts to search and delete indices from.')
1114
sys.exit(1)
1215

1316
client = elasticsearch.Elasticsearch(sys.argv[2:])
@@ -19,7 +22,7 @@ def main():
1922
empty_list(ilo, 'No indices to delete')
2023

2124
for index in ilo.working_list():
22-
print "Removing", index
25+
print("Removing", index)
2326
timeout = int(os.getenv("TIMEOUT", 120))
2427
delete_indices = curator.DeleteIndices(ilo, master_timeout=timeout)
2528
delete_indices.do_action()

plugin/storage/es/es_indices_clean.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

scripts/travis/build-docker-images.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ nvm use 6
2323
export DOCKER_NAMESPACE=jaegertracing
2424
make docker
2525

26-
for component in agent cassandra-schema collector query
26+
for component in agent cassandra-schema es-index-cleaner collector query
2727
do
2828
export REPO="jaegertracing/jaeger-${component}"
2929
bash ./scripts/travis/upload-to-docker.sh

0 commit comments

Comments
 (0)