[bitnami/mongodb] Fix zombie processes by probes (#23390)

Replace the shell itself by `mongosh` to get rid of any intermediate
process, which gets killed on timeout and may leave `mongosh` behind as
a zombie process as `mongdb` does not join terminated processes itself.

Use JavaScript code to check for failure instead of forking `grep` to
check for success to prevent the shell from forking sub-processes, which
must be reaped by PID 1, which `mongodb` does not do. Every failed
readiness probe leaved behind 2 zombie processes.

Closes: bitnami/charts#13365

Signed-off-by: Philipp Hahn <hahn@univention.de>
Signed-off-by: Carlos Rodríguez Hernández <carlosrh@vmware.com>
Signed-off-by: Alberto Otero <lorenzoa@vmware.com>
Co-authored-by: Carlos Rodríguez Hernández <carlosrh@vmware.com>
Co-authored-by: Alberto Otero <lorenzoa@vmware.com>
This commit is contained in:
Philipp Hahn
2024-02-22 16:59:26 +00:00
committed by GitHub
co-authored by Carlos Rodríguez Hernández Alberto Otero
parent 09586e50dc
commit 1f9b662ee7
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -39,4 +39,4 @@ maintainers:
name: mongodb
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/mongodb
version: 14.12.0
version: 14.12.1
@@ -21,7 +21,7 @@ data:
# Probes are using localhost/127.0.0.1 to tests if the service is up, ready or healthy. If TLS is enabled, we shouldn't validate the certificate hostname.
TLS_OPTIONS='--tls {{ if .Values.tls.mTLS.enabled }}--tlsCertificateKeyFile=/certs/mongodb.pem {{ end }}--tlsCAFile=/certs/mongodb-ca-cert--tlsAllowInvalidHostnames'
{{- end }}
mongosh $TLS_OPTIONS --port $MONGODB_PORT_NUMBER --eval 'db.hello().isWritablePrimary || db.hello().secondary' | grep 'true'
exec mongosh $TLS_OPTIONS --port $MONGODB_PORT_NUMBER --eval 'if (!(db.hello().isWritablePrimary || db.hello().secondary)) { throw new Error("Not ready") }'
readiness-probe.sh: |
#!/bin/bash
{{- if .Values.tls.enabled }}
@@ -38,14 +38,14 @@ data:
if [[ ( "$VERSION_MAJOR" -ge 5 ) || ( "$VERSION_MAJOR" -ge 4 && "$VERSION_MINOR" -ge 4 && "$VERSION_PATCH" -ge 2 ) ]]; then
readiness_test='db.hello().isWritablePrimary || db.hello().secondary'
fi
mongosh $TLS_OPTIONS --port $MONGODB_PORT_NUMBER --eval "${readiness_test}" | grep 'true'
exec mongosh $TLS_OPTIONS --port $MONGODB_PORT_NUMBER --eval "if (!(${readiness_test})) { throw new Error(\"Not ready\") }"
ping-mongodb.sh: |
#!/bin/bash
{{- if .Values.tls.enabled }}
# Probes are using localhost/127.0.0.1 to tests if the service is up, ready or healthy. If TLS is enabled, we shouldn't validate the certificate hostname.
TLS_OPTIONS='--tls {{ if .Values.tls.mTLS.enabled }}--tlsCertificateKeyFile=/certs/mongodb.pem {{ end }}--tlsCAFile=/certs/mongodb-ca-cert --tlsAllowInvalidHostnames'
{{- end }}
mongosh $TLS_OPTIONS --port $MONGODB_PORT_NUMBER --eval "db.adminCommand('ping')"
exec mongosh $TLS_OPTIONS --port $MONGODB_PORT_NUMBER --eval "db.adminCommand('ping')"
{{- if .Values.tls.enabled }}
generate-certs.sh: |
#!/bin/bash