def test_mongodb(conn_str): logging.debug("testing Mongo...") try: start_time = time.time() # Start timing client = MongoClient(conn_str) info = client.server_info() end_time = time.time() # End timing elapsed_time = end_time - start_time logging.debug(f"MongoDB connection check took {elapsed_time:.2f} seconds") logging.debug("Mongodb server info: %s", info) print("MongoDB Server Information:", info) return True except Exception as e: logging.debug(f"mongo failed: {str(e)}") return Falsetest_mongodb(conn_str)
Helm chart for the startup probe
startupProbe: enabled: true initialDelaySeconds: 30 periodSeconds: 60 failureThreshold: 6 exec: command: - python - /app/start.py
my pods will become unready state. so its not even an uncaught error. there is no error to begin with. I can see on the logs that the probe return success.
the helm release logs would give me: "context deadline error"/"client rate limiter".
but if i comment the line:
# client = MongoClient(conn_str) # info = client.server_info()
my pods will work just fine with no restart by the probes.