mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-02 10:09:02 +01:00
A guest-agent command caught by a freeze can leave a stale reply that the thaw reads as "got wrong command id", so every command Pulse doesn't send removes a chance of that (#2439). For a guest whose linked Pulse agent is current, the get-fsinfo reading was thrown away later in the same poll, in favour of the agent's inventory. The check asks the same question as the code that replaces the reading, so the read stops only where it would have been discarded. An agent that is stale, offline, unlinked or reporting no usable disks keeps the read. The poll that loses the agent reads at once, and if that read fails the row shows the failure rather than an old agent reading. Metadata and memory reads are unchanged, so guest-agent evidence and the expected-unreachable incident keep working for a guest that answers them. A current agent now counts as a healthy-guest signal for memory retention, as a new filesystem reply did. The cost: a guest that answers only get-fsinfo loses that evidence after ten minutes, and a replication run shows deferred only on polls whose metadata or memory read hits it. A config lock still shows deferred.
56 lines
1.8 KiB
Go
56 lines
1.8 KiB
Go
package monitoring
|
|
|
|
import "github.com/rcourtman/pulse-go-rewrite/internal/models"
|
|
|
|
func resolveGuestDiskFromLinkedHostAgent(guestID string, vmIDToHostAgent map[string]models.Host) (models.Disk, []models.Disk, bool) {
|
|
if guestID == "" || len(vmIDToHostAgent) == 0 {
|
|
return models.Disk{}, nil, false
|
|
}
|
|
|
|
host, ok := vmIDToHostAgent[guestID]
|
|
if !ok {
|
|
return models.Disk{}, nil, false
|
|
}
|
|
|
|
summary, ok := models.AggregateDisk(host.Disks)
|
|
if !ok {
|
|
return models.Disk{}, nil, false
|
|
}
|
|
|
|
disks := append([]models.Disk(nil), host.Disks...)
|
|
return models.Disk{
|
|
Total: summary.Total,
|
|
Used: summary.Used,
|
|
Free: summary.Free,
|
|
Usage: summary.Usage,
|
|
Mountpoint: summary.Mountpoint,
|
|
Type: summary.Type,
|
|
Device: summary.Device,
|
|
}, disks, true
|
|
}
|
|
|
|
// linkedHostAgentSuppliesGuestDisks reports whether preferLinkedHostAgentDiskInventory
|
|
// will replace this poll's reading with the linked agent's inventory.
|
|
func linkedHostAgentSuppliesGuestDisks(guestID string, vmIDToHostAgent map[string]models.Host) bool {
|
|
summary, _, ok := resolveGuestDiskFromLinkedHostAgent(guestID, vmIDToHostAgent)
|
|
return ok && summary.Total > 0
|
|
}
|
|
|
|
func preferLinkedHostAgentDiskInventory(
|
|
guestID string,
|
|
vmIDToHostAgent map[string]models.Host,
|
|
diskTotal uint64,
|
|
diskUsed uint64,
|
|
diskFree uint64,
|
|
diskUsage float64,
|
|
individualDisks []models.Disk,
|
|
diskStatusReason string,
|
|
) (uint64, uint64, uint64, float64, []models.Disk, string, bool) {
|
|
summary, hostDisks, ok := resolveGuestDiskFromLinkedHostAgent(guestID, vmIDToHostAgent)
|
|
if !ok || summary.Total <= 0 {
|
|
return diskTotal, diskUsed, diskFree, diskUsage, individualDisks, diskStatusReason, false
|
|
}
|
|
|
|
return uint64(summary.Total), uint64(summary.Used), uint64(summary.Free), summary.Usage, hostDisks, "", true
|
|
}
|