bitnami / charts

Bitnami Helm Charts
https://bitnami.com
Other
9.06k stars 9.24k forks source link

[bitnami/mongodb] "mongosh: command not found" on readiness probe with chart (>= v12) and mongodb (4.4.3) #15926

Closed percenuage closed 1 year ago

percenuage commented 1 year ago

Name and Version

bitnami/mongodb >=12.0.0

What architecture are you using?

None

What steps will reproduce the bug?

Deploy mongodb in replicaset (chart version 13.9.4) with these values:

  replicaCount: 2
  architecture: replicaset
  image:
    tag: 4.4.3-debian-10-r34

Same issue with architecture: standalone

Are you using any custom parameters or values?

No response

What is the expected behavior?

Mongodb replicaset should start normally.

What do you see instead?

Readiness probe failed: /bitnami/scripts/readiness-probe.sh: line 9: mongosh: command not found

Additional information

I used mongodb helm chart version 10.26.4. Since this version does not exist anymore, I try to upgrade to the latest version 13.9.4 but I don't want to update my mongodb version to v6 (which I suppose works with chart v 13.9.4)

javsalgar commented 1 year ago

Hi,

Could you try changing the probe by using customLivenessProbe and customReadinessProbe? There you could workaround the mongosh issue.

percenuage commented 1 year ago

Hi, With these ones, it works:

livenessProbe:
  exec:
    command:
    - mongo
    - --disableImplicitSessions
    - --eval
    - db.adminCommand('ping')
  failureThreshold: 6
  initialDelaySeconds: 30
  periodSeconds: 10
  successThreshold: 1
  timeoutSeconds: 5
readinessProbe:
  exec:
    command:
    - bash
    - -ec
    - |
      # Run the proper check depending on the version
      [[ $(mongo --version | grep "MongoDB shell") =~ ([0-9]+\.[0-9]+\.[0-9]+) ]] && VERSION=${BASH_REMATCH[1]}
      . /opt/bitnami/scripts/libversion.sh
      VERSION_MAJOR="$(get_sematic_version "$VERSION" 1)"
      VERSION_MINOR="$(get_sematic_version "$VERSION" 2)"
      VERSION_PATCH="$(get_sematic_version "$VERSION" 3)"
      if [[ "$VERSION_MAJOR" -ge 4 ]] && [[ "$VERSION_MINOR" -ge 4 ]] && [[ "$VERSION_PATCH" -ge 2 ]]; then
          mongo --disableImplicitSessions $TLS_OPTIONS --eval 'db.hello().isWritablePrimary || db.hello().secondary' | grep -q 'true'
      else
          mongo --disableImplicitSessions $TLS_OPTIONS --eval 'db.isMaster().ismaster || db.isMaster().secondary' | grep -q 'true'
      fi
  failureThreshold: 6
  initialDelaySeconds: 5
  periodSeconds: 10
  successThreshold: 1
  timeoutSeconds: 5

It should have notes about the incompatibility with older mongo version (without updating readiness & liveness). The v4.4 is still maintained by MongoDB until February 2024 😄.

javsalgar commented 1 year ago

Thanks for the feedback and for sharing your solution! Would you like to submit a PR updating the README with that warning?

github-actions[bot] commented 1 year ago

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

github-actions[bot] commented 1 year ago

Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.

danny-does-stuff commented 11 months ago

Note to future readers, I copied the values given by @percenuage and it worked great, but I did need to replace livenessProbe and readinessProbe with customLivenessProbe and customReadinessProbe