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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Recheck guest Docker inventory after checker setup
rcourtman83e8f53ac5f6
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.mdindex c03e4268ff..13dfa8bbb4 100644--- a/docs/release-control/v6/internal/subsystems/monitoring.md+++ b/docs/release-control/v6/internal/subsystems/monitoring.md@@ -202,7 +202,11 @@ truth for live infrastructure data.host-side `pct` / `lxc-attach` failures are probe errors and must not beconverted into cached `HasDocker=false` results. Negative Docker detectionsmay be rechecked on a short cadence so command enrollment, daemon startup,- or transient Proxmox access failures do not hide later inventory.+ or transient Proxmox access failures do not hide later inventory. Negative+ detections from before the current Docker checker configuration must be+ rechecked after monitor/router startup, so explicit guest Docker inventory+ can repopulate immediately after backend restarts instead of waiting for the+ normal negative-cache cadence.15. Add or change mock-mode Discovery context through the canonical mockfixture graph. Mock Discovery records must be derived from the same authoredstate graph as mock nodes, guests, Docker hosts, containers, and Kubernetesdiff --git a/internal/monitoring/canonical_guardrails_test.go b/internal/monitoring/canonical_guardrails_test.goindex 64a867da47..6e0013ba55 100644--- a/internal/monitoring/canonical_guardrails_test.go+++ b/internal/monitoring/canonical_guardrails_test.go@@ -910,6 +910,8 @@ func TestProxmoxGuestDockerInventoryUsesCanonicalReportIngestPath(t *testing.T)"type DockerInventoryCollector interface {","proxmoxGuestDockerSocketMarker","proxmoxGuestDockerNegativeRecheckAfter",+ "dockerCheckerConfiguredAt",+ "checker_reconfigured","func (m *Monitor) CollectProxmoxGuestDockerInventory(ctx context.Context, containers []models.Container) {","m.hasOnlineHostAgentForContainer(ct.ID)","m.ApplyDockerReport(report, nil)",@@ -946,6 +948,45 @@ func TestProxmoxGuestDockerInventoryUsesCanonicalReportIngestPath(t *testing.T)}}+func TestProxmoxGuestDockerDetectionRechecksNegativeCacheAfterCheckerSetup(t *testing.T) {+ configuredAt := time.Now()+ monitor := &Monitor{}+ container := models.Container{+ ID: "pve-a:node-a:101",+ VMID: 101,+ Name: "docker-lxc",+ Node: "node-a",+ Status: "running",+ Uptime: 7200,+ }++ reason := monitor.containerNeedsDockerCheck(container, map[string]models.Container{+ container.ID: {+ ID: container.ID,+ Status: "running",+ Uptime: 3600,+ HasDocker: false,+ DockerCheckedAt: configuredAt.Add(-time.Minute),+ },+ }, configuredAt)+ if reason != "checker_reconfigured" {+ t.Fatalf("reason = %q, want checker_reconfigured", reason)+ }++ reason = monitor.containerNeedsDockerCheck(container, map[string]models.Container{+ container.ID: {+ ID: container.ID,+ Status: "running",+ Uptime: 3600,+ HasDocker: false,+ DockerCheckedAt: configuredAt.Add(time.Minute),+ },+ }, configuredAt)+ if reason != "" {+ t.Fatalf("fresh negative cache reason = %q, want empty", reason)+ }+}+func TestProxmoxGuestDockerLXCProbingRequiresExplicitOptIn(t *testing.T) {requiredSnippets := map[string][]string{"../config/config.go": {diff --git a/internal/monitoring/docker_detection.go b/internal/monitoring/docker_detection.goindex 962ce7ea5f..8caa316e93 100644--- a/internal/monitoring/docker_detection.go+++ b/internal/monitoring/docker_detection.go@@ -66,6 +66,7 @@ type containerDockerResult struct {func (m *Monitor) CheckContainersForDocker(ctx context.Context, containers []models.Container) []models.Container {m.mu.RLock()checker := m.dockerChecker+ checkerConfiguredAt := m.dockerCheckerConfiguredAtm.mu.RUnlock()if checker == nil {@@ -91,7 +92,7 @@ func (m *Monitor) CheckContainersForDocker(ctx context.Context, containers []mod}// Check if this container needs Docker detection- reason := m.containerNeedsDockerCheck(ct, previousContainers)+ reason := m.containerNeedsDockerCheck(ct, previousContainers, checkerConfiguredAt)if reason != "" {needsCheck = append(needsCheck, containerDockerCheck{index: i,@@ -148,7 +149,7 @@ func (m *Monitor) CheckContainersForDocker(ctx context.Context, containers []mod// containerNeedsDockerCheck determines if a running container needs Docker checking.// Returns the reason for checking, or empty string if no check is needed.-func (m *Monitor) containerNeedsDockerCheck(ct models.Container, previousContainers map[string]models.Container) string {+func (m *Monitor) containerNeedsDockerCheck(ct models.Container, previousContainers map[string]models.Container, checkerConfiguredAt time.Time) string {prev, existed := previousContainers[ct.ID]// New container - never seen before@@ -161,6 +162,10 @@ func (m *Monitor) containerNeedsDockerCheck(ct models.Container, previousContainreturn "first_check"}+ if !prev.HasDocker && !checkerConfiguredAt.IsZero() && prev.DockerCheckedAt.Before(checkerConfiguredAt) {+ return "checker_reconfigured"+ }+// Negative Docker checks can be transient during agent command enrollment,// Proxmox token rotation, or Docker daemon startup. Recheck them on a short// cadence so a single false result does not hide Docker-in-LXC inventory@@ -1136,8 +1141,10 @@ func (m *Monitor) SetDockerChecker(checker DockerChecker) {defer m.mu.Unlock()m.dockerChecker = checkerif checker != nil {+ m.dockerCheckerConfiguredAt = time.Now()log.Info().Msg("Docker detection enabled for LXC containers")} else {+ m.dockerCheckerConfiguredAt = time.Time{}log.Info().Msg("Docker detection disabled for LXC containers")}}diff --git a/internal/monitoring/docker_detection_test.go b/internal/monitoring/docker_detection_test.goindex 5a852a25f9..395d285c6f 100644--- a/internal/monitoring/docker_detection_test.go+++ b/internal/monitoring/docker_detection_test.go@@ -821,10 +821,11 @@ func TestContainerNeedsDockerCheck(t *testing.T) {}tests := []struct {- name string- container models.Container- previous map[string]models.Container- wantReason string+ name string+ container models.Container+ previous map[string]models.Container+ checkerConfiguredAt time.Time+ wantReason string}{{name: "new container",@@ -870,6 +871,21 @@ func TestContainerNeedsDockerCheck(t *testing.T) {},wantReason: "negative_cache_expired",},+ {+ name: "recheck negative docker result from previous checker generation",+ container: models.Container{ID: "ct-1", Status: "running", Uptime: 7200},+ previous: map[string]models.Container{+ "ct-1": {+ ID: "ct-1",+ Status: "running",+ Uptime: 3600,+ HasDocker: false,+ DockerCheckedAt: time.Now().Add(-time.Minute),+ },+ },+ checkerConfiguredAt: time.Now(),+ wantReason: "checker_reconfigured",+ },{name: "keep fresh negative docker result",container: models.Container{ID: "ct-1", Status: "running", Uptime: 7200},@@ -910,7 +926,7 @@ func TestContainerNeedsDockerCheck(t *testing.T) {for _, tt := range tests {t.Run(tt.name, func(t *testing.T) {- reason := monitor.containerNeedsDockerCheck(tt.container, tt.previous)+ reason := monitor.containerNeedsDockerCheck(tt.container, tt.previous, tt.checkerConfiguredAt)if reason != tt.wantReason {t.Errorf("Expected reason %q, got %q", tt.wantReason, reason)}diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.goindex ec61fb19f0..68528235ae 100644--- a/internal/monitoring/monitor.go+++ b/internal/monitoring/monitor.go@@ -1014,28 +1014,29 @@ type Monitor struct {guestMetadataHoldDuration time.DurationguestAgentWorkSlots chan struct{}// Configurable guest agent timeouts (refs #592)- guestAgentFSInfoTimeout time.Duration- guestAgentNetworkTimeout time.Duration- guestAgentOSInfoTimeout time.Duration- guestAgentVersionTimeout time.Duration- guestAgentRetries int- guestAgentVMBudget time.Duration- executor PollExecutor- breakerBaseRetry time.Duration- breakerMaxDelay time.Duration- breakerHalfOpenWindow time.Duration- instanceInfoCache map[string]*instanceInfo- pollStatusMap map[string]*pollStatus- dlqInsightMap map[string]*dlqInsight- nodeLastOnline map[string]time.Time // Track last time each node was seen online (for grace period)- nodePendingUpdatesCache map[string]pendingUpdatesCache // Cache pending updates per node (checked every 30 min)- resourceStore ResourceStoreInterface // Optional unified resource store for polling optimization- supplementalProviders map[unifiedresources.DataSource]MonitorSupplementalRecordsProvider- recoveryManager *recoverymanager.Manager // Optional recovery store manager for backup rollups- mockMetricsCancel context.CancelFunc- mockMetricsWg sync.WaitGroup- dockerChecker DockerChecker // Optional Docker checker for LXC containers- dockerInventoryCollector DockerInventoryCollector // Optional Docker inventory collector for LXC containers+ guestAgentFSInfoTimeout time.Duration+ guestAgentNetworkTimeout time.Duration+ guestAgentOSInfoTimeout time.Duration+ guestAgentVersionTimeout time.Duration+ guestAgentRetries int+ guestAgentVMBudget time.Duration+ executor PollExecutor+ breakerBaseRetry time.Duration+ breakerMaxDelay time.Duration+ breakerHalfOpenWindow time.Duration+ instanceInfoCache map[string]*instanceInfo+ pollStatusMap map[string]*pollStatus+ dlqInsightMap map[string]*dlqInsight+ nodeLastOnline map[string]time.Time // Track last time each node was seen online (for grace period)+ nodePendingUpdatesCache map[string]pendingUpdatesCache // Cache pending updates per node (checked every 30 min)+ resourceStore ResourceStoreInterface // Optional unified resource store for polling optimization+ supplementalProviders map[unifiedresources.DataSource]MonitorSupplementalRecordsProvider+ recoveryManager *recoverymanager.Manager // Optional recovery store manager for backup rollups+ mockMetricsCancel context.CancelFunc+ mockMetricsWg sync.WaitGroup+ dockerChecker DockerChecker // Optional Docker checker for LXC containers+ dockerCheckerConfiguredAt time.Time // Last time the Docker checker was configured+ dockerInventoryCollector DockerInventoryCollector // Optional Docker inventory collector for LXC containers// Agent profile cache to avoid disk I/O on every report (refs #1094)agentProfileCacheMu sync.RWMutexagentProfileCache *agentProfileCacheEntry