fix: Clear node host agent link when agent is removed

When a host agent is deleted via the UI, the LinkedHostAgentID on any
PVE nodes that were linked to it was not being cleared. This caused
the "Agent" tag to persist in the UI after uninstalling the agent.

Related to #920
This commit is contained in:
rcourtman 2025-12-26 17:52:32 +00:00
parent 7f5ea636db
commit cf577e715f
2 changed files with 28 additions and 0 deletions

View file

@ -1210,6 +1210,15 @@ func (m *Monitor) RemoveHostAgent(hostID string) (models.Host, error) {
m.state.RemoveConnectionHealth(hostConnectionPrefix + hostID)
// Clear LinkedHostAgentID from any nodes that were linked to this host agent
unlinkedCount := m.state.UnlinkNodesFromHostAgent(hostID)
if unlinkedCount > 0 {
log.Info().
Str("hostID", hostID).
Int("unlinkedNodes", unlinkedCount).
Msg("Cleared host agent links from PVE nodes")
}
log.Info().
Str("host", host.Hostname).
Str("hostID", hostID).