Pulse/internal/monitoring/backup_guard.go
2026-03-18 16:06:30 +00:00

24 lines
745 B
Go

package monitoring
import "strings"
// shouldPreservePBSBackupsWithTerminal preserves stale PBS backups only when all
// datastore fetches failed and at least one failure was non-terminal.
func shouldPreservePBSBackupsWithTerminal(datastoreCount, datastoreFetches, datastoreTerminalFailure int) bool {
if datastoreCount > 0 && datastoreFetches == 0 && datastoreTerminalFailure < datastoreCount {
return true
}
return false
}
// shouldReuseCachedPBSBackups keeps cached data for transient fetch errors and
// avoids reuse for terminal API 4xx errors.
func shouldReuseCachedPBSBackups(err error) bool {
if err == nil {
return false
}
if strings.Contains(strings.ToLower(err.Error()), "api error 4") {
return false
}
return true
}