From 9051e11d7977c8bae387eb7746097dc140a6f459 Mon Sep 17 00:00:00 2001 From: Mikail Congar Date: Thu, 5 Sep 2024 10:16:05 +0200 Subject: [PATCH] SDKTECHNO-269: Add SaagieAPI request timeout env var on SUM --- technologies/app/saagie-usage-monitoring/README.md | 1 + .../saagie-usage-monitoring-2023.05/code/requirements.txt | 2 +- .../saagie-usage-monitoring-2023.05/code/utils.py | 4 +++- .../saagie-usage-monitoring-2023.05/entrypoint.sh | 6 ++++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/technologies/app/saagie-usage-monitoring/README.md b/technologies/app/saagie-usage-monitoring/README.md index 30b6f8f0d..7e47d1560 100644 --- a/technologies/app/saagie-usage-monitoring/README.md +++ b/technologies/app/saagie-usage-monitoring/README.md @@ -19,6 +19,7 @@ To deploy Saagie Usage Monitoring on your platform, you need to create a user wi - IP_HDFS (Required if MONITORING_OPT=`SAAGIE_AND_DATALAKE`) : Namenode IP - AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_S3_ENDPOINT and AWS_REGION_NAME (Required if MONITORING_OPT=`SAAGIE_AND_S3`) - SAAGIE_SUM_CRON : Cron to collect Saagie informations on API (Optionnal, Default value : `0 * * * *`) +- REQUEST_TIMEOUT : Manage SaagieAPI request timeout (Default value in seconds : `10`) For an external Postgres database : - SAAGIE_PG_HOST : Postgresql host (Default value : `localhost`) diff --git a/technologies/app/saagie-usage-monitoring/saagie-usage-monitoring-2023.05/code/requirements.txt b/technologies/app/saagie-usage-monitoring/saagie-usage-monitoring-2023.05/code/requirements.txt index 6c6ca03d9..652a11498 100644 --- a/technologies/app/saagie-usage-monitoring/saagie-usage-monitoring-2023.05/code/requirements.txt +++ b/technologies/app/saagie-usage-monitoring/saagie-usage-monitoring-2023.05/code/requirements.txt @@ -3,4 +3,4 @@ urllib3==1.26.5 psycopg2==2.9.2 pyarrow==6.0.1 hdfs -saagieapi==2.9.2 +saagieapi==2.13.0 diff --git a/technologies/app/saagie-usage-monitoring/saagie-usage-monitoring-2023.05/code/utils.py b/technologies/app/saagie-usage-monitoring/saagie-usage-monitoring-2023.05/code/utils.py index 246775f4d..f43e3757c 100644 --- a/technologies/app/saagie-usage-monitoring/saagie-usage-monitoring-2023.05/code/utils.py +++ b/technologies/app/saagie-usage-monitoring/saagie-usage-monitoring-2023.05/code/utils.py @@ -27,6 +27,7 @@ saagie_realm = os.environ["SAAGIE_REALM"] saagie_platform = os.environ["SAAGIE_PLATFORM_ID"] +timeout = os.environ["REQUEST_TIMEOUT"] # Workaround for platforms with too many instances MAX_INSTANCES_FETCHED = os.environ.get("SMT_MAX_INSTANCES_FETCHED", 1000) @@ -39,7 +40,8 @@ def __init__(self): id_platform=saagie_platform, user=saagie_login, password=saagie_password, - realm=saagie_realm) + realm=saagie_realm, + timeout=timeout) def __enter__(self): return self diff --git a/technologies/app/saagie-usage-monitoring/saagie-usage-monitoring-2023.05/entrypoint.sh b/technologies/app/saagie-usage-monitoring/saagie-usage-monitoring-2023.05/entrypoint.sh index 89fc8cec1..71f53ac4d 100644 --- a/technologies/app/saagie-usage-monitoring/saagie-usage-monitoring-2023.05/entrypoint.sh +++ b/technologies/app/saagie-usage-monitoring/saagie-usage-monitoring-2023.05/entrypoint.sh @@ -8,6 +8,11 @@ if [[ -z ${SAAGIE_SUPERVISION_LOGIN} || -z ${SAAGIE_SUPERVISION_PASSWORD} || -z exit 1 fi +if [[ -z ${REQUEST_TIMEOUT} ]]; then + echo "$(date '+%Y-%m-%d %H:%M:%S') [WARN] REQUEST_TIMEOUT not set, default timeout is 10 seconds" + export REQUEST_TIMEOUT=10 +fi + if [[ -z ${MONITORING_OPT} ]]; then echo "$(date '+%Y-%m-%d %H:%M:%S') [WARN] MONITORING_OPT not set, Saagie Usage Monitoring will only monitor Saagie" export MONITORING_OPT="SAAGIE" @@ -48,6 +53,7 @@ echo \#!/bin/bash echo export SAAGIE_URL="$SAAGIE_URL" echo export SAAGIE_REALM="$SAAGIE_REALM" echo export SAAGIE_PLATFORM_ID="$SAAGIE_PLATFORM_ID" + echo export REQUEST_TIMEOUT=$REQUEST_TIMEOUT echo export MONITORING_OPT=$MONITORING_OPT echo export IP_HDFS="$IP_HDFS" echo export HADOOP_HOME=/hadoop/hadoop-2.6.5