Skip to content

Commit d8cc56d

Browse files
committed
network creation failsafe
1 parent 8235b65 commit d8cc56d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

application/src/config.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,6 +1393,7 @@ impl Config {
13931393
"a docker network with the same name already exists, but it overlaps with another network. automatically incrementing interface, pool subnet and gateway by 1 and trying again..."
13941394
);
13951395

1396+
let mut attempts = 0;
13961397
loop {
13971398
fn increment_ip_or_cidr(ip: &str) -> String {
13981399
let network_mask = if let Some(slash) = ip.find('/') {
@@ -1447,6 +1448,14 @@ impl Config {
14471448
tracing::info!("created docker network {}", self.docker.network.name);
14481449
break;
14491450
}
1451+
1452+
if attempts >= 80 {
1453+
return Err(anyhow::anyhow!(
1454+
"failed to create docker network after 80 attempts, aborting"
1455+
));
1456+
}
1457+
1458+
attempts += 1;
14501459
}
14511460
}
14521461
Err(err) => return Err(err.into()),

0 commit comments

Comments
 (0)