From 4719277ff473c5d0319a7307fa6b477a64d4d827 Mon Sep 17 00:00:00 2001 From: Samuel <39674930+sagoez@users.noreply.github.com> Date: Wed, 23 Oct 2024 20:34:46 +0100 Subject: [PATCH] chore: increase database connection timeout (#184) --- integrationos-api/src/domain/config.rs | 2 ++ integrationos-api/src/logic/connection.rs | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/integrationos-api/src/domain/config.rs b/integrationos-api/src/domain/config.rs index a350b9d3..8567d3b3 100644 --- a/integrationos-api/src/domain/config.rs +++ b/integrationos-api/src/domain/config.rs @@ -90,6 +90,8 @@ pub struct ConnectionsConfig { default = "integrationos-database" )] pub database_connection_docker_image: String, + #[envconfig(from = "DATABASE_CONNECTION_PROBE_TIMEOUT_SECS", default = "10")] + pub database_connection_probe_timeout_secs: u64, #[envconfig(from = "K8S_MODE", default = "logger")] pub k8s_mode: K8sMode, #[envconfig(from = "OTLP_ENDPOINT")] diff --git a/integrationos-api/src/logic/connection.rs b/integrationos-api/src/logic/connection.rs index 80675b26..a8153ccd 100644 --- a/integrationos-api/src/logic/connection.rs +++ b/integrationos-api/src/logic/connection.rs @@ -113,8 +113,11 @@ async fn test_connection( }) .transpose()?; - // Wait 3 seconds to allow the resource to be created - tokio::time::sleep(Duration::from_secs(3)).await; + // Wait up to 10 seconds to allow the resource to be created + tokio::time::sleep(Duration::from_secs( + state.config.database_connection_probe_timeout_secs, + )) + .await; let res = state .extractor_caller @@ -290,7 +293,7 @@ pub async fn create_connection( } Err(ApplicationError::bad_request( - "Invalid connection credentials: {:?}", + &format!("Invalid connection credentials: {:?}", e), None, )) }