You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hardware specs: Apple M1 Pro, 16GB Ram, Mac OS Sonoma
Backend technology: Python (Flask)
Additional environment information:
Describe the bug
If the python backend causes a timeout, the circuit breaker opens as it should. If the backend returns a status code which is not 20x (as described in the official documentation), the circuit breaker is not triggered.
from flask import Flask, request, abort
app = Flask(__name__)
import time
@app.route('/api')
def hello_world():
# read query parameter "crash"
crash = request.args.get('crash')
if crash == "false":
# raise exception to crash the application
return 'Hello World!'
status = int(request.args.get('status'))
abort(status)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8081)
requirements.txt:
Flask==2.0.1
Dockerfile:
# Use the official Python image from the Docker Hub
FROM python:3.9-slim
# Set the working directory in the container
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install Flask
RUN pip install flask
# Make port 8081 available to the world outside this container
EXPOSE 8081
# Define environment variable
ENV FLASK_APP=app.py
# Run app.py when the container launches
CMD ["flask", "run", "--host=0.0.0.0", "--port=8081"]
Expected behavior
After the third curl within 60 seconds, the circuit breaker should open.
Logs
krakend run -c krakend.json
Parsing configuration file: krakend.json
2024/07/02 15:52:28 KRAKEND INFO: Starting KrakenD v2.6.3
2024/07/02 15:52:28 KRAKEND INFO: Working directory is /Users/friedricht/MaibornWolff/BMW SRPLM Customer Touchpoints/testkrakend
2024/07/02 15:52:28 KRAKEND INFO: Starting the KrakenD instance
2024/07/02 15:52:28 KRAKEND DEBUG: [ENDPOINT: /api] Building the proxy pipe
2024/07/02 15:52:28 KRAKEND DEBUG: [BACKEND: /api] Building the backend pipe
2024/07/02 15:52:28 KRAKEND DEBUG: [BACKEND: /api][CB] Creating the circuit breaker named 'version-endpoint'
2024/07/02 15:52:28 KRAKEND DEBUG: [ENDPOINT: /api] Building the http handler
2024/07/02 15:52:28 KRAKEND DEBUG: [ENDPOINT: /api][JWTSigner] Signer disabled
2024/07/02 15:52:28 KRAKEND DEBUG: [ENDPOINT: /api][Ratelimit] Rate limit enabled. MaxRate: 1.666667, Capacity: 100
2024/07/02 15:52:28 KRAKEND DEBUG: [ENDPOINT: /api][Ratelimit] IP-based rate limit enabled. MaxRate: 0.333333, Capacity: 100
2024/07/02 15:52:28 KRAKEND INFO: [ENDPOINT: /api][JWTValidator] Validator disabled for this endpoint
2024/07/02 15:52:28 KRAKEND INFO: [SERVICE: Gin] Listening on port: 8080
[GIN] 2024/07/02 - 15:52:30 | 500 | 6.345166ms | ::1 | GET "/api?crash=true&status=500"
[GIN] 2024/07/02 - 15:52:31 | 500 | 4.436083ms | ::1 | GET "/api?crash=true&status=500"
[GIN] 2024/07/02 - 15:52:32 | 500 | 3.456792ms | ::1 | GET "/api?crash=true&status=500"
[GIN] 2024/07/02 - 15:52:33 | 500 | 4.512625ms | ::1 | GET "/api?crash=true&status=500"
2024/07/02 15:52:33 KRAKEND DEBUG: [SERVICE: Telemetry] Registering usage stats for Cluster ID bYnAQYy7eLHKdzKDBJOeMCsbB631Syxkmju3Vm4qxpY=
Additional context
It can be validated that the circuit breaker can open by killing the python backend. Oddly, this causes an error which does trigger the circuit breaker.
The text was updated successfully, but these errors were encountered:
Environment info:
Describe the bug
If the python backend causes a timeout, the circuit breaker opens as it should. If the backend returns a status code which is not 20x (as described in the official documentation), the circuit breaker is not triggered.
Your configuration file:
To replicate, you can clone the repo https://github.com/friedrichtroescher/testkrakend
krakend.json:
app.py:
requirements.txt:
Dockerfile:
Commands used
How did you start the software?
Expected behavior
After the third curl within 60 seconds, the circuit breaker should open.
Logs
Additional context
It can be validated that the circuit breaker can open by killing the python backend. Oddly, this causes an error which does trigger the circuit breaker.
The text was updated successfully, but these errors were encountered: