From 3a93f8b871d78464521797daff58e348d919b710 Mon Sep 17 00:00:00 2001 From: Markus Frei Date: Mon, 16 Nov 2026 09:02:14 +0100 Subject: [PATCH] fix(plugin:dashboard): keep the ETA for the remaining steps while a large include runs An include_tasks or include_role is one step of the progress bar. The ETA subtracted the whole running time of the current step from the estimate for all steps left, so a long include such as the one of monitoring_plugins (install.yml with linux-source.yml, about 60 tasks) drove it to 00:00:00 with 60 steps to go. The steps after the running one now always count in full, and only the running step's own average share is counted down. --- plugins/callback/dashboard.py | 9 ++++++--- tests/unit/plugins/callback/test_dashboard.py | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/callback/dashboard.py b/plugins/callback/dashboard.py index 2dbf8a621..66836dcc5 100644 --- a/plugins/callback/dashboard.py +++ b/plugins/callback/dashboard.py @@ -195,14 +195,17 @@ def hms(seconds): def eta(step, total, play_start, step_start, now): """The remaining time of a play, or None before the first step is done. The - time the finished steps took per step, times the steps left, less the time the - running step already took. It gets more accurate towards the end of the play. + time the finished steps took per step, times the steps after the running one, + plus what is left of that step's share. A step that runs longer than the + average, like an include_tasks with dozens of tasks, does not eat into the + estimate for the steps after it. It gets more accurate towards the end of the + play. """ done = step - 1 if done < 1: return None per_step = (step_start - play_start) / done - return max(per_step * (total - done) - (now - step_start), 0) + return per_step * (total - step) + max(per_step - (now - step_start), 0) def progress_bar(step, total, width, color=True, remaining=None): diff --git a/tests/unit/plugins/callback/test_dashboard.py b/tests/unit/plugins/callback/test_dashboard.py index ff228060c..ce864fd71 100644 --- a/tests/unit/plugins/callback/test_dashboard.py +++ b/tests/unit/plugins/callback/test_dashboard.py @@ -261,7 +261,10 @@ def test_eta_from_the_finished_steps(self): self.assertEqual(_module.eta(7, 21, 100, 160, 164), 146) # no step done yet self.assertIsNone(_module.eta(1, 21, 100, 100, 130)) - # a step that takes longer than estimated does not go below zero + # a step that takes longer than the average, like a large include, keeps + # the estimate for the 14 steps after it + self.assertEqual(_module.eta(7, 21, 100, 160, 460), 140) + # and the last step does not go below zero self.assertEqual(_module.eta(21, 21, 0, 200, 900), 0)