Skip to content

Commit

Permalink
Final commit
Browse files Browse the repository at this point in the history
  • Loading branch information
samuchila committed Apr 23, 2024
1 parent 64223f7 commit f41ff99
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions api/src/infrastructure/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,40 @@ impl DockerInfrastructure {
let docker = Docker::connect_with_socket_defaults()?;

let mut futures = container_details
.clone()
.into_iter()
.filter(|p| {
p.state.as_ref().and_then(|state| state.status)
== Some(ContainerStateStatusEnum::RUNNING)
})
.map(|details| async {
let id = details
.id
.as_ref()
.expect("id is mandatory for a docker container");

if details.state.as_ref().and_then(|state| state.status)
== Some(ContainerStateStatusEnum::RUNNING)
{
docker.stop_container(id, None).await?;
trace!("Stopped container {id} for {app_name}");
}
docker.stop_container(id, None).await?;

Ok::<ContainerInspectResponse, BollardError>(details)
})
.map(Box::pin)
.collect::<FuturesUnordered<_>>();

while let Some(result) = futures.next().await {
let container = result?;
let id = container
.id
.expect("id is mandatory for a docker container");
trace!("Stopped container {id} for {app_name}");
}

let mut futures = container_details
.into_iter()
.map(|details| async {
let id = details
.id
.as_ref()
.expect("id is mandatory for a docker container");

docker.remove_container(id, None).await?;
trace!("Deleted container {id} for {app_name}");
Expand Down

0 comments on commit f41ff99

Please sign in to comment.