diff options
author | Roman Melnikov | 2023-11-01 12:42:30 +0100 |
---|---|---|
committer | Roman Melnikov | 2023-11-02 11:29:52 +0100 |
commit | aeeee3c1e3e9bfc38462cb315b6e19ee9fe6db70 (patch) | |
tree | db04d30c6df0f6f19ccdfc6070da00c5bbf4d1b8 /src/bin | |
parent | d50737080327575d78fe7490b20fcc3eba9f1d72 (diff) |
[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.
Diffstat (limited to '')
-rw-r--r-- | src/bin/activate.rs | 10 |
1 files changed, 7 insertions, 3 deletions
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<u16>, } /// 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<u16>) -> 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<dyn std::error::Error>> { .await .map_err(|x| Box::new(x) as Box<dyn std::error::Error>), - 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<dyn std::error::Error>), |