Adjust snapshot interval calculations to use one-third of the configured cadence
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user