diff options
| author | diogo464 <[email protected]> | 2025-08-23 17:18:51 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-08-23 17:18:51 +0100 |
| commit | 49aa9352c52b92e9bc4326080c87c9a6a0a97813 (patch) | |
| tree | 1b3d2e38ef998ededd0d9f5aa0f94430e7cdb2c5 | |
| parent | f727cb597497337c7dd74b29d07239ad3b8624cf (diff) | |
remove existing containers on net up/down
| -rw-r--r-- | src/main.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index b964d95..46e660a 100644 --- a/src/main.rs +++ b/src/main.rs | |||
| @@ -252,6 +252,7 @@ async fn cmd_net_up(args: NetUpArgs) -> Result<()> { | |||
| 252 | .context("parsing latency matrix")?; | 252 | .context("parsing latency matrix")?; |
| 253 | let machines = oar::job_list_machines(&context).await?; | 253 | let machines = oar::job_list_machines(&context).await?; |
| 254 | let configs = machine_generate_configs(&matrix, args.matrix_wrap, &machines, &args.addresses)?; | 254 | let configs = machine_generate_configs(&matrix, args.matrix_wrap, &machines, &args.addresses)?; |
| 255 | machines_containers_clean(&context, &machines).await?; | ||
| 255 | machines_net_container_build(&context, &machines).await?; | 256 | machines_net_container_build(&context, &machines).await?; |
| 256 | machines_clean(&context, &machines).await?; | 257 | machines_clean(&context, &machines).await?; |
| 257 | machines_configure(&context, &configs).await?; | 258 | machines_configure(&context, &configs).await?; |
| @@ -261,6 +262,7 @@ async fn cmd_net_up(args: NetUpArgs) -> Result<()> { | |||
| 261 | async fn cmd_net_down(args: NetDownArgs) -> Result<()> { | 262 | async fn cmd_net_down(args: NetDownArgs) -> Result<()> { |
| 262 | let context = context_from_common(&args.common).await?; | 263 | let context = context_from_common(&args.common).await?; |
| 263 | let machines = oar::job_list_machines(&context).await?; | 264 | let machines = oar::job_list_machines(&context).await?; |
| 265 | machines_containers_clean(&context, &machines).await?; | ||
| 264 | machines_net_container_build(&context, &machines).await?; | 266 | machines_net_container_build(&context, &machines).await?; |
| 265 | machines_clean(&context, &machines).await?; | 267 | machines_clean(&context, &machines).await?; |
| 266 | Ok(()) | 268 | Ok(()) |
| @@ -400,7 +402,7 @@ async fn cmd_run(args: RunArgs) -> Result<()> { | |||
| 400 | let containers = parse_schedule(&schedule)?; | 402 | let containers = parse_schedule(&schedule)?; |
| 401 | let machines = oar::job_list_machines(&ctx).await?; | 403 | let machines = oar::job_list_machines(&ctx).await?; |
| 402 | 404 | ||
| 403 | machine::for_each(&machines, |machine| machine_containers_clean(&ctx, machine)).await?; | 405 | machines_containers_clean(&ctx, &machines).await?; |
| 404 | machine::for_each(&machines, |machine| { | 406 | machine::for_each(&machines, |machine| { |
| 405 | let ctx = ctx.clone(); | 407 | let ctx = ctx.clone(); |
| 406 | let containers = containers | 408 | let containers = containers |
| @@ -487,10 +489,7 @@ async fn cmd_clean(args: CleanArgs) -> Result<()> { | |||
| 487 | let context = context_from_common(&args.common).await?; | 489 | let context = context_from_common(&args.common).await?; |
| 488 | let machines = oar::job_list_machines(&context).await?; | 490 | let machines = oar::job_list_machines(&context).await?; |
| 489 | machines_net_container_build(&context, &machines).await?; | 491 | machines_net_container_build(&context, &machines).await?; |
| 490 | machine::for_each(&machines, |machine| { | 492 | machines_containers_clean(&context, &machines).await?; |
| 491 | machine_containers_clean(&context, machine) | ||
| 492 | }) | ||
| 493 | .await?; | ||
| 494 | machines_clean(&context, &machines).await?; | 493 | machines_clean(&context, &machines).await?; |
| 495 | Ok(()) | 494 | Ok(()) |
| 496 | } | 495 | } |
| @@ -706,6 +705,12 @@ async fn machines_clean(ctx: &Context, machines: &[Machine]) -> Result<()> { | |||
| 706 | } | 705 | } |
| 707 | 706 | ||
| 708 | #[tracing::instrument(ret, err, skip_all)] | 707 | #[tracing::instrument(ret, err, skip_all)] |
| 708 | async fn machines_containers_clean(ctx: &Context, machines: &[Machine]) -> Result<()> { | ||
| 709 | machine::for_each(machines, |machine| machine_containers_clean(&ctx, machine)).await?; | ||
| 710 | Ok(()) | ||
| 711 | } | ||
| 712 | |||
| 713 | #[tracing::instrument(ret, err, skip_all)] | ||
| 709 | async fn machines_net_container_build(ctx: &Context, machines: &[Machine]) -> Result<()> { | 714 | async fn machines_net_container_build(ctx: &Context, machines: &[Machine]) -> Result<()> { |
| 710 | tracing::info!("building networking container for machines: {machines:?}"); | 715 | tracing::info!("building networking container for machines: {machines:?}"); |
| 711 | machine::for_each(machines, |machine| { | 716 | machine::for_each(machines, |machine| { |
