From 1b792a07dd1f48b145ea2fc610f3476dadc774f0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 2 Feb 2021 14:44:46 +0100 Subject: Fix: Make sure that bar is moved to LogReceiver, drop it afterwards This patch makes the bar moved to the LogReceiver instead of borrowing it to it. Because ProgressBar::clone() is cheap (according to indicatif documentation it is just an Arc<> holding the actual object), we can do this here without fearing the overhead. Signed-off-by: Matthias Beyer --- src/endpoint/scheduler.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/endpoint/scheduler.rs b/src/endpoint/scheduler.rs index a4721a8..a993833 100644 --- a/src/endpoint/scheduler.rs +++ b/src/endpoint/scheduler.rs @@ -179,9 +179,10 @@ impl JobHandle { log_dir: self.log_dir.as_ref(), job_id, log_receiver, - bar: &self.bar, + bar: self.bar.clone(), } .join(); + drop(self.bar); let (run_container, logres) = tokio::join!(running_container, logres); let log = logres.with_context(|| anyhow!("Collecting logs for job on '{}'", ep.name()))?; @@ -320,7 +321,7 @@ struct LogReceiver<'a> { log_dir: Option<&'a PathBuf>, job_id: Uuid, log_receiver: UnboundedReceiver, - bar: &'a ProgressBar, + bar: ProgressBar, } impl<'a> LogReceiver<'a> { -- cgit v1.2.3 From 21599575558fe2f456265d1b2381eab6184c7dbd Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 2 Feb 2021 14:45:54 +0100 Subject: Fix: Progress reporting This patch fixes progress reporting. Because our progress-bar-creating helper initializes the bar with length 1, we have to set the length here manually. The bar has to be added to the multibar object right away, because otherwise it will be rendered to the output which gives us an ugly dead progress bar. If the length is set after the adding to the multibar object, this does not happen. Signed-off-by: Matthias Beyer Tested-by: Matthias Beyer --- src/orchestrator/orchestrator.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/orchestrator/orchestrator.rs b/src/orchestrator/orchestrator.rs index ecd994a..de2f82f 100644 --- a/src/orchestrator/orchestrator.rs +++ b/src/orchestrator/orchestrator.rs @@ -233,11 +233,14 @@ impl<'a> Orchestrator<'a> { let (sender, receiver) = tokio::sync::mpsc::channel(100); trace!("Creating TaskPreparation object for job {}", uuid); + let bar = self.progress_generator.bar(); + let bar = multibar.add(bar); + bar.set_length(100); let tp = TaskPreparation { uuid: *uuid, jobdef, - bar: multibar.add(self.progress_generator.bar()), + bar, config: self.config, source_cache: &self.source_cache, scheduler: &self.scheduler, -- cgit v1.2.3