diff options
| author | diogo464 <[email protected]> | 2025-08-08 13:30:43 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-08-08 13:30:43 +0100 |
| commit | 2b7d8cc7ce98f706dc07becec36263dd40f25d03 (patch) | |
| tree | 41b9953110bac63b1a2bc7f3ae9f88a715063d64 /src/main.rs | |
| parent | 6eab78fa80a47adfeded4fe10cd57b77c20bed07 (diff) | |
improved container wait reliability with timeouts/retries
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 7ef6ff6..3db3169 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -565,12 +565,14 @@ async fn machine_containers_wait( | |||
| 565 | ) -> Result<()> { | 565 | ) -> Result<()> { |
| 566 | tracing::info!("waiting for {} containers to exit", containers.len()); | 566 | tracing::info!("waiting for {} containers to exit", containers.len()); |
| 567 | let script = machine_containers_wait_script(containers); | 567 | let script = machine_containers_wait_script(containers); |
| 568 | let wait_timeout = Duration::from_secs(60); | ||
| 568 | let retry_seconds = 5; | 569 | let retry_seconds = 5; |
| 569 | let mut retries = 10; | 570 | let mut retries = 10; |
| 570 | loop { | 571 | loop { |
| 571 | match machine_run_script(ctx, machine, &script).await { | 572 | let fut = tokio::time::timeout(wait_timeout, machine_run_script(ctx, machine, &script)); |
| 572 | Ok(_) => break, | 573 | match fut.await { |
| 573 | Err(err) => { | 574 | Ok(Ok(_)) => break, |
| 575 | Ok(Err(err)) => { | ||
| 574 | tracing::debug!("failed to run script: {err}, {retries} left"); | 576 | tracing::debug!("failed to run script: {err}, {retries} left"); |
| 575 | if retries == 0 { | 577 | if retries == 0 { |
| 576 | return Err(err); | 578 | return Err(err); |
| @@ -580,6 +582,10 @@ async fn machine_containers_wait( | |||
| 580 | tokio::time::sleep(Duration::from_secs(retry_seconds)).await; | 582 | tokio::time::sleep(Duration::from_secs(retry_seconds)).await; |
| 581 | tracing::debug!("retrying"); | 583 | tracing::debug!("retrying"); |
| 582 | } | 584 | } |
| 585 | Err(_) => { | ||
| 586 | tracing::debug!("wait timeout, retrying..."); | ||
| 587 | tokio::time::sleep(Duration::from_secs(retry_seconds)).await; | ||
| 588 | } | ||
| 583 | } | 589 | } |
| 584 | } | 590 | } |
| 585 | tracing::info!("all containers exited"); | 591 | tracing::info!("all containers exited"); |
