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.

Give remediation context the same actionable detail as chat

rcourtman35ae43ca4861
diff --git a/internal/servicediscovery/formatters.go b/internal/servicediscovery/formatters.go
index 1a2ddb1fe4..eae7a36693 100644
--- a/internal/servicediscovery/formatters.go
+++ b/internal/servicediscovery/formatters.go
@@ -326,6 +326,23 @@ func FormatForRemediation(d *ResourceDiscovery) string {
sb.WriteString("\n\n")
}
+ // Service control — how to restart/reload the workload, the core remediation
+ // action. Previously remediation context surfaced only hardware facts, so it
+ // never told you how to actually restart the thing it was helping you fix.
+ var serviceFacts []DiscoveryFact
+ for _, f := range d.Facts {
+ if f.Category == FactCategoryService {
+ serviceFacts = append(serviceFacts, f)
+ }
+ }
+ if len(serviceFacts) > 0 {
+ sb.WriteString("### Service Control\n")
+ for _, f := range serviceFacts {
+ sb.WriteString(fmt.Sprintf("- %s: %s\n", f.Key, f.Value))
+ }
+ sb.WriteString("\n")
+ }
+
// Config paths for potential fixes
if len(d.ConfigPaths) > 0 {
sb.WriteString("### Configuration Files\n")
@@ -335,6 +352,21 @@ func FormatForRemediation(d *ResourceDiscovery) string {
sb.WriteString("\n")
}
+ // Bind mounts — edit or back up persistent files at the HOST source; the
+ // container only sees the destination path, so without this a fix written
+ // "to /config" would not survive a container recreate.
+ if len(d.DockerMounts) > 0 {
+ sb.WriteString("### Bind Mounts (host -> container)\n")
+ for _, m := range d.DockerMounts {
+ line := fmt.Sprintf("- `%s` -> `%s`", m.Source, m.Destination)
+ if m.ReadOnly {
+ line += " (read-only)"
+ }
+ sb.WriteString(line + "\n")
+ }
+ sb.WriteString("\n")
+ }
+
// Log paths for troubleshooting
if len(d.LogPaths) > 0 {
sb.WriteString("### Log Files\n")
diff --git a/internal/servicediscovery/formatters_test.go b/internal/servicediscovery/formatters_test.go
index 62cf78b6a5..fd7b43c79e 100644
--- a/internal/servicediscovery/formatters_test.go
+++ b/internal/servicediscovery/formatters_test.go
@@ -214,6 +214,37 @@ func TestFormatScopeHint(t *testing.T) {
}
}
+func TestFormatForRemediationSurfacesControlAndMounts(t *testing.T) {
+ d := &ResourceDiscovery{
+ ID: MakeResourceID(ResourceTypeDocker, "nuc", "homeassistant"),
+ ResourceType: ResourceTypeDocker,
+ Hostname: "nuc",
+ ServiceType: "home-assistant",
+ ServiceName: "Home Assistant",
+ CLIAccess: "docker exec homeassistant bash",
+ ConfigPaths: []string{"/config/automations.yaml"},
+ DockerMounts: []DockerBindMount{
+ {ContainerName: "homeassistant", Source: "/opt/ha/config", Destination: "/config", Type: "bind"},
+ },
+ Facts: []DiscoveryFact{
+ {Category: FactCategoryService, Key: "restart", Value: "docker restart homeassistant", Confidence: 0.9},
+ },
+ }
+
+ out := FormatForRemediation(d)
+ // Remediation must tell you how to restart the service and where to edit its
+ // files on the host — the two core fix actions, previously both missing.
+ for _, want := range []string{
+ "docker restart homeassistant", // service-control fact
+ "/opt/ha/config", // host bind-mount source
+ "/config/automations.yaml", // config file to edit
+ } {
+ if !strings.Contains(out, want) {
+ t.Errorf("remediation context missing %q\n--- output ---\n%s", want, out)
+ }
+ }
+}
+
func TestFilterImportantFactsLimit(t *testing.T) {
var facts []DiscoveryFact
for i := 0; i < 10; i++ {