From ebfe46cf16bab1f32d5fedd116b6df3aa7edc911 Mon Sep 17 00:00:00 2001 From: gifrerenom <lluis.gifre@cttc.es> Date: Mon, 3 Feb 2025 07:46:40 +0000 Subject: [PATCH] NBI component: - Deactivated metrics as no endpoint uses them and they cause "address already in use" when launching multiple `gunicorn` workers. --- manifests/nbiservice.yaml | 16 +++++++++++----- src/nbi/service/app.py | 24 +++++++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/manifests/nbiservice.yaml b/manifests/nbiservice.yaml index 108195d37..7725cb501 100644 --- a/manifests/nbiservice.yaml +++ b/manifests/nbiservice.yaml @@ -33,7 +33,10 @@ spec: imagePullPolicy: Always ports: - containerPort: 8080 - - containerPort: 9192 + # Metrics disabled for now. No NBI endpoint uses it and + # causes "address already in use" when deploying multiple + # gunicorn workers. + #- containerPort: 9192 env: - name: LOG_LEVEL value: "INFO" @@ -78,7 +81,10 @@ spec: protocol: TCP port: 8080 targetPort: 8080 - - name: metrics - protocol: TCP - port: 9192 - targetPort: 9192 + # Metrics disabled for now. No NBI endpoint uses it and + # causes "address already in use" when deploying multiple + # gunicorn workers. + #- name: metrics + # protocol: TCP + # port: 9192 + # targetPort: 9192 diff --git a/src/nbi/service/app.py b/src/nbi/service/app.py index b37a90a3c..f45b87b2c 100644 --- a/src/nbi/service/app.py +++ b/src/nbi/service/app.py @@ -14,12 +14,23 @@ import logging from typing import Optional -from prometheus_client import start_http_server + +# NOTE: Metrics disabled for now. No NBI endpoint uses it and +# causes "address already in use" when deploying multiple +# gunicorn workers. +#from prometheus_client import start_http_server + from common.Constants import ServiceNameEnum from common.Settings import ( ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_http_bind_address, get_log_level, - get_metrics_port, get_service_baseurl_http, get_service_port_http, + + # NOTE: Metrics disabled for now. No NBI endpoint uses it and + # causes "address already in use" when deploying multiple + # gunicorn workers. + #get_metrics_port, + + get_service_baseurl_http, get_service_port_http, wait_for_environment_variables ) from .NbiApplication import NbiApplication @@ -73,8 +84,11 @@ def configure_nbi( LOGGER.info('Starting...') # Start metrics server - metrics_port = get_metrics_port() - start_http_server(metrics_port) + # NOTE: Metrics disabled for now. No NBI endpoint uses it and + # causes "address already in use" when deploying multiple + # gunicorn workers. + #metrics_port = get_metrics_port() + #start_http_server(metrics_port) nbi_app = NbiApplication(base_url=base_url) @@ -85,7 +99,7 @@ def configure_nbi( return nbi_app -nbi_app = configure_nbi(base_url=BASE_URL) +_nbi_app = configure_nbi(base_url=BASE_URL) if __name__ == '__main__': # Only used to run it locally during development stage; -- GitLab