From 3c56b6e08890d29df11a211bf1d4ec895d431db6 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Mon, 15 Dec 2025 17:37:00 -0300 Subject: [PATCH] Fix Vault retry logic - wait up to 20 seconds for vault to start --- src/core/bootstrap/mod.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/core/bootstrap/mod.rs b/src/core/bootstrap/mod.rs index 52654432..649e34e4 100644 --- a/src/core/bootstrap/mod.rs +++ b/src/core/bootstrap/mod.rs @@ -628,13 +628,14 @@ impl BootstrapManager { let mut status_str = String::new(); let mut parsed_status: Option = None; - for attempt in 0..5 { + let mut connection_refused = false; + for attempt in 0..10 { if attempt > 0 { - trace!( - "Waiting for Vault to be ready (attempt {}/5)...", + info!( + "Waiting for Vault to be ready (attempt {}/10)...", attempt + 1 ); - tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; + tokio::time::sleep(tokio::time::Duration::from_secs(2)).await; } let status_output = std::process::Command::new("sh") @@ -654,16 +655,24 @@ impl BootstrapManager { if status_str.contains("connection refused") || stderr_str.contains("connection refused") { - warn!("Vault is not running (connection refused)"); - return Err(anyhow::anyhow!("Vault not running - needs to be started")); + connection_refused = true; + // Don't return immediately - keep retrying as vault may be starting + continue; } + connection_refused = false; if let Ok(status) = serde_json::from_str::(&status_str) { parsed_status = Some(status); break; } } + // Only return error after all retries exhausted + if connection_refused { + warn!("Vault is not running after retries (connection refused)"); + return Err(anyhow::anyhow!("Vault not running - needs to be started")); + } + // Parse status - handle both success and error cases if let Some(status) = parsed_status { let initialized = status["initialized"].as_bool().unwrap_or(false);