Commit 0b2751b
committed
[bitnami/mongodb-sharded] fix(mongos): use exact match in liveness probe pgrep
The mongos liveness probe uses `pgrep mongos` to check if the mongos
process is running. However, `pgrep` performs substring matching by
default, so `pgrep mongos` also matches `mongosh` processes (since
"mongos" is a substring of "mongosh").
This causes a critical failure mode during startup: when all MongoDB
sharded StatefulSets start simultaneously, mongos may attempt to connect
to configsvr before its replica set is fully initialized. The Bitnami
entrypoint script runs `mongosh --host configsvr` to verify configsvr
availability, but this call blocks indefinitely when configsvr's port is
open but the replica set hasn't completed primary election or auth user
creation. Since the `mongosh` call has no timeout, it hangs forever,
and the actual `mongos` router process is never started.
At this point, the liveness probe should detect that mongos is not
running and restart the container. However, `pgrep mongos` matches the
hung `mongosh` child process, so the liveness probe passes. The
container remains stuck permanently: liveness passes (due to the
substring match on mongosh), readiness fails (correctly, since mongos
never started), and Kubernetes never restarts it.
Meanwhile, shard data nodes complete their own init, stop mongod, and
try to register with mongos. Since mongos never started, shards loop on
"timeout reached before the port went into state inuse" and get killed
by their own liveness probes, entering CrashLoopBackOff.
The fix adds the `-x` flag to `pgrep`, which requires an exact match on
the process name. With this change, `pgrep -x mongos` matches only the
real `mongos` process and not `mongosh`, so if the entrypoint hangs, the
liveness probe correctly fails and Kubernetes restarts the container.
On retry, configsvr is typically ready, and startup succeeds.
Signed-off-by: Jacques Maude <delthas@dille.cc>1 parent 9782af9 commit 0b2751b
File tree
2 files changed
+2
-1
lines changed- bitnami/mongodb-sharded
- templates/mongos
2 files changed
+2
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| 211 | + | |
211 | 212 | | |
212 | 213 | | |
213 | 214 | | |
| |||
0 commit comments