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.

Bound app-container Patrol scope to selected workloads

rcourtmana83e15176ad1
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index e73ac692b0..4f3483e9c0 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -3538,7 +3538,13 @@ resolve canonical/source IDs and unique aliases before collection, reject
two deliberately different boundaries: its effective evidence scope may
include related hosts, parents, and dependencies for model reasoning, while
its finding-lifecycle scope is the exact resolved caller-requested identity
- set. `patrol_get_findings`, report, assess, and resolve must not refresh or
+ set. An exact app-container scope retains its Docker host as the transport
+ parent and retains the selected container's embedded image, mount, and
+ network-attachment evidence, but it must not re-ingest the host's complete
+ image, volume, network, or Swarm child inventory into the scoped provider.
+ Those unrelated host children are neither dependencies of the selected
+ workload nor permission to turn a targeted check into a host-wide scan.
+ `patrol_get_findings`, report, assess, and resolve must not refresh or
create a finding on a context-only dependency; the model may cite that
dependency as evidence for the requested resource and Pro investigation may
expand causally after Watch is durable. This prevents a targeted workload
diff --git a/internal/ai/patrol_run.go b/internal/ai/patrol_run.go
index cc96b27d1b..f58adadfb9 100644
--- a/internal/ai/patrol_run.go
+++ b/internal/ai/patrol_run.go
@@ -1507,6 +1507,23 @@ func scopePatrolDockerHost(d models.DockerHost, matcher patrolScopeMatcher) (mod
if len(matchedContainers) > 0 {
hostCopy := d
hostCopy.Containers = matchedContainers
+ // A Docker host is the transport parent for its containers, so the
+ // filtered snapshot must retain the host record. It must not, however,
+ // retain the host's complete child inventory. Re-ingesting that inventory
+ // into the scoped unified-resource provider would turn a request for one
+ // container into every image, volume, network, and Swarm object on the
+ // host. The matched container already carries its own image, mounts, and
+ // network attachments as bounded dependency evidence.
+ hostCopy.Images = nil
+ hostCopy.Volumes = nil
+ hostCopy.Networks = nil
+ hostCopy.Services = nil
+ hostCopy.Tasks = nil
+ hostCopy.Nodes = nil
+ hostCopy.Secrets = nil
+ hostCopy.Configs = nil
+ hostCopy.StorageUsage = nil
+ hostCopy.Swarm = nil
included := make([]string, 0, len(matchedContainers))
for _, c := range matchedContainers {
included = append(included, c.ID)
diff --git a/internal/ai/patrol_run_test.go b/internal/ai/patrol_run_test.go
index a28f5783be..e45bd0c944 100644
--- a/internal/ai/patrol_run_test.go
+++ b/internal/ai/patrol_run_test.go
@@ -423,9 +423,27 @@ func TestFilterStateByScope_DockerHost(t *testing.T) {
ID: "dh1",
Hostname: "docker-host-1",
Containers: []models.DockerContainer{
- {ID: "c1", Name: "web"},
+ {
+ ID: "c1",
+ Name: "web",
+ Image: "example/web:latest",
+ Networks: []models.DockerContainerNetworkLink{{Name: "frontend"}},
+ Mounts: []models.DockerContainerMount{{Type: "volume", Name: "web-data"}},
+ },
{ID: "c2", Name: "db"},
},
+ Images: []models.DockerImage{{ID: "sha256:web", RepoTags: []string{"example/web:latest"}}, {ID: "sha256:db", RepoTags: []string{"example/db:latest"}}},
+ Volumes: []models.DockerVolume{{Name: "web-data"}, {Name: "db-data"}},
+ Networks: []models.DockerNetwork{{ID: "network-frontend", Name: "frontend"}, {ID: "network-backend", Name: "backend"}},
+ Services: []models.DockerService{{ID: "service-web", Name: "web"}},
+ Tasks: []models.DockerTask{{ID: "task-web", ContainerID: "c1"}},
+ Nodes: []models.DockerNode{{ID: "node-1", Hostname: "docker-host-1"}},
+ Secrets: []models.DockerSecret{{ID: "secret-web", Name: "web-secret"}},
+ Configs: []models.DockerConfig{{ID: "config-web", Name: "web-config"}},
+ StorageUsage: &models.DockerStorageUsage{
+ Images: models.DockerStorageUsageBucket{TotalCount: 2},
+ },
+ Swarm: &models.DockerSwarmInfo{LocalState: "active"},
},
},
}
@@ -475,6 +493,26 @@ func TestFilterStateByScope_DockerContainerOnly(t *testing.T) {
if filtered.DockerHosts[0].Containers[0].ID != "c1" {
t.Errorf("expected container c1, got %s", filtered.DockerHosts[0].Containers[0].ID)
}
+ filteredHost := filtered.DockerHosts[0]
+ if len(filteredHost.Images) != 0 || len(filteredHost.Volumes) != 0 || len(filteredHost.Networks) != 0 ||
+ len(filteredHost.Services) != 0 || len(filteredHost.Tasks) != 0 || len(filteredHost.Nodes) != 0 ||
+ len(filteredHost.Secrets) != 0 || len(filteredHost.Configs) != 0 || filteredHost.StorageUsage != nil || filteredHost.Swarm != nil {
+ t.Fatalf("container scope retained unrelated host inventory: %+v", filteredHost)
+ }
+ for _, resourceType := range []unifiedresources.ResourceType{
+ unifiedresources.ResourceTypeDockerImage,
+ unifiedresources.ResourceTypeDockerVolume,
+ unifiedresources.ResourceTypeDockerNetwork,
+ unifiedresources.ResourceTypeDockerService,
+ unifiedresources.ResourceTypeDockerTask,
+ unifiedresources.ResourceTypeDockerSwarmNode,
+ unifiedresources.ResourceTypeDockerSecret,
+ unifiedresources.ResourceTypeDockerConfig,
+ } {
+ if got := len(filtered.unifiedResourceProvider.GetByType(resourceType)); got != 0 {
+ t.Fatalf("container scope retained %d unrelated %s resources", got, resourceType)
+ }
+ }
}
func TestFilterStateByScope_Storage(t *testing.T) {