diff options
| author | diogo464 <[email protected]> | 2025-07-24 12:46:32 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-07-24 12:46:32 +0100 |
| commit | f068edd95f960dea97bb874430c43e55d6b7d186 (patch) | |
| tree | d30ba87f0b3b4f6be6365a9739224e644a639887 /src/main.rs | |
| parent | 4cb719cd459a7b53e40e57d8dcf4e2cdf72e99f9 (diff) | |
added basic retry logic to the machine_containers_wait function
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index cba59b8..4fd002a 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -544,7 +544,23 @@ async fn machine_containers_wait( | |||
| 544 | ) -> Result<()> { | 544 | ) -> Result<()> { |
| 545 | tracing::info!("waiting for {} containers to exit", containers.len()); | 545 | tracing::info!("waiting for {} containers to exit", containers.len()); |
| 546 | let script = machine_containers_wait_script(containers); | 546 | let script = machine_containers_wait_script(containers); |
| 547 | machine_run_script(ctx, machine, &script).await?; | 547 | let retry_seconds = 5; |
| 548 | let mut retries = 10; | ||
| 549 | loop { | ||
| 550 | match machine_run_script(ctx, machine, &script).await { | ||
| 551 | Ok(_) => break, | ||
| 552 | Err(err) => { | ||
| 553 | tracing::debug!("failed to run script: {err}, {retries} left"); | ||
| 554 | if retries == 0 { | ||
| 555 | return Err(err); | ||
| 556 | } | ||
| 557 | retries -= 1; | ||
| 558 | tracing::debug!("waiting {retry_seconds} before retrying..."); | ||
| 559 | tokio::time::sleep(Duration::from_secs(retry_seconds)).await; | ||
| 560 | tracing::debug!("retrying"); | ||
| 561 | } | ||
| 562 | } | ||
| 563 | } | ||
| 548 | tracing::info!("all containers exited"); | 564 | tracing::info!("all containers exited"); |
| 549 | Ok(()) | 565 | Ok(()) |
| 550 | } | 566 | } |
