diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2021-04-12 13:53:03 +0200 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@atos.net> | 2021-04-12 19:34:41 +0200 |
commit | 8706494827ad598d335a9369beecdd0ddfef0cee (patch) | |
tree | b6cdd12368f63806867879579913740c181bb624 /src | |
parent | 8ba1fa438d00b7fb417aa15152e5e6dc93b3aba9 (diff) |
Shuffle endpoint configurations
As the comment in the code explains, we're always loading the endpoints from the
same file and feed it to the scheduler the same way.
Because of that, we always schedule to the first endpoint until it is full and
then to the second.
To have a bit more spreading over the endpoints, shuffle the configurations
before connecting, so this way the scheduler does not always (each time butido
is called) use the same endpoint as first endpoint.
This is not a perfect solution, but a simple and working one.
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/commands/build.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/commands/build.rs b/src/commands/build.rs index afe0e45..07d2ce8 100644 --- a/src/commands/build.rs +++ b/src/commands/build.rs @@ -98,7 +98,7 @@ pub async fn build( trace!("Repository HEAD = {}", hash_str); let phases = config.available_phases(); - let endpoint_configurations = config + let mut endpoint_configurations = config .docker() .endpoints() .iter() @@ -111,7 +111,14 @@ pub async fn build( .required_docker_api_versions(config.docker().docker_api_versions().clone()) .build() }) - .collect(); + .collect::<Vec<_>>(); + { + // Because we're loading always sequencially, to have a bit more spread over the endpoints, + // shuffle the endpoints here. Not a perfect solution, but a working one. + use rand::Rng; + let mut rng = rand::thread_rng(); + rng.shuffle(&mut endpoint_configurations); + } info!("Endpoint config build"); let pname = matches |