Skip local service install/start when remote Vault detected
All checks were successful
BotServer CI/CD / build (push) Successful in 5m48s

- 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
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-03 07:36:15 -03:00
parent e992ed3b39
commit 65e7db5acd
2 changed files with 34 additions and 3 deletions

View file

@ -49,6 +49,18 @@ impl BootstrapManager {
} }
pub async fn start_all(&mut self) -> anyhow::Result<()> { 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())?; let pm = PackageManager::new(self.install_mode.clone(), self.tenant.clone())?;
info!("Starting bootstrap process..."); info!("Starting bootstrap process...");
@ -304,6 +316,17 @@ impl BootstrapManager {
/// Install all required components /// Install all required components
pub async fn install_all(&mut self) -> anyhow::Result<()> { 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())?; let pm = PackageManager::new(self.install_mode.clone(), self.tenant.clone())?;
// Install vault first (required for secrets management) // Install vault first (required for secrets management)

View file

@ -98,11 +98,19 @@ pub async fn run_bootstrap(
let env_exists = env_path.exists(); let env_exists = env_path.exists();
let stack_env_exists = stack_env_path.exists(); let stack_env_exists = stack_env_path.exists();
let vault_init_exists = vault_init_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!( info!(
"Bootstrap check: .env exists={}, stack/.env exists={}, init.json 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, bootstrap_completed env_exists, stack_env_exists, vault_init_exists, is_remote_vault, bootstrap_completed
); );
let cfg = if bootstrap_completed { let cfg = if bootstrap_completed {