aboutsummaryrefslogtreecommitdiff
path: root/src/deploy.rs
diff options
context:
space:
mode:
authorRoman Melnikov2023-11-01 12:42:30 +0100
committerRoman Melnikov2023-11-02 11:29:52 +0100
commitaeeee3c1e3e9bfc38462cb315b6e19ee9fe6db70 (patch)
treedb04d30c6df0f6f19ccdfc6070da00c5bbf4d1b8 /src/deploy.rs
parentd50737080327575d78fe7490b20fcc3eba9f1d72 (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/deploy.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/deploy.rs b/src/deploy.rs
index 41cd58b..a371c18 100644
--- a/src/deploy.rs
+++ b/src/deploy.rs
@@ -121,6 +121,7 @@ struct WaitCommandData<'a> {
sudo: &'a Option<String>,
closure: &'a str,
temp_path: &'a Path,
+ activation_timeout: Option<u16>,
debug_logs: bool,
log_dir: Option<&'a str>,
}
@@ -142,6 +143,9 @@ fn build_wait_command(data: &WaitCommandData) -> String {
data.closure,
data.temp_path.display(),
);
+ if let Some(activation_timeout) = data.activation_timeout {
+ self_activate_command = format!("{} --activation-timeout {}", self_activate_command, activation_timeout);
+ }
if let Some(sudo_cmd) = &data.sudo {
self_activate_command = format!("{} {}", sudo_cmd, self_activate_command);
@@ -155,6 +159,7 @@ fn test_wait_command_builder() {
let sudo = Some("sudo -u test".to_string());
let closure = "/nix/store/blah/etc";
let temp_path = Path::new("/tmp");
+ let activation_timeout = Some(600);
let debug_logs = true;
let log_dir = Some("/tmp/something.txt");
@@ -163,10 +168,11 @@ fn test_wait_command_builder() {
sudo: &sudo,
closure,
temp_path,
+ activation_timeout,
debug_logs,
log_dir
}),
- "sudo -u test /nix/store/blah/etc/activate-rs --debug-logs --log-dir /tmp/something.txt wait '/nix/store/blah/etc' --temp-path '/tmp'"
+ "sudo -u test /nix/store/blah/etc/activate-rs --debug-logs --log-dir /tmp/something.txt wait '/nix/store/blah/etc' --temp-path '/tmp' --activation-timeout 600"
.to_string(),
);
}
@@ -328,6 +334,8 @@ pub async fn deploy_profile(
let confirm_timeout = deploy_data.merged_settings.confirm_timeout.unwrap_or(30);
+ let activation_timeout = deploy_data.merged_settings.activation_timeout;
+
let magic_rollback = deploy_data.merged_settings.magic_rollback.unwrap_or(true);
let auto_rollback = deploy_data.merged_settings.auto_rollback.unwrap_or(true);
@@ -386,6 +394,7 @@ pub async fn deploy_profile(
sudo: &deploy_defs.sudo,
closure: &deploy_data.profile.profile_settings.path,
temp_path: temp_path,
+ activation_timeout: activation_timeout,
debug_logs: deploy_data.debug_logs,
log_dir: deploy_data.log_dir,
});