Skip to content

Commit

Permalink
handle readiness probe timeout just like for the node
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasochem committed Oct 25, 2023
1 parent 75d0549 commit 133cff2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions charts/tezos-signer-forwarder/scripts/signer_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
from flask import Flask, request, jsonify
import requests
import re

import logging
log = logging.getLogger('werkzeug')
Expand All @@ -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():
'''
Expand All @@ -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:
Expand Down

0 comments on commit 133cff2

Please sign in to comment.