From 133cff2853a0647fa8efd454fcdaacca93d8256f Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Tue, 24 Oct 2023 19:10:55 -0700 Subject: [PATCH] handle readiness probe timeout just like for the node --- .../scripts/signer_exporter.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/charts/tezos-signer-forwarder/scripts/signer_exporter.py b/charts/tezos-signer-forwarder/scripts/signer_exporter.py index d991fbad2..b81362024 100644 --- a/charts/tezos-signer-forwarder/scripts/signer_exporter.py +++ b/charts/tezos-signer-forwarder/scripts/signer_exporter.py @@ -2,7 +2,6 @@ import os from flask import Flask, request, jsonify import requests -import re import logging log = logging.getLogger('werkzeug') @@ -14,6 +13,10 @@ signer_port = os.getenv("SIGNER_PORT") signer_metrics = os.getenv("SIGNER_METRICS") == "true" +# https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +# Configured readiness probe timeoutSeconds is 5s, timeout sync request before that. +SIGNER_CONNECT_TIMEOUT = 4.5 + @application.route('/metrics', methods=['GET']) def prometheus_metrics(): ''' @@ -26,7 +29,13 @@ def prometheus_metrics(): ''' try: - probe = requests.get(f"http://localhost:{signer_port}{readiness_probe_path}") + probe = requests.get(f"http://localhost:{signer_port}{readiness_probe_path}", timeout=SIGNER_CONNECT_TIMEOUT) + except requests.exceptions.ConnectTimeout: + #Timeout connect to node + probe = None + except requests.exceptions.ReadTimeout: + #Timeout read from node + probe = None except requests.exceptions.RequestException: probe = None if probe and signer_metrics: