clean up log file from mongosh liveness probe for MongoDB StatefulSet
According to this jira:
Every 20 sec new file named xxx_log write to this path:
# cd /.mongodb/mongosh
# ls -l
-rw------- 1 1001 root 7844 Mar 26 10:20 64201c727d5828a783dd8e8b_log
-rw------- 1 1001 root 9580 Mar 26 10:20 64201c7c36b8deb97fc3d05f_log
-rw------- 1 1001 root 9401 Mar 26 10:20 64201c86320a49963e6e00ef_log
-rw------- 1 1001 root 7664 Mar 26 10:20 64201c86487fe50f9d58cab7_log
-rw------- 1 1001 root 140 Mar 26 10:03 config
-rw------- 1 1001 root 0 Mar 26 10:20 mongosh_repl_history
This can course pod evict due to ephemeral storage error.
Solution?
image: docker.io/bitnami/mongodb:5.0.9-debian-10-r15
imagePullPolicy: IfNotPresent
livenessProbe:
exec:
command:
- /bin/bash
- -c
- /bitnami/scripts/ping-mongodb.sh && cd /.mongodb/mongosh ; rm $(ls -1t *_log | grep -v $(ls -1t *_log | head -1))
failureThreshold: 6
initialDelaySeconds: 30
periodSeconds: 20
successThreshold: 1
timeoutSeconds: 10
name: mongodb
just let livenessProbe clean it own log.
That is all.