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.

Summarize relationship edges in timelines

rcourtmanbb89be0b7017
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 95c481439f..59217a79bd 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -131,6 +131,10 @@ Relationship-change timeline entries also preserve the affected graph endpoints
in `relatedResources`, so the canonical history keeps enough context for the
detail drawer and audit views to explain which neighboring resources moved with
the change.
+For relationship changes, the `from` and `to` fields now summarize the actual
+edge(s) rather than only the parent pointer, so the API contract keeps the
+graph transition legible even before the frontend expands the related-resource
+chips.
Invalid `sourceAdapter` values are rejected at the API boundary, so the filter
contract stays aligned with the canonical adapter set rather than silently
falling back to an empty slice.
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index c5952d4d66..c8f3c92dc8 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -88,6 +88,9 @@ Relationship-change timeline records now keep the affected graph endpoints in
`relatedResources`, so the durable history preserves the same graph context the
detail drawer can surface later instead of collapsing relationship changes down
to parent-only hints.
+Those same relationship changes now summarize the actual edge(s) in `from` and
+`to`, so the canonical timeline keeps the graph transition readable without
+needing the drawer to reconstruct an edge summary from raw endpoints.
That store also now migrates legacy `resource_changes` tables that still carry
the pre-v6 `timestamp` column by backfilling canonical `observed_at` values,
adding the newer `occurred_at` field, and preserving the legacy timestamp on
diff --git a/internal/unifiedresources/change_emission.go b/internal/unifiedresources/change_emission.go
index ecb5686b49..141a5ecb6b 100644
--- a/internal/unifiedresources/change_emission.go
+++ b/internal/unifiedresources/change_emission.go
@@ -4,6 +4,7 @@ import (
"fmt"
"log"
"reflect"
+ "sort"
"strings"
"time"
@@ -250,6 +251,9 @@ func resourceStateSummary(resource Resource) string {
}
func resourceRelationSummary(resource Resource) string {
+ if summary := resourceRelationshipSummary(resource.Relationships); summary != "" {
+ return summary
+ }
parentID := ""
if resource.ParentID != nil {
parentID = strings.TrimSpace(*resource.ParentID)
@@ -260,6 +264,48 @@ func resourceRelationSummary(resource Resource) string {
return parentID
}
+func resourceRelationshipSummary(relationships []ResourceRelationship) string {
+ if len(relationships) == 0 {
+ return ""
+ }
+
+ summaries := make([]string, 0, len(relationships))
+ for _, relationship := range relationships {
+ sourceID := CanonicalResourceID(relationship.SourceID)
+ targetID := CanonicalResourceID(relationship.TargetID)
+ if sourceID == "" && targetID == "" {
+ continue
+ }
+
+ label := sourceID
+ if label == "" {
+ label = "?"
+ }
+ label += "->"
+ if targetID == "" {
+ label += "?"
+ } else {
+ label += targetID
+ }
+ if relationship.Type != "" {
+ label += fmt.Sprintf("[%s]", relationship.Type)
+ }
+ summaries = append(summaries, label)
+ }
+
+ if len(summaries) == 0 {
+ return ""
+ }
+ sort.Strings(summaries)
+ if len(summaries) == 1 {
+ return summaries[0]
+ }
+ if len(summaries) <= 3 {
+ return strings.Join(summaries, ", ")
+ }
+ return fmt.Sprintf("%d relationships", len(summaries))
+}
+
func resourceConfigSummary(resource Resource) string {
return fmt.Sprintf("%s|%s|%s|%s", resource.Type, resource.Technology, resource.Name, resource.CustomURL)
}
diff --git a/internal/unifiedresources/change_emission_test.go b/internal/unifiedresources/change_emission_test.go
index 2672e781e9..cc7d716b55 100644
--- a/internal/unifiedresources/change_emission_test.go
+++ b/internal/unifiedresources/change_emission_test.go
@@ -65,6 +65,9 @@ func TestBuildResourceChange_ClassifiesRelationshipChangeAndIncludesEndpoints(t
if change.Kind != ChangeRelationship {
t.Fatalf("Kind = %q, want %q", change.Kind, ChangeRelationship)
}
+ if change.From != "vm:1->db:1[depends_on]" || change.To != "vm:1->db:2[depends_on]" {
+ t.Fatalf("From/To = %q/%q, want vm:1->db:1[depends_on]/vm:1->db:2[depends_on]", change.From, change.To)
+ }
if !sameStringSet(change.RelatedResources, []string{"db:1", "db:2"}) {
t.Fatalf("RelatedResources = %+v, want db:1 and db:2", change.RelatedResources)
}
diff --git a/internal/unifiedresources/code_standards_test.go b/internal/unifiedresources/code_standards_test.go
index eebfa957ca..fa6f69ce84 100644
--- a/internal/unifiedresources/code_standards_test.go
+++ b/internal/unifiedresources/code_standards_test.go
@@ -293,6 +293,7 @@ func TestResourceChangeEmissionCoversRelationshipAndCapabilityChanges(t *testing
"changed = append(changed, \"relationships\")",
"if !reflect.DeepEqual(before.Capabilities, after.Capabilities) {",
"changed = append(changed, \"capabilities\")",
+ "resourceRelationshipSummary(relationships []ResourceRelationship)",
}
for _, snippet := range requiredSnippets {
if !strings.Contains(source, snippet) {