Deleted hosts aren't removed from the finished script runs on the batch script progress page
Fleet version: 4.74
Web browser and operating system: N/A
💥 Actual behavior
Hosts are removed from the list, but the count is still displayed on the total progress bar and in the corresponding tab in the batch script progress.
🛠️ To fix
When a host is deleted, decrease host counts for any batch script runs they were part of.
🧑💻 Steps to reproduce
- Start a batch script run on several hosts
- Wait for it to finish
- Delete the hosts on which you ran it.
- Open Batch script UI
🕯️ More info (optional)
We update the host count for any in-progress and scheduled scripts, just not for the finished ones
Nice catch! Dealing with deleted hosts was something we all missed in the initial design and have been patching as it comes up.
For the progress bar, there's not a lot we can do safely w/ the current implementation. We cache the stats on the record when it's finished, because the query to generate those numbers is expensive and as the list of finished batch runs goes it'll become prohibitive to run.
The details page we can switch to using the "live" numbers, but then they wouldn't match the progress bar 🤔 .
The more thorough solution would be to add logic to update the stats for related batch script runs when a host is deleted. I wouldn't want to do that as a cherry-pick though, it'll require some planning.
@AndreyKizimenko , @sgress454 , did we miss this? Since it's not 4.76.0 I removed the unreleased label. TMWYT
@sgress454 @AndreyKizimenko
Alternative frontend solution:
Frontend change where if count in progress bar is bigger than the hosts listed on such tab then we add a note saying that "host counts may include deleted hosts".
@melpike @rachaelshaw See my last comment (moving to user story review).
@lucasmrod I'm good with that. We can include the note as a tooltip over the count badge.
@melpike to be 100% clear do you want to add the tooltip to the badges at all times, or only when we detect a difference between the number on the badge and the number in the label of the hosts table?
Frontend change where if count in progress bar is bigger than the hosts listed on such tab then we add a note saying that "host counts may include deleted hosts".
@sgress454 Thanks for following up. Yes, to be clear, I was going off of Lucas' suggestion above. However, if there's complexity I'm not accounting for, I'll defer to the eng team.
However, if there's complexity I'm not accounting for, I'll defer to the eng team.
There is a bit, because we only get the second number (the one above the table) after we click the badge. So the tooltip would only appear after you click the badge at least once (but should appear immediately as long as you're still hovering over the badge). After that we can keep it so that the tooltip always appears on hover.
@melpike How about we render a help text message above the table instead? We could trigger it conditionally, only showing it if a specific category count (like Incompatible) doesn't match the host list count. Here is a preview of how that would look:
How about we render a help text message above the table instead?
Thanks for bringing this up @juan-fdz-hawa! Let's follow some of the UI's existing patterns and have a tooltip on the host count above the table "Some hosts may have been removed."
@juan-fdz-hawa While testing this I couldn't reproduce the original issue, so the tooltip is never showing for me, unless I'm not performing the steps to reproduce correctly. Here's a video:
https://github.com/user-attachments/assets/9e45deae-cb83-46e9-b4a5-93f8417ad9b0
Perhaps there was a change on main that solved the root cause of this issue and we no longer need the tooltip?
Only way I could get the bug to surface was to cook it using something like: INSERT INTO fleet.batch_activities (script_id, execution_id, user_id, job_id, status, activity_type, num_targeted, num_pending, num_ran, num_errored, num_incompatible, num_canceled, created_at, updated_at, started_at, finished_at, canceled) VALUES (1, uuid(), null, null, 'finished', 'script', 2, 0, 1, 0, 0, 0, '2026-03-25 17:24:06', '2026-03-25 17:26:56', '2026-03-25 17:24:06', '2026-03-25 17:24:53', 0);
Ghosts no longer cloud Script count, clear as glass city, Fleet's truth shines brightly.