Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Surface Docker-in-LXC probe failures and stop the probe churn

rcourtman2483dbed9c14
diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md
index 3645dcc03d..54fe050a03 100644
--- a/docs/CONFIGURATION.md
+++ b/docs/CONFIGURATION.md
@@ -329,7 +329,7 @@ When `allowEmbedding` is `false`, Pulse sends `X-Frame-Options: DENY` and `frame
| `PULSE_DISABLE_DOCKER_UPDATE_ACTIONS` | Hide Docker update buttons (read-only mode) | `false` |
| `PULSE_ENABLE_PROXMOX_GUEST_DOCKER_DETECTION` | Allow Proxmox-side LXC Docker socket hinting with `pct exec` | `false` |
| `PULSE_ENABLE_PROXMOX_GUEST_DOCKER_INVENTORY` | Allow Proxmox-side minimal LXC Docker inventory collection with `pct exec`; collects Docker host/container summary, not inspect/env/mount/process data | `false` |
-| `PULSE_PROXMOX_GUEST_DOCKER_INVENTORY_VMIDS` | Optional comma-separated VMID allowlist for Proxmox-side LXC Docker inventory; empty means all running Docker-enabled LXCs are eligible when inventory is enabled | *(unset)* |
+| `PULSE_PROXMOX_GUEST_DOCKER_INVENTORY_VMIDS` | Optional comma-separated VMID allowlist for Proxmox-side LXC Docker discovery; when set, only these guests are socket-probed and inventoried. Empty means all running LXCs are eligible when detection or inventory is enabled | *(unset)* |
| `PULSE_TELEMETRY` | Outbound usage telemetry ([details](PRIVACY.md)); set `false` to disable | `true` |
| `PULSE_DEPLOYMENT_METHOD` | Optional closed telemetry label: `docker_compose`, `docker_run`, `container_other`, `systemd`, `binary_other`, or `other`; invalid values are reported only as the safe runtime fallback | Inferred as `container_other` or `binary_other` |
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index af63724e53..3fcf4a25d1 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -1992,9 +1992,17 @@ the intentionally sparse public response.
it cannot use: `lxc-attach` needs `CAP_SETUID` to write `/proc/<pid>/uid_map`
for unprivileged guests, and without it the Docker socket probe fails with
`write_id_mapping: 61 Operation not permitted` for every unprivileged LXC.
- Because that probe failure is debug-level and retried each poll, the
- resulting surface is silently incomplete rather than visibly broken, so the
- capability must be provisioned up front rather than diagnosed later.
+ The monitoring server must surface that failure mode instead of hiding it:
+ the first probe failure of a streak, and the point where the retry backoff
+ reaches its cap, log at warn with the guest, node, and error, and failed
+ probes retry with exponential backoff (one minute doubling to a
+ thirty-minute ceiling) instead of re-running `pct exec` on every poll.
+ Reconfiguring the checker resets the backoff so command execution enabled
+ at runtime retries immediately. A warn log is diagnosis, not discovery, so
+ the capability must still be provisioned up front rather than diagnosed
+ later. The `PULSE_PROXMOX_GUEST_DOCKER_INVENTORY_VMIDS` allowlist must gate
+ the socket probe as well as inventory collection, so opting into specific
+ guests never leaves every other guest probed each cycle.
Persistence-sensitive NAS targets must keep one canonical continuity model here: installer-owned bootstraps may use flash-backed or immutable-root launch hooks only as thin trampolines, while the durable wrapper, state, and reboot-surviving binary copy stay in the governed persistent state directory that updater continuity also refreshes.
Unix `--update` re-entry must also preserve lifecycle identity for legacy
v5.1.x agents that do not yet have v6 `connection.env` state. When a
diff --git a/frontend-modern/public/docs/CONFIGURATION.md b/frontend-modern/public/docs/CONFIGURATION.md
index 3645dcc03d..54fe050a03 100644
--- a/frontend-modern/public/docs/CONFIGURATION.md
+++ b/frontend-modern/public/docs/CONFIGURATION.md
@@ -329,7 +329,7 @@ When `allowEmbedding` is `false`, Pulse sends `X-Frame-Options: DENY` and `frame
| `PULSE_DISABLE_DOCKER_UPDATE_ACTIONS` | Hide Docker update buttons (read-only mode) | `false` |
| `PULSE_ENABLE_PROXMOX_GUEST_DOCKER_DETECTION` | Allow Proxmox-side LXC Docker socket hinting with `pct exec` | `false` |
| `PULSE_ENABLE_PROXMOX_GUEST_DOCKER_INVENTORY` | Allow Proxmox-side minimal LXC Docker inventory collection with `pct exec`; collects Docker host/container summary, not inspect/env/mount/process data | `false` |
-| `PULSE_PROXMOX_GUEST_DOCKER_INVENTORY_VMIDS` | Optional comma-separated VMID allowlist for Proxmox-side LXC Docker inventory; empty means all running Docker-enabled LXCs are eligible when inventory is enabled | *(unset)* |
+| `PULSE_PROXMOX_GUEST_DOCKER_INVENTORY_VMIDS` | Optional comma-separated VMID allowlist for Proxmox-side LXC Docker discovery; when set, only these guests are socket-probed and inventoried. Empty means all running LXCs are eligible when detection or inventory is enabled | *(unset)* |
| `PULSE_TELEMETRY` | Outbound usage telemetry ([details](PRIVACY.md)); set `false` to disable | `true` |
| `PULSE_DEPLOYMENT_METHOD` | Optional closed telemetry label: `docker_compose`, `docker_run`, `container_other`, `systemd`, `binary_other`, or `other`; invalid values are reported only as the safe runtime fallback | Inferred as `container_other` or `binary_other` |
diff --git a/internal/api/router.go b/internal/api/router.go
index 43105f0cbf..5aa2c9cd62 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -1728,11 +1728,13 @@ func (r *Router) configureProxmoxGuestDockerDetection(m *monitoring.Monitor) {
detectionEnabled := r.config != nil && (r.config.EnableProxmoxGuestDockerDetection || inventoryEnabled)
if !detectionEnabled {
m.SetDockerChecker(nil)
+ m.SetDockerCheckerAllowedVMIDs(nil)
m.SetDockerInventoryCollector(nil)
return
}
if r.agentExecServer == nil {
m.SetDockerChecker(nil)
+ m.SetDockerCheckerAllowedVMIDs(nil)
m.SetDockerInventoryCollector(nil)
return
}
@@ -1754,15 +1756,20 @@ func (r *Router) configureProxmoxGuestDockerDetection(m *monitoring.Monitor) {
return result.Stdout + result.Stderr, result.ExitCode, nil
}
+ allowedVMIDs, invalidVMIDs := monitoring.ParseProxmoxGuestDockerInventoryVMIDs(r.config.ProxmoxGuestDockerInventoryVMIDs)
+ if len(invalidVMIDs) > 0 {
+ log.Warn().
+ Strs("invalidVmids", invalidVMIDs).
+ Msg("[Router] Ignoring invalid Proxmox guest Docker inventory VMID allowlist entries")
+ }
+
checker := monitoring.NewAgentDockerChecker(execFunc)
m.SetDockerChecker(checker)
+ // The allowlist gates the socket probe as well as inventory collection:
+ // opting into specific guests must not leave every other guest probed via
+ // pct exec on each poll cycle.
+ m.SetDockerCheckerAllowedVMIDs(allowedVMIDs)
if inventoryEnabled {
- allowedVMIDs, invalidVMIDs := monitoring.ParseProxmoxGuestDockerInventoryVMIDs(r.config.ProxmoxGuestDockerInventoryVMIDs)
- if len(invalidVMIDs) > 0 {
- log.Warn().
- Strs("invalidVmids", invalidVMIDs).
- Msg("[Router] Ignoring invalid Proxmox guest Docker inventory VMID allowlist entries")
- }
m.SetDockerInventoryCollector(monitoring.NewAgentDockerInventoryCollector(execFunc, monitoring.AgentDockerInventoryCollectorOptions{
AllowedVMIDs: allowedVMIDs,
}))
diff --git a/internal/monitoring/docker_detection.go b/internal/monitoring/docker_detection.go
index 54718f6281..76f90414ba 100644
--- a/internal/monitoring/docker_detection.go
+++ b/internal/monitoring/docker_detection.go
@@ -20,8 +20,27 @@ const (
proxmoxGuestDockerInventoryMarker = "PULSE_DOCKER_GUEST_INVENTORY_V1"
proxmoxGuestDockerSocketMarker = "PULSE_DOCKER_SOCKET"
proxmoxGuestDockerNegativeRecheckAfter = 5 * time.Minute
+
+ // A probe that errors (as opposed to succeeding with "no docker") is
+ // retried with exponential backoff instead of on every poll cycle: a
+ // persistent failure such as an agent token without agent:exec or an
+ // lxc-attach that cannot enter the guest would otherwise re-run pct exec
+ // against every affected guest forever.
+ proxmoxGuestDockerProbeFailureBackoffBase = time.Minute
+ proxmoxGuestDockerProbeFailureBackoffMax = 30 * time.Minute
+ // Failure entries not touched for this long belong to guests that no
+ // longer exist (a live failing guest refreshes its entry at least once
+ // per backoff window) and are pruned.
+ proxmoxGuestDockerProbeFailurePruneAfter = 24 * time.Hour
)
+// dockerProbeFailureState tracks consecutive Docker socket probe failures for
+// one LXC container.
+type dockerProbeFailureState struct {
+ failures int
+ lastAt time.Time
+}
+
// DockerChecker provides the ability to check for Docker inside LXC containers.
// This is typically implemented by wrapping the agentexec.Server.
type DockerChecker interface {
@@ -68,12 +87,15 @@ func (m *Monitor) CheckContainersForDocker(ctx context.Context, containers []mod
m.mu.RLock()
checker := m.dockerChecker
checkerConfiguredAt := m.dockerCheckerConfiguredAt
+ allowedVMIDs := m.dockerCheckAllowedVMIDs
m.mu.RUnlock()
if checker == nil {
return containers
}
+ m.pruneDockerProbeFailures()
+
// Get previous container state for comparison
previousContainers := make(map[string]models.Container)
for _, ct := range m.state.GetContainers() {
@@ -94,6 +116,16 @@ func (m *Monitor) CheckContainersForDocker(ctx context.Context, containers []mod
// Check if this container needs Docker detection
reason := m.containerNeedsDockerCheck(ct, previousContainers, checkerConfiguredAt)
+ if reason != "" && len(allowedVMIDs) > 0 {
+ if _, ok := allowedVMIDs[ct.VMID]; !ok {
+ // Outside the explicit VMID allowlist: never probe.
+ reason = ""
+ }
+ }
+ if reason != "" && m.dockerProbeInFailureBackoff(ct.ID) {
+ // A recent probe failure is still inside its backoff window.
+ reason = ""
+ }
if reason != "" {
needsCheck = append(needsCheck, containerDockerCheck{
index: i,
@@ -127,6 +159,7 @@ func (m *Monitor) CheckContainersForDocker(ctx context.Context, containers []mod
if result.hasDocker {
dockerCount++
}
+ m.clearDockerProbeFailure(containers[result.index])
} else if result.err != nil {
// Check failed - preserve previous status if available
ct := containers[result.index]
@@ -134,6 +167,7 @@ func (m *Monitor) CheckContainersForDocker(ctx context.Context, containers []mod
containers[result.index].HasDocker = prev.HasDocker
containers[result.index].DockerCheckedAt = prev.DockerCheckedAt
}
+ m.recordDockerProbeFailure(ct, result.err)
}
}
@@ -190,6 +224,109 @@ func (m *Monitor) containerNeedsDockerCheck(ct models.Container, previousContain
return ""
}
+// dockerProbeFailureBackoff returns how long to wait after the given number of
+// consecutive probe failures before trying again.
+func dockerProbeFailureBackoff(failures int) time.Duration {
+ if failures <= 0 {
+ return 0
+ }
+ backoff := proxmoxGuestDockerProbeFailureBackoffBase
+ for i := 1; i < failures; i++ {
+ backoff *= 2
+ if backoff >= proxmoxGuestDockerProbeFailureBackoffMax {
+ return proxmoxGuestDockerProbeFailureBackoffMax
+ }
+ }
+ return backoff
+}
+
+// dockerProbeInFailureBackoff reports whether a container's last probe failure
+// is still inside its backoff window.
+func (m *Monitor) dockerProbeInFailureBackoff(containerID string) bool {
+ m.dockerProbeFailureMu.Lock()
+ defer m.dockerProbeFailureMu.Unlock()
+ state, ok := m.dockerProbeFailures[containerID]
+ if !ok {
+ return false
+ }
+ return time.Since(state.lastAt) < dockerProbeFailureBackoff(state.failures)
+}
+
+// recordDockerProbeFailure notes a failed Docker socket probe. The first
+// failure of a streak logs at warn so a default install surfaces why
+// Docker-in-LXC discovery is incomplete; repeats log at debug, escalating to
+// warn once more when the retry backoff reaches its cap.
+func (m *Monitor) recordDockerProbeFailure(ct models.Container, err error) {
+ m.dockerProbeFailureMu.Lock()
+ if m.dockerProbeFailures == nil {
+ m.dockerProbeFailures = make(map[string]*dockerProbeFailureState)
+ }
+ state, ok := m.dockerProbeFailures[ct.ID]
+ if !ok {
+ state = &dockerProbeFailureState{}
+ m.dockerProbeFailures[ct.ID] = state
+ }
+ state.failures++
+ state.lastAt = time.Now()
+ failures := state.failures
+ m.dockerProbeFailureMu.Unlock()
+
+ backoff := dockerProbeFailureBackoff(failures)
+ justCapped := backoff == proxmoxGuestDockerProbeFailureBackoffMax &&
+ dockerProbeFailureBackoff(failures-1) != proxmoxGuestDockerProbeFailureBackoffMax
+ event := log.Debug()
+ if failures == 1 || justCapped {
+ event = log.Warn()
+ }
+ event.
+ Err(err).
+ Str("container", ct.Name).
+ Int("vmid", ct.VMID).
+ Str("node", ct.Node).
+ Int("consecutiveFailures", failures).
+ Dur("retryAfter", backoff).
+ Msg("Docker socket probe failed for LXC container; retrying with backoff")
+}
+
+// clearDockerProbeFailure drops any recorded failure streak for a container
+// after a successful probe.
+func (m *Monitor) clearDockerProbeFailure(ct models.Container) {
+ m.dockerProbeFailureMu.Lock()
+ state, ok := m.dockerProbeFailures[ct.ID]
+ if ok {
+ delete(m.dockerProbeFailures, ct.ID)
+ }
+ m.dockerProbeFailureMu.Unlock()
+ if ok && state.failures > 0 {
+ log.Info().
+ Str("container", ct.Name).
+ Int("vmid", ct.VMID).
+ Str("node", ct.Node).
+ Int("previousFailures", state.failures).
+ Msg("Docker socket probe recovered for LXC container")
+ }
+}
+
+// pruneDockerProbeFailures removes failure entries for containers that have
+// not been probed in a long time (guests that were removed while failing).
+func (m *Monitor) pruneDockerProbeFailures() {
+ m.dockerProbeFailureMu.Lock()
+ defer m.dockerProbeFailureMu.Unlock()
+ for id, state := range m.dockerProbeFailures {
+ if time.Since(state.lastAt) > proxmoxGuestDockerProbeFailurePruneAfter {
+ delete(m.dockerProbeFailures, id)
+ }
+ }
+}
+
+// resetDockerProbeFailures clears all failure streaks, so a reconfigured
+// checker retries every guest immediately.
+func (m *Monitor) resetDockerProbeFailures() {
+ m.dockerProbeFailureMu.Lock()
+ defer m.dockerProbeFailureMu.Unlock()
+ m.dockerProbeFailures = nil
+}
+
// checkDockerParallel checks Docker for multiple containers in parallel
func (m *Monitor) checkDockerParallel(ctx context.Context, checker DockerChecker, checks []containerDockerCheck) []containerDockerResult {
results := make([]containerDockerResult, len(checks))
@@ -1139,17 +1276,45 @@ func ParseProxmoxGuestDockerInventoryVMIDs(raw string) (map[int]struct{}, []stri
// for new containers and containers that have restarted.
func (m *Monitor) SetDockerChecker(checker DockerChecker) {
m.mu.Lock()
- defer m.mu.Unlock()
m.dockerChecker = checker
if checker != nil {
m.dockerCheckerConfiguredAt = time.Now()
- log.Info().Msg("Docker detection enabled for LXC containers")
} else {
m.dockerCheckerConfiguredAt = time.Time{}
+ }
+ m.mu.Unlock()
+ // Reconfiguration (for example command execution newly enabled on an
+ // agent) is exactly when a failing probe deserves an immediate retry.
+ m.resetDockerProbeFailures()
+ if checker != nil {
+ log.Info().Msg("Docker detection enabled for LXC containers")
+ } else {
log.Info().Msg("Docker detection disabled for LXC containers")
}
}
+// SetDockerCheckerAllowedVMIDs restricts the LXC Docker socket probe to the
+// supplied Proxmox VMIDs. A nil or empty set means every running LXC guest is
+// eligible. The filter applies before a probe is scheduled, so guests outside
+// an explicit inventory allowlist are never pct exec'd at all.
+func (m *Monitor) SetDockerCheckerAllowedVMIDs(allowed map[int]struct{}) {
+ var filtered map[int]struct{}
+ if len(allowed) > 0 {
+ filtered = make(map[int]struct{}, len(allowed))
+ for vmid := range allowed {
+ if vmid > 0 {
+ filtered[vmid] = struct{}{}
+ }
+ }
+ if len(filtered) == 0 {
+ filtered = nil
+ }
+ }
+ m.mu.Lock()
+ defer m.mu.Unlock()
+ m.dockerCheckAllowedVMIDs = filtered
+}
+
// GetDockerChecker returns the current Docker checker, if configured.
func (m *Monitor) GetDockerChecker() DockerChecker {
m.mu.RLock()
diff --git a/internal/monitoring/docker_detection_test.go b/internal/monitoring/docker_detection_test.go
index 395d285c6f..3f2f508e33 100644
--- a/internal/monitoring/docker_detection_test.go
+++ b/internal/monitoring/docker_detection_test.go
@@ -2,6 +2,7 @@ package monitoring
import (
"context"
+ "errors"
"strings"
"sync"
"testing"
@@ -13,7 +14,8 @@ import (
// mockDockerChecker is a test implementation of DockerChecker
type mockDockerChecker struct {
- results map[int]bool // vmid -> hasDocker
+ results map[int]bool // vmid -> hasDocker
+ errs map[int]error // vmid -> probe error
mu sync.Mutex
calls []int // records vmids that were checked
}
@@ -22,12 +24,21 @@ func (m *mockDockerChecker) CheckDockerInContainer(ctx context.Context, node str
m.mu.Lock()
m.calls = append(m.calls, vmid)
m.mu.Unlock()
+ if err, ok := m.errs[vmid]; ok {
+ return false, err
+ }
if hasDocker, ok := m.results[vmid]; ok {
return hasDocker, nil
}
return false, nil
}
+func (m *mockDockerChecker) callCount() int {
+ m.mu.Lock()
+ defer m.mu.Unlock()
+ return len(m.calls)
+}
+
func TestCheckContainersForDocker_NewContainers(t *testing.T) {
// Create a monitor with state
state := models.NewState()
@@ -933,3 +944,148 @@ func TestContainerNeedsDockerCheck(t *testing.T) {
})
}
}
+
+func TestCheckContainersForDocker_VMIDAllowlistGatesProbe(t *testing.T) {
+ state := models.NewState()
+ monitor := &Monitor{state: state}
+ checker := &mockDockerChecker{
+ results: map[int]bool{101: true, 102: true},
+ }
+ monitor.SetDockerChecker(checker)
+ monitor.SetDockerCheckerAllowedVMIDs(map[int]struct{}{101: {}})
+
+ containers := []models.Container{
+ {ID: "ct-1", VMID: 101, Name: "allowed", Node: "node1", Status: "running"},
+ {ID: "ct-2", VMID: 102, Name: "excluded", Node: "node1", Status: "running"},
+ }
+
+ result := monitor.CheckContainersForDocker(context.Background(), containers)
+
+ if got := checker.callCount(); got != 1 {
+ t.Fatalf("expected only the allowlisted guest to be probed, got %d probes", got)
+ }
+ if len(checker.calls) != 1 || checker.calls[0] != 101 {
+ t.Fatalf("expected probe of VMID 101 only, got %v", checker.calls)
+ }
+ for i := range result {
+ switch result[i].ID {
+ case "ct-1":
+ if !result[i].HasDocker || result[i].DockerCheckedAt.IsZero() {
+ t.Errorf("allowlisted container should have been probed and marked")
+ }
+ case "ct-2":
+ if result[i].HasDocker || !result[i].DockerCheckedAt.IsZero() {
+ t.Errorf("excluded container must not be probed or marked")
+ }
+ }
+ }
+
+ // Clearing the allowlist re-enables probing for every guest.
+ monitor.SetDockerCheckerAllowedVMIDs(nil)
+ monitor.CheckContainersForDocker(context.Background(), containers)
+ if got := checker.callCount(); got != 3 {
+ t.Fatalf("expected both guests probed after clearing allowlist, got %d total probes", got)
+ }
+}
+
+func TestCheckContainersForDocker_FailedProbeBacksOff(t *testing.T) {
+ state := models.NewState()
+ monitor := &Monitor{state: state}
+ checker := &mockDockerChecker{
+ errs: map[int]error{101: errors.New("write_id_mapping: Operation not permitted")},
+ }
+ monitor.SetDockerChecker(checker)
+
+ containers := []models.Container{
+ {ID: "ct-1", VMID: 101, Name: "failing", Node: "node1", Status: "running"},
+ }
+
+ // First poll: probe runs and fails.
+ monitor.CheckContainersForDocker(context.Background(), containers)
+ if got := checker.callCount(); got != 1 {
+ t.Fatalf("expected 1 probe on first poll, got %d", got)
+ }
+
+ // Immediate next polls: still inside the backoff window, no re-probe.
+ monitor.CheckContainersForDocker(context.Background(), containers)
+ monitor.CheckContainersForDocker(context.Background(), containers)
+ if got := checker.callCount(); got != 1 {
+ t.Fatalf("expected failed probe to back off, got %d probes", got)
+ }
+
+ // Rewind the failure timestamp past the first backoff window: retries.
+ monitor.dockerProbeFailureMu.Lock()
+ monitor.dockerProbeFailures["ct-1"].lastAt = time.Now().Add(-2 * proxmoxGuestDockerProbeFailureBackoffBase)
+ monitor.dockerProbeFailureMu.Unlock()
+ monitor.CheckContainersForDocker(context.Background(), containers)
+ if got := checker.callCount(); got != 2 {
+ t.Fatalf("expected retry after backoff expiry, got %d probes", got)
+ }
+ monitor.dockerProbeFailureMu.Lock()
+ failures := monitor.dockerProbeFailures["ct-1"].failures
+ monitor.dockerProbeFailureMu.Unlock()
+ if failures != 2 {
+ t.Fatalf("expected 2 consecutive failures recorded, got %d", failures)
+ }
+
+ // Probe starts succeeding: streak clears and result applies.
+ checker.errs = nil
+ checker.results = map[int]bool{101: true}
+ monitor.dockerProbeFailureMu.Lock()
+ monitor.dockerProbeFailures["ct-1"].lastAt = time.Now().Add(-time.Hour)
+ monitor.dockerProbeFailureMu.Unlock()
+ result := monitor.CheckContainersForDocker(context.Background(), containers)
+ if !result[0].HasDocker {
+ t.Fatalf("expected successful probe to mark HasDocker")
+ }
+ monitor.dockerProbeFailureMu.Lock()
+ _, stillTracked := monitor.dockerProbeFailures["ct-1"]
+ monitor.dockerProbeFailureMu.Unlock()
+ if stillTracked {
+ t.Fatalf("expected failure streak to clear after success")
+ }
+}
+
+func TestSetDockerCheckerResetsProbeFailureBackoff(t *testing.T) {
+ state := models.NewState()
+ monitor := &Monitor{state: state}
+ checker := &mockDockerChecker{
+ errs: map[int]error{101: errors.New("agent token not authorized for command execution")},
+ }
+ monitor.SetDockerChecker(checker)
+
+ containers := []models.Container{
+ {ID: "ct-1", VMID: 101, Name: "failing", Node: "node1", Status: "running"},
+ }
+ monitor.CheckContainersForDocker(context.Background(), containers)
+ monitor.CheckContainersForDocker(context.Background(), containers)
+ if got := checker.callCount(); got != 1 {
+ t.Fatalf("expected backoff after first failure, got %d probes", got)
+ }
+
+ // Reconfiguring the checker (e.g. commands newly enabled) retries at once.
+ monitor.SetDockerChecker(checker)
+ monitor.CheckContainersForDocker(context.Background(), containers)
+ if got := checker.callCount(); got != 2 {
+ t.Fatalf("expected immediate retry after checker reconfiguration, got %d probes", got)
+ }
+}
+
+func TestDockerProbeFailureBackoffSchedule(t *testing.T) {
+ cases := []struct {
+ failures int
+ want time.Duration
+ }{
+ {0, 0},
+ {1, proxmoxGuestDockerProbeFailureBackoffBase},
+ {2, 2 * proxmoxGuestDockerProbeFailureBackoffBase},
+ {5, 16 * proxmoxGuestDockerProbeFailureBackoffBase},
+ {6, proxmoxGuestDockerProbeFailureBackoffMax},
+ {100, proxmoxGuestDockerProbeFailureBackoffMax},
+ }
+ for _, tc := range cases {
+ if got := dockerProbeFailureBackoff(tc.failures); got != tc.want {
+ t.Errorf("backoff(%d) = %v, want %v", tc.failures, got, tc.want)
+ }
+ }
+}
diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go
index 4fb71dc1de..4b912b31f4 100644
--- a/internal/monitoring/monitor.go
+++ b/internal/monitoring/monitor.go
@@ -1186,7 +1186,12 @@ type Monitor struct {
mockMetricsWg sync.WaitGroup
dockerChecker DockerChecker // Optional Docker checker for LXC containers
dockerCheckerConfiguredAt time.Time // Last time the Docker checker was configured
+ dockerCheckAllowedVMIDs map[int]struct{} // Optional VMID allowlist gating the LXC Docker socket probe; empty means all guests
dockerInventoryCollector DockerInventoryCollector // Optional Docker inventory collector for LXC containers
+ // Consecutive Docker socket probe failures per container ID, so persistent
+ // failures back off instead of re-running pct exec on every poll cycle.
+ dockerProbeFailureMu sync.Mutex
+ dockerProbeFailures map[string]*dockerProbeFailureState
// Agent profile cache to avoid disk I/O on every report (refs #1094)
agentProfileCacheMu sync.RWMutex
agentProfileCache *agentProfileCacheEntry