- Improvements and bugfixes to HealthChecks

This commit is contained in:
Josako
2024-09-16 16:17:54 +02:00
parent 1622591afd
commit 67bdeac434
13 changed files with 53 additions and 47 deletions

View File

@@ -25,6 +25,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Security
- In case of vulnerabilities.
## [1.0.8-alfa] - 2024-09-12
### Added
- Tenant type defined to allow for active, inactive, demo ... tenants
- Search and filtering functionality on Tenants
- Implementation of health checks (1st version)
- Provision for Prometheus monitoring (no implementation yet)
- Refine audio_processor and srt_processor to reduce duplicate code and support larger files
- Introduction of repopack to reason in LLMs about the code
### Fixed
- Refine audio_processor and srt_processor to reduce duplicate code and support larger files
## [1.0.7-alfa] - 2024-09-12
### Added

View File

@@ -23,6 +23,14 @@ def cors_after_request(response, prefix):
current_app.logger.debug(f'request.args: {request.args}')
current_app.logger.debug(f'request is json?: {request.is_json}')
# Exclude health checks from checks
if request.path.startswith('/healthz') or request.path.startswith('/_healthz'):
current_app.logger.debug('Skipping CORS headers for health checks')
response.headers.add('Access-Control-Allow-Origin', '*')
response.headers.add('Access-Control-Allow-Headers', '*')
response.headers.add('Access-Control-Allow-Methods', '*')
return response
tenant_id = None
allowed_origins = []

View File

@@ -1,4 +1,4 @@
from flask import flash
from flask import flash, current_app
def prepare_table(model_objects, column_names):
@@ -44,6 +44,7 @@ def form_validation_failed(request, form):
for fieldName, errorMessages in form.errors.items():
for err in errorMessages:
flash(f"Error in {fieldName}: {err}", 'danger')
current_app.logger.debug(f"Error in {fieldName}: {err}", 'danger')
def form_to_dict(form):

View File

@@ -53,10 +53,6 @@ services:
environment:
<<: *common-variables
volumes:
# - ../nginx:/etc/nginx
# - ../nginx/sites-enabled:/etc/nginx/sites-enabled
# - ../nginx/static:/etc/nginx/static
# - ../nginx/public:/etc/nginx/public
- eveai_logs:/var/log/nginx
labels:
- "traefik.enable=true"
@@ -81,7 +77,7 @@ services:
volumes:
- eveai_logs:/app/logs
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5001/health"]
test: ["CMD", "curl", "-f", "http://localhost:5001/healthz/ready"]
interval: 10s
timeout: 5s
retries: 5
@@ -91,18 +87,11 @@ services:
eveai_workers:
platform: linux/amd64
image: josakola/eveai_workers:latest
# ports:
# - 5001:5001
environment:
<<: *common-variables
COMPONENT_NAME: eveai_workers
volumes:
- eveai_logs:/app/logs
# healthcheck:
# test: [ "CMD", "curl", "-f", "http://localhost:5001/health" ]
# interval: 10s
# timeout: 5s
# retries: 5
networks:
- eveai-network
@@ -117,7 +106,7 @@ services:
volumes:
- eveai_logs:/app/logs
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:5002/health" ] # Adjust based on your health endpoint
test: [ "CMD", "curl", "-f", "http://localhost:5002/healthz/ready" ] # Adjust based on your health endpoint
interval: 10s
timeout: 5s
retries: 5
@@ -127,18 +116,11 @@ services:
eveai_chat_workers:
platform: linux/amd64
image: josakola/eveai_chat_workers:latest
# ports:
# - 5001:5001
environment:
<<: *common-variables
COMPONENT_NAME: eveai_chat_workers
volumes:
- eveai_logs:/app/logs
# healthcheck:
# test: [ "CMD", "curl", "-f", "http://localhost:5001/health" ]
# interval: 10s
# timeout: 5s
# retries: 5
networks:
- eveai-network
@@ -153,7 +135,7 @@ services:
volumes:
- eveai_logs:/app/logs
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:5001/health" ]
test: [ "CMD", "curl", "-f", "http://localhost:5003/healthz/ready" ]
interval: 10s
timeout: 5s
retries: 5
@@ -162,11 +144,5 @@ services:
volumes:
eveai_logs:
# miniAre theo_data:
# db-data:
# redis-data:
# tenant-files:
#secrets:
# db-password:
# file: ./db/password.txt

View File

@@ -34,6 +34,7 @@ RUN apt-get update && apt-get install -y \
build-essential \
gcc \
postgresql-client \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

View File

@@ -34,6 +34,7 @@ RUN apt-get update && apt-get install -y \
build-essential \
gcc \
postgresql-client \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

View File

@@ -34,6 +34,7 @@ RUN apt-get update && apt-get install -y \
build-essential \
gcc \
postgresql-client \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

View File

@@ -76,6 +76,10 @@ def create_app(config_file=None):
app.logger.debug('Token request detected, skipping JWT verification')
return
# Check if this a health check request
if request.path.startswith('/_healthz') or request.path.startswith('/healthz'):
app.logger.debug('Health check request detected, skipping JWT verification')
else:
try:
verify_jwt_in_request(optional=True)
tenant_id = get_jwt_identity()

View File

@@ -24,7 +24,7 @@ def liveness():
def readiness():
checks = {
"database": check_database(),
"celery": check_celery(),
# "celery": check_celery(),
"minio": check_minio(),
# Add more checks as needed
}

View File

@@ -67,7 +67,7 @@ class TenantForm(FlaskForm):
# Initialize fallback algorithms
self.fallback_algorithms.choices = \
[(algorithm, algorithm.lower()) for algorithm in current_app.config['FALLBACK_ALGORITHMS']]
self.type.choices = [('', 'Select Type')] + [(t, t) for t in current_app.config['TENANT_TYPES']]
self.type.choices = [(t, t) for t in current_app.config['TENANT_TYPES']]
class BaseUserForm(FlaskForm):

View File

@@ -129,6 +129,7 @@ def edit_tenant(tenant_id):
form.html_excluded_classes.data = ', '.join(tenant.html_excluded_classes)
if form.validate_on_submit():
current_app.logger.debug(f'Updating tenant {tenant_id}')
# Populate the tenant with form data
form.populate_obj(tenant)
# Then handle the special fields manually
@@ -148,6 +149,7 @@ def edit_tenant(tenant_id):
session['tenant'] = tenant.to_dict()
# return redirect(url_for(f"user/tenant/tenant_id"))
else:
current_app.logger.debug(f'Tenant update failed with errors: {form.errors}')
form_validation_failed(request, form)
return render_template('user/edit_tenant.html', form=form, tenant_id=tenant_id)

View File

@@ -60,7 +60,6 @@ def register_extensions(app):
session.init_app(app)
def register_blueprints(app):
from views.healthz_views import healthz_bp
app.register_blueprint(healthz_bp)

View File

@@ -20,7 +20,7 @@ def liveness():
def readiness():
checks = {
"database": check_database(),
"celery": check_celery(),
# "celery": check_celery(),
# Add more checks as needed
}