fleetctl trigger silently no-ops for WithRunOnce schedules after a restart (found while QA'ing #36365 fix)
Fleet versions
- Discovered: 4.91.0-rc.2608171507 (branch
rc-minor-fleet-v4.91.0) - Reproduced: 4.91.0-rc.2608171507 (branch
rc-minor-fleet-v4.91.0)
Web browser and operating system: N/A — reproduced via fleetctl trigger, direct MySQL queries, and Go source inspection against a local dev server on macOS; no browser UI involved.
💥 Actual behavior
fleetctl trigger --name software_checksum_migration (the documented remediation for #36365 — "Duplicate CVE entries for giflib 5.2.2" — if duplicate software inventory rows are still present after upgrading) silently does nothing once the migration has completed successfully one time and the server has been restarted since. The command reports success ("Sent request to trigger software_checksum_migration schedule") and returns no error, but no reconciliation actually runs.
Root cause: cronSoftwareChecksumMigration (added in PR #50427, changed to auto-run via PR #50490) is registered with schedule.WithRunOnce(true). Schedule.Start() (server/service/schedule/schedule.go) contains:
} else if s.runOnce && prevScheduledRun.Status == fleet.CronStatsStatusCompleted {
// If job is set to run once, and it already ran, then nothing to do
return
}
prevScheduledRun is read from the persisted cron_stats table, not an in-memory flag. So on any server restart after one completed run, every future Start() call for this schedule hits this branch and returns before the goroutine that listens on the schedule's trigger channel is ever created.
However, CronSchedules.StartCronSchedule (server/fleet/cron_schedules.go) still registers the schedule in the running-schedules map unconditionally:
sched.Start()
cs.Schedules[sched.Name()] = sched
So TriggerCronSchedule finds the schedule by name (no "not found" error), calls sched.Trigger(ctx), which attempts a non-blocking send on the trigger channel:
select {
case s.trigger <- 0:
didTrigger = true
default:
s.logger.DebugContext(ctx, "trigger channel not available")
}
return nil, didTrigger, nil
Since nothing is listening (the goroutine was never created), this always falls to default:, logs only at DEBUG level, and returns (nil, false, nil) — no error. TriggerCronSchedule's caller sees err == nil and stats == nil and reports success.
This also means the "runs daily thereafter" behavior described in PR #50490's release notes only holds for the lifetime of a single continuously-running process — a restart resets everything, and the same early-return prevents the daily ticker from ever being set up again either.
Not a new pattern: the identical WithRunOnce(true) construction already exists in cronUninstallSoftwareMigration and cronUpgradeCodeSoftwareMigration (cmd/fleet/cron.go), predating this ticket. PR #50490 copied an existing, already-flawed pattern onto a third schedule rather than introducing a new one — meaning uninstall_software_migration and upgrade_code_software_migration most likely have the identical bug today.
Verified live against main/rc-minor-fleet-v4.91.0 (commit 1ba789a263a5):
- Confirmed via
cron_statsthatsoftware_checksum_migrationhad onecompletedrow from an earlier server startup. fleetctl trigger --name software_checksum_migrationagainst the then-running server produced no newcron_statsrow and no change to a manually-inserted duplicate-checksum pair forgiflib 5.2.2/homebrew_packages.- Deleted the stale
cron_statsrow and restarted the server —Start()then proceeded normally, the migration ran automatically, and a fresh manual trigger did work (and was idempotent on a second call) — all within that same process. - Confirms the break is specifically "next restart after a completed run persists," not "immediately after any single completion."
🛠️ Expected behavior
fleetctl trigger --name software_checksum_migration (and the equivalent for uninstall_software_migration / upgrade_code_software_migration, if they share this bug) should actually re-run the job whenever invoked, regardless of how many times the server has restarted since the job last completed — matching what the PR's own documentation and release notes describe. At minimum, TriggerCronSchedule should surface an error when a schedule is registered but its listener was never started, rather than silently reporting success.
🧑💻 Steps to reproduce
- [x] Have been confirmed to consistently lead to reproduction in multiple Fleet instances.
- On a Fleet instance with the fix for #36365 (
software_checksum_migrationregistered withWithRunOnce(true)), let the server start up normally so the migration runs once andcron_statsrecords acompletedrow forsoftware_checksum_migration. - Restart the Fleet server (any restart — deploy, pod reschedule, manual restart).
- Insert a duplicate-checksum software pair directly (or otherwise reproduce #36365's duplicate-row scenario).
- Run
fleetctl trigger --name software_checksum_migration. - Observe: command reports success, but no new
cron_statsrow is created and the duplicate is not merged. - (To confirm the mechanism) Delete the
completedcron_statsrow for this schedule and restart the server again — the trigger will work correctly within that process, until the next restart.
🕯️ More info (optional)
- Related: #36365 ("Duplicate CVE entries for giflib 5.2.2"), fixed by fleetdm/fleet#50427 and fleetdm/fleet#50490
- This is a follow-up finding from QA'ing #36365's fix, not a new independent bug report unrelated to it. The core duplicate-merging logic (
ReconcileSoftwareChecksums) is correct and well-tested — verified directly via a live reproduction using the exact real pre/post-v4.76.0 checksum formulas forgiflib 5.2.2. This ticket is specifically about the scheduling/trigger wrapper around that logic. - Worth checking whether
cronUninstallSoftwareMigrationandcronUpgradeCodeSoftwareMigrationhave the same issue, since they use the identicalWithRunOnce(true)pattern. - Relevant code:
server/service/schedule/schedule.go(Start(),Trigger()),server/fleet/cron_schedules.go(StartCronSchedule,TriggerCronSchedule),cmd/fleet/cron.go(cronSoftwareChecksumMigrationand the two otherWithRunOnceschedules).
This is expected - the server was updated so that the bug is not introduced again. software_checksum_migration is meant to be run once to fix existing data (the reason why it was not added as a migration due to possible performance issues).
If the run was successful, the user shouldn't need to run software_checksum_migration again - and we should probably be good to remove that job altogether in a subsequent release.
Schedules sleep after restart trigger channel never wakes silent success lies
Closing issue since @juan-fdz-hawa mentioned this was as-designed.
Schedules persist through restarts but listeners fade to silence trigger brings no change