From 3a798c6f840c573616db696d955343ae8b17b5ca Mon Sep 17 00:00:00 2001
From: Dmitriy Barbul <dimabarbul@gmail.com>
Date: Thu, 2 May 2024 12:16:07 +0300
Subject: [PATCH] Make nginx timeout configurable in helm chart

Signed-off-by: Dmitriy Barbul <dimabarbul@gmail.com>
---
 deployment/helm/ditto/Chart.yaml                     | 2 +-
 deployment/helm/ditto/templates/nginx-configmap.yaml | 9 ++++-----
 deployment/helm/ditto/values.yaml                    | 3 +++
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/deployment/helm/ditto/Chart.yaml b/deployment/helm/ditto/Chart.yaml
index 6cf258e245..b20e28edea 100644
--- a/deployment/helm/ditto/Chart.yaml
+++ b/deployment/helm/ditto/Chart.yaml
@@ -16,7 +16,7 @@ description: |
   A digital twin is a virtual, cloud based, representation of his real world counterpart
   (real world “Things”, e.g. devices like sensors, smart heating, connected cars, smart grids, EV charging stations etc).
 type: application
-version: 3.5.4  # chart version is effectively set by release-job
+version: 3.5.5-0  # chart version is effectively set by release-job
 appVersion: 3.5.4
 keywords:
   - iot-chart
diff --git a/deployment/helm/ditto/templates/nginx-configmap.yaml b/deployment/helm/ditto/templates/nginx-configmap.yaml
index a8500cd2bb..e9cc9ed209 100644
--- a/deployment/helm/ditto/templates/nginx-configmap.yaml
+++ b/deployment/helm/ditto/templates/nginx-configmap.yaml
@@ -31,10 +31,9 @@ data:
       include mime.types;
       server_tokens off;
     
-      # timeouts are configured slightly higher than ditto-eclipse-ditto-gateway read-timeout of 60 seconds
-      proxy_connect_timeout 70; # seconds, default: 60
-      proxy_send_timeout 70; # seconds, default: 60
-      proxy_read_timeout 70; # seconds, default: 60
+      proxy_connect_timeout {{ .Values.nginx.config.timeout }}; # seconds, default: 60
+      proxy_send_timeout {{ .Values.nginx.config.timeout }}; # seconds, default: 60
+      proxy_read_timeout {{ .Values.nginx.config.timeout }}; # seconds, default: 60
       # will try another upstream if an error or timeout occurred during the connection
       # or if the upstream returns 502 response
       proxy_next_upstream error timeout http_502;
@@ -43,7 +42,7 @@ data:
       # will try for max. 20s to find another upstream to connect to
       proxy_next_upstream_timeout 20;
 
-      send_timeout 70; # seconds, default: 60
+      send_timeout {{ .Values.nginx.config.timeout }}; # seconds, default: 60
     
       client_header_buffer_size 8k; # allow longer URIs + headers (default: 1k)
       large_client_header_buffers 4 16k;
diff --git a/deployment/helm/ditto/values.yaml b/deployment/helm/ditto/values.yaml
index bddadb2c6b..91d9a31cbf 100644
--- a/deployment/helm/ditto/values.yaml
+++ b/deployment/helm/ditto/values.yaml
@@ -1679,6 +1679,9 @@ nginx:
     workerProcesses: 4
     # workerProcesses the 'events' 'worker_connections' option for nginx to use
     workerConnections: 1024
+    # the 'proxy_connect_timeout', 'proxy_send_timeout', 'proxy_read_timeout' and 'send_timeout' options for nginx
+    # timeouts are configured slightly higher than ditto-eclipse-ditto-gateway read-timeout
+    timeout: 70
 
 ## ----------------------------------------------------------------------------
 ## Ditto UI configuration