From aeeee3c1e3e9bfc38462cb315b6e19ee9fe6db70 Mon Sep 17 00:00:00 2001 From: Roman Melnikov Date: Wed, 1 Nov 2023 12:42:30 +0100 Subject: [Chore] Make activation wait timeout configurable Problem: Currently profile activation waiting timeout is hardcoded to 240 seconds, see https://github.com/serokell/deploy-rs/pull/48. In some cases, this timeout can be exceeded (e.g. activation performs a heavy DB migration and waits for it to finish before considering the profile activation succesful). Solution: Make this timeout configurable via 'activationTimeout' deploy attribute or corresponding '--activation-timeout' CLI option. For the sake of backward compatibility, the new 'wait' subcommand '--activation-timeout' option is made optional and defaults to 240 seconds if it wasn't provided. --- src/bin/activate.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/bin/activate.rs') diff --git a/src/bin/activate.rs b/src/bin/activate.rs index 4a2760b..4017510 100644 --- a/src/bin/activate.rs +++ b/src/bin/activate.rs @@ -101,6 +101,10 @@ struct WaitOpts { /// Path for any temporary files that may be needed during activation #[clap(long)] temp_path: PathBuf, + + /// Timeout to wait for activation + #[clap(long)] + activation_timeout: Option, } /// Revoke profile activation @@ -319,7 +323,7 @@ pub enum WaitError { #[error("Error waiting for activation: {0}")] Waiting(#[from] DangerZoneError), } -pub async fn wait(temp_path: PathBuf, closure: String) -> Result<(), WaitError> { +pub async fn wait(temp_path: PathBuf, closure: String, activation_timeout: Option) -> Result<(), WaitError> { let lock_path = deploy::make_lock_path(&temp_path, &closure); let (created, done) = mpsc::channel(1); @@ -359,7 +363,7 @@ pub async fn wait(temp_path: PathBuf, closure: String) -> Result<(), WaitError> return Ok(()); } - danger_zone(done, 240).await?; + danger_zone(done, activation_timeout.unwrap_or(240)).await?; info!("Found canary file, done waiting!"); @@ -575,7 +579,7 @@ async fn main() -> Result<(), Box> { .await .map_err(|x| Box::new(x) as Box), - SubCommand::Wait(wait_opts) => wait(wait_opts.temp_path, wait_opts.closure) + SubCommand::Wait(wait_opts) => wait(wait_opts.temp_path, wait_opts.closure, wait_opts.activation_timeout) .await .map_err(|x| Box::new(x) as Box), -- cgit v1.2.3