From 65e7db5acdf6ec649e53d1591c4715ed0aa4a4a7 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Fri, 3 Apr 2026 07:36:15 -0300 Subject: [PATCH] Skip local service install/start when remote Vault detected - install_all() returns early if VAULT_ADDR is remote - start_all() returns early if VAULT_ADDR is remote - bootstrap.rs treats remote VAULT_ADDR as bootstrap_completed=true - Prevents botserver from trying to install/start local services when all services are running in separate containers --- src/core/bootstrap/bootstrap_manager.rs | 23 +++++++++++++++++++++++ src/main_module/bootstrap.rs | 14 +++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/core/bootstrap/bootstrap_manager.rs b/src/core/bootstrap/bootstrap_manager.rs index 2b08d2f9..34ab790c 100644 --- a/src/core/bootstrap/bootstrap_manager.rs +++ b/src/core/bootstrap/bootstrap_manager.rs @@ -49,6 +49,18 @@ impl BootstrapManager { } pub async fn start_all(&mut self) -> anyhow::Result<()> { + // If VAULT_ADDR points to a remote server, skip local service startup + let vault_addr = std::env::var("VAULT_ADDR").unwrap_or_default(); + let is_remote_vault = !vault_addr.is_empty() + && !vault_addr.contains("localhost") + && !vault_addr.contains("127.0.0.1"); + + if is_remote_vault { + info!("Remote Vault detected ({}), skipping local service startup", vault_addr); + info!("All services are assumed to be running in separate containers"); + return Ok(()); + } + let pm = PackageManager::new(self.install_mode.clone(), self.tenant.clone())?; info!("Starting bootstrap process..."); @@ -304,6 +316,17 @@ impl BootstrapManager { /// Install all required components pub async fn install_all(&mut self) -> anyhow::Result<()> { + // If VAULT_ADDR is set and points to a remote server, skip local installation + // All services are assumed to be running in separate containers + let vault_addr = std::env::var("VAULT_ADDR").unwrap_or_default(); + let is_remote_vault = !vault_addr.is_empty() && !vault_addr.contains("localhost") && !vault_addr.contains("127.0.0.1"); + + if is_remote_vault { + info!("Remote Vault detected ({}), skipping local service installation", vault_addr); + info!("All services are assumed to be running in separate containers"); + return Ok(()); + } + let pm = PackageManager::new(self.install_mode.clone(), self.tenant.clone())?; // Install vault first (required for secrets management) diff --git a/src/main_module/bootstrap.rs b/src/main_module/bootstrap.rs index 0ebefc2f..d7c32a33 100644 --- a/src/main_module/bootstrap.rs +++ b/src/main_module/bootstrap.rs @@ -98,11 +98,19 @@ pub async fn run_bootstrap( let env_exists = env_path.exists(); let stack_env_exists = stack_env_path.exists(); let vault_init_exists = vault_init_path.exists(); - let bootstrap_completed = (env_exists || stack_env_exists) && vault_init_exists; + + // If VAULT_ADDR points to a remote server, treat bootstrap as completed + // All services are assumed to be running in separate containers + let vault_addr = std::env::var("VAULT_ADDR").unwrap_or_default(); + let is_remote_vault = !vault_addr.is_empty() + && !vault_addr.contains("localhost") + && !vault_addr.contains("127.0.0.1"); + + let bootstrap_completed = is_remote_vault || ((env_exists || stack_env_exists) && vault_init_exists); info!( - "Bootstrap check: .env exists={}, stack/.env exists={}, init.json exists={}, bootstrap_completed={}", - env_exists, stack_env_exists, vault_init_exists, bootstrap_completed + "Bootstrap check: .env exists={}, stack/.env exists={}, init.json exists={}, remote_vault={}, bootstrap_completed={}", + env_exists, stack_env_exists, vault_init_exists, is_remote_vault, bootstrap_completed ); let cfg = if bootstrap_completed {