From b626743b744ab44f22e58f2bee9102556ae466d4 Mon Sep 17 00:00:00 2001 From: Elvis Pranskevichus Date: Tue, 6 Feb 2024 13:10:56 -0800 Subject: [PATCH] Bump operation monitor timeout, remove unnecessary instance status check (#1202) Some operations may take considerably longer than 5 minutes, so bump the monitor timeout to 20 minutes. Also, remove instance status check as any successful completion of operation will ensure the instance is in the available state. --- src/cloud/ops.rs | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/src/cloud/ops.rs b/src/cloud/ops.rs index 18ea7a4f4..b46f293b4 100644 --- a/src/cloud/ops.rs +++ b/src/cloud/ops.rs @@ -12,8 +12,8 @@ use crate::options::CloudOptions; use crate::portable::status::{RemoteStatus, RemoteType, try_connect}; use crate::question; -const OPERATION_WAIT_TIME: Duration = Duration::from_secs(5 * 60); -const POLLING_INTERVAL: Duration = Duration::from_secs(1); +const OPERATION_WAIT_TIME: Duration = Duration::from_secs(20 * 60); +const POLLING_INTERVAL: Duration = Duration::from_secs(2); const SPINNER_TICK: Duration = Duration::from_millis(100); #[derive(Debug, serde::Serialize, serde::Deserialize)] @@ -246,24 +246,7 @@ async fn wait_for_operation( } } - anyhow::bail!("Timed out.") -} - -async fn wait_instance_available_after_operation( - operation: CloudOperation, - org: &str, - name: &str, - client: &CloudClient, -) -> anyhow::Result { - wait_for_operation(operation, client).await?; - let url = format!("orgs/{}/instances/{}", org, name); - let instance: CloudInstance = client.get(&url).await?; - - if instance.dsn != "" && instance.status == "available" { - Ok(instance) - } else { - anyhow::bail!("Timed out.") - } + anyhow::bail!("Operation is taking too long, stopping monitor.") } #[tokio::main] @@ -281,8 +264,7 @@ pub async fn create_cloud_instance( } _ => Err(e), })?; - wait_instance_available_after_operation( - operation, &request.org, &request.name, client).await?; + wait_for_operation(operation, client).await?; Ok(()) } @@ -302,8 +284,7 @@ pub async fn resize_cloud_instance( } _ => Err(e), })?; - wait_instance_available_after_operation( - operation, &request.org, &request.name, client).await?; + wait_for_operation(operation, client).await?; Ok(()) } @@ -316,8 +297,7 @@ pub async fn upgrade_cloud_instance( let operation: CloudOperation = client .put(url, request) .await?; - wait_instance_available_after_operation( - operation, &request.org, &request.name, client).await?; + wait_for_operation(operation, client).await?; Ok(()) }