From a03144e004e7def36be89dda94ff79d770644dea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Felipe=20Gon=C3=A7alves?= Date: Fri, 21 Jun 2024 08:10:04 -0300 Subject: [PATCH] fix(ctl): allocate more instances than workers available --- ctl/src/deployer/alloc.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ctl/src/deployer/alloc.rs b/ctl/src/deployer/alloc.rs index af8c31d..3a1c085 100644 --- a/ctl/src/deployer/alloc.rs +++ b/ctl/src/deployer/alloc.rs @@ -14,8 +14,10 @@ pub fn rand_many( workers: &[WorkerDetails], instances: u32, ) -> impl Iterator + '_ { - workers - .choose_multiple(&mut rand::thread_rng(), instances as usize) + let mut rng = rand::thread_rng(); + (0..instances) + // Unwrap is safe since an eventual 0..0 wouldn't yield any iterations. + .map(move |_| workers.choose(&mut rng).unwrap()) .map(|w| (InstanceId(Uuid::now_v7()), w.addr)) }