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
Merge origin/main into fix/link-fold-references
rcourtman860b5087d2fa
diff --cc docs/release-control/v6/internal/subsystems/unified-resources.mdindex 73c93c7c70,abf7035f3a..43a510e262--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@@ -6567,44 -6654,55 +6654,83 @@@ separatesystem's facet, and the system's pools re-parent to the merged row.- The registry remembers each resource a manual link folded into itsprimary. A folded resource is still observed, so neither pin-driven nor- record-declared succession may succeed its ID. An agent-type primary- carries the folded resource's machine keys and is pinned with them, and- succeeding the folded ID re-keyed the link onto the primary itself, which- split the pair on the next rebuild. That already broke snapshot links whose- primary is a machine-keyless agent-type row, such as a Proxmox node.+ record-declared succession may succeed its ID: that re-keyed the link onto+ the primary itself, which split the pair on the next rebuild, and already+ broke snapshot links whose primary is a machine-keyless agent-type row,+ such as a Proxmox node.+ - Each side of a link is pinned only from its own identity, captured when+ the link first joins it in a rebuild (`recordLinkOwnPin`). A side with no+ pinnable identity (not agent-shaped, or no strong key) writes no pin, and+ a pinnable folded side keeps its pin under its own canonical ID. The merged+ primary used to be pinned with both sides' keys, and the store's+ one-owner-per-key rule then deleted the folded side's pin. A Proxmox node's+ pin records its qualified endpoint as the hostname, so the node's next+ rebuild completed the linked agent's machine key from that merged pin,+ minted the agent's machine-derived ID and merged with the agent by ID+ before the link applied. With the node as primary, succession then+ rewrote the link into a self-link on the agent's ID; in either direction,+ removing the link left the pair merged.+ - A link side rewrites its whole row (`ReplaceResourceIdentityPins`)+ instead of upserting it. Like an upsert it keeps the stored fields its+ own pin leaves empty, so evidence from an earlier observation survives a+ weaker one, but it never keeps a machine, DMI or cluster-and-hostname key+ another resource holds this rebuild, including a cluster key a kept+ hostname would complete. That is how a key an earlier release borrowed+ into the row from the merged identity leaves it; a key a resource reports+ now also beats one a link side's row only kept, as the store already+ hands a moved key to the new pin. The store gives each strong key one+ owner and deletes any other row holding a key a written pin carries, so a+ folded side drops each own key held by a live non-link resource's+ upserted row (an upsert cannot drop a field), a live link side's own pin,+ or a folded side earlier in canonical-ID order. It writes no pin when no+ strong key is left, or when it would lose the machine or DMI key it+ reports: a cluster-only row reads as a machine-keyless host's, which+ cluster-slot succession lets a later machine in that slot absorb. A row kept for a side that writes no pin goes+ when another written pin carries one of its keys, such as the folded+ agent's own pin carrying the machine key an earlier release borrowed into+ a Proxmox node's row. That hand-back only reaches a row the node cannot+ complete from: while the node's qualified endpoint, or its cluster and+ name, still resolve to that row, completion supplies the borrowed key+ before any link applies, so the pair merges by ID and succession rewrites+ the link into a self-link, as it did before this change. A link side whose+ row loses a borrowed machine key becomes a machine-keyless row, open to+ the cluster-slot succession any machine-keyless host gets. Two live resources that share a strong key+ still take it from each other on alternate rebuilds, as before. Evidence+ a later record pass of the same rebuild merges into an already-joined row+ reaches neither side's pin.-- Fold history is registry-local: resource seeding and overlay clones do not- carry it. A reference to the folded resource's canonical ID, such as an- availability check configured against an agent later linked into its- guest, does not resolve to the primary, so the check loses its target in- the broadcast as it already did in the resources API.+- A folded resource's canonical ID resolves to the primary holding it. The+ merged resource carries its folded IDs in memory, including IDs folded+ into those along a chain of links, and resource seeding indexes them. The+ monitor's rebuild, a registry seeded from its listing (the resources API,+ which then replays availability checks) and a read-state overlay therefore+ resolve them alike. The index follows the holding rows, so a holder that a+ later link merges away or that is re-keyed in place keeps the answer+ consistent. An availability check configured against an agent later+ linked into its guest lands on the merged row, as a check configured+ against the primary would. "A manual link keeps only the primary's own+ checks" still holds: the merge never carries the folded resource's+ projected checks; only the check's own reference resolves again.+ `ResolveReferenceID` and `GetByReference` follow the fold as well, as the+ folded agent's alert reference (`agent:<host ID>`) already did through the+ merged row's canonical aliases. Alert intent, operator-state reads and+ writes through the resources API and API lookups by the folded ID+ therefore reach the merged row. Patrol's finding auto-acknowledgement+ still reads a row stored under the exact reference first, so an+ operator-state row kept under the folded ID applies there. History does+ not follow the fold: a history binding persists, and+ `expandHistoryAliases` walks bindings in both directions, so binding a+ folded ID would join the two journals for good. Folded IDs are never+ `SupersededCanonicalIDs`, which alert-configuration and availability-link+ migrations rewrite permanently; the stored link stays as the operator+ wrote it. A live row with a folded ID answers for itself. Two rows holding+ one folded ID resolve to neither, without falling through to weaker+ matches such as a hostname alias. Folds ride in-memory clones only; a+ serialized listing loses them, as it loses source parents.+ `availability_link_test.go` pins both link directions through two+ rebuilds in all three registries+ (`TestAvailabilityLinkToALinkFoldedResourceFollowsItsPrimary`), a chain+ (`TestAvailabilityLinkFollowsChainedLinkFolds`) and the index cases+ (`TestLinkFoldIndexFollowsItsHolders`).`registry_merge_policy_test.go` pins the record links in both directionsthrough two rebuilds and the live supplemental refresh, and checks that adiff --cc internal/unifiedresources/registry.goindex 93545322c1,86d97f396b..3081fb6980--- a/internal/unifiedresources/registry.go+++ b/internal/unifiedresources/registry.go@@@ -96,15 -95,16 +96,21 @@@ type ResourceRegistry structexclusions map[string]struct{}identityPins *identityPinIndexpbsBackups []models.PBSBackup- // linkMergedIDs holds the resources a manual link folded into their- // primary. They are still observed, so identity succession treats them- // as live.- linkMergedIDs map[string]struct{}+ // linkFoldIndex maps each canonical ID a manual link folded into another+ // resource to the rows that took it in (Resource.linkFoldedIDs). Folded+ // resources are still observed, so identity succession treats them as+ // live, and references to them resolve to the row holding them. Holders+ // carry their folds, so a registry seeded from another registry's listing+ // indexes the same ones. Entries are rows, not IDs, and are checked on+ // read (linkFoldHoldersLocked): a holder folded away, replaced or re-keyed+ // needs no bookkeeping.+ linkFoldIndex map[string][]*Resource+ // linkOwnPins holds the identity pin each side of a manual link derives+ // from its own sources, captured before the link merged them. A nil+ // value records a side with no pinnable identity. PersistIdentityPins+ // writes these instead of the merged projection, so a link never lends+ // one machine's identity keys to another resource's durable pin.+ linkOwnPins map[string]*ResourceIdentityPin// supersededIndex maps record-declared retired canonical IDs to the live// resource that superseded them, so references persisted under a retired// ID (availability links, API reads) keep resolving. An empty value marks@@@ -4900,23 -4854,36 +4912,43 @@@ func (rr *ResourceRegistry) applyManualprimaryID, otherID = otherID, primaryID}+ rr.recordLinkOwnPin(primaryID, primary)+ rr.recordLinkOwnPin(otherID, other)rr.mergeResourceData(primary, other, thresholds)delete(rr.resources, otherID)- if rr.linkMergedIDs == nil {- rr.linkMergedIDs = make(map[string]struct{})- }- rr.linkMergedIDs[otherID] = struct{}{}+ rr.foldLinkedResourceLocked(primary, otherID, other)rr.updateSourceMappings(otherID, primaryID)}}+// foldLinkedResourceLocked records on the link primary the resource folded+// into it and every ID earlier links folded into that resource, so a chain of+// links resolves to its last primary. The folded row has left the registry,+// so its own index entries lapse on read.+func (rr *ResourceRegistry) foldLinkedResourceLocked(primary *Resource, otherID string, other *Resource) {+ folded := append([]string{otherID}, other.linkFoldedIDs...)+ primary.linkFoldedIDs = uniqueTrimmed(append(append([]string(nil), primary.linkFoldedIDs...), folded...)...)+ rr.indexLinkFoldedIDsLocked(primary, folded)+}++ // recordLinkOwnPin captures the identity pin a manual-link side derives from+ // its own sources, before the link merge projects the other side's identity+ // onto the primary. The first capture in a registry generation wins, so a+ // primary that absorbs several links keeps the pin it had before any of them.+ func (rr *ResourceRegistry) recordLinkOwnPin(id string, resource *Resource) {+ if _, recorded := rr.linkOwnPins[id]; recorded {+ return+ }+ if rr.linkOwnPins == nil {+ rr.linkOwnPins = make(map[string]*ResourceIdentityPin)+ }+ if pin, ok := identityPinForResource(resource); ok {+ rr.linkOwnPins[id] = &pin+ return+ }+ rr.linkOwnPins[id] = nil+ }+func (rr *ResourceRegistry) mergeResourceData(primary *Resource, other *Resource, thresholds map[DataSource]time.Duration) {if other == nil || primary == nil {return