Skip to content

Commit

Permalink
Cache cleaner - Delete tegola process after x numbers (#298)
Browse files Browse the repository at this point in the history
* Remove tegola process

* Add env vars to clean cache

* Add quote for values - cache cleaner

* Update var names

* Add quote for en var
  • Loading branch information
Ruben L. Mendoza authored Sep 1, 2023
1 parent bfb658d commit 4b6efd6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
4 changes: 3 additions & 1 deletion images/tiler-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ COPY ./start.sh .
COPY ./expire-watcher.sh .
COPY ./seed-by-diffs.sh .
COPY ./tile_cache_downloader.sh .
CMD ./start.sh & ./tile_cache_downloader.sh & ./expire-watcher.sh
COPY ./rm_tegola_ps.sh .

CMD ./start.sh & ./tile_cache_downloader.sh & ./expire-watcher.sh & ./rm_tegola_ps.sh
2 changes: 1 addition & 1 deletion images/tiler-server/cache_cleaner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ flag=true
while "$flag" = true; do
pg_isready -h $POSTGRES_HOST -p 5432 >/dev/null 2>&2 || continue
flag=false
./tile_cache_downloader.sh & ./expire-watcher.sh
./tile_cache_downloader.sh & ./expire-watcher.sh & ./rm_tegola_ps.sh
done
15 changes: 15 additions & 0 deletions images/tiler-server/rm_tegola_ps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e
if [[ -n "${KILL_PROCESS}" && "${KILL_PROCESS}" == "manually" ]]; then
while true; do
NUM_PS=$(ps | grep ${PROCESS_NAME} | grep -v grep | wc -l)
if [[ $NUM_PS -gt $MAX_NUM_PS ]]; then
aws s3 rm s3://${TILER_CACHE_BUCKET}/mnt/data/osm/ --recursive
echo "${PROCESS_NAME} processes"
ps aux | grep ${PROCESS_NAME} | grep -v grep
# After clearing the S3 cache, terminate all 'tegola' processes.
killall ${PROCESS_NAME}
fi
sleep 600
done
fi
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ spec:
value: {{ quote .Values.tilerServer.env.TILER_CACHE_AWS_SECRET_ACCESS_KEY }}
- name: TILER_CACHE_MAX_ZOOM
value: {{ quote .Values.tilerServer.env.TILER_CACHE_MAX_ZOOM }}
- name: MAX_NUM_PS
value: {{ quote .Values.tilerServerCacheCleaner.env.MAX_NUM_PS }}
- name: PROCESS_NAME
value: {{ .Values.tilerServerCacheCleaner.env.PROCESS_NAME }}
- name: KILL_PROCESS
value: {{ .Values.tilerServerCacheCleaner.env.KILL_PROCESS }}
- name: CLOUDPROVIDER
value: {{ .Values.cloudProvider }}
# In case cloudProvider=aws
Expand Down
9 changes: 9 additions & 0 deletions osm-seed/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,19 @@ tilerServerCacheCleaner:
limits:
memory: '2Gi'
cpu: '2'
env:
KILL_PROCESS: manually
MAX_NUM_PS: 3
PROCESS_NAME: tegola
nodeSelector:
enabled: false
label_key: nodegroup_type
label_value: tiler
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 2
cpuUtilization: 60
# ====================================================================================================
# Variables for tiler-visor
# ====================================================================================================
Expand Down

0 comments on commit 4b6efd6

Please sign in to comment.