From e2779f80c03bca0680466eec738f2bf8c2c28dac Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Fri, 13 Feb 2026 15:17:05 +1100 Subject: [PATCH] Adjust snapshot interval calculations to use one-third of the configured cadence --- internal/tasks/inventorySnapshots.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/tasks/inventorySnapshots.go b/internal/tasks/inventorySnapshots.go index af82881..779b80d 100644 --- a/internal/tasks/inventorySnapshots.go +++ b/internal/tasks/inventorySnapshots.go @@ -132,7 +132,10 @@ func (c *CronTask) RunVcenterSnapshotHourly(ctx context.Context, logger *slog.Lo if err != nil { return err } - minIntervalSeconds := intWithDefault(c.Settings.Values.Settings.VcenterInventorySnapshotSeconds, 3600) / 2 + minIntervalSeconds := intWithDefault(c.Settings.Values.Settings.VcenterInventorySnapshotSeconds, 3600) / 3 + if minIntervalSeconds < 1 { + minIntervalSeconds = 1 + } if !lastSnapshot.IsZero() && startTime.Sub(lastSnapshot) < time.Duration(minIntervalSeconds)*time.Second { c.Logger.Info("Skipping hourly snapshot, last snapshot too recent", "last_snapshot", lastSnapshot, @@ -1524,8 +1527,8 @@ func (c *CronTask) compareWithPreviousSnapshot( if tableUpdated { prevTableTouched = true } - expectedSeconds := int64(c.Settings.Values.Settings.VcenterInventorySnapshotSeconds) / 2 - // Skip only if snapshots are closer together than half the configured cadence + expectedSeconds := int64(c.Settings.Values.Settings.VcenterInventorySnapshotSeconds) / 3 + // Skip only if snapshots are closer together than one-third of the configured cadence if SnapshotTooSoon(prevSnapshotTime, startTime.Unix(), expectedSeconds) { c.Logger.Info("skipping new-VM detection because snapshots are too close together", "prev_table", prevTableName, "prev_snapshot_unix", prevSnapshotTime, "current_snapshot_unix", startTime.Unix(), "expected_interval_seconds", expectedSeconds) } else {