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
Fix agent connection recovery controls
rcourtman1cdb39580189
diff --git a/frontend-modern/src/api/__tests__/connections.branchcov0718.test.ts b/frontend-modern/src/api/__tests__/connections.branchcov0718.test.tsindex 572684ab36..29b7edcd3b 100644--- a/frontend-modern/src/api/__tests__/connections.branchcov0718.test.ts+++ b/frontend-modern/src/api/__tests__/connections.branchcov0718.test.ts@@ -232,20 +232,34 @@ describe('ConnectionsAPI — branch coverage', () => {);});- it('throws Remove-not-yet-supported for a docker connection id', async () => {- await expect(ConnectionsAPI.remove('docker:runtime/1')).rejects.toThrow(- 'Remove is not yet supported for docker connections',- );+ it('docker connection delegates to the runtime delete endpoint with the suffix path', async () => {+ mockedApiFetch.mockResolvedValueOnce({+ ok: true,+ text: () => Promise.resolve(JSON.stringify({ success: true })),+ } as unknown as Response);++ await ConnectionsAPI.remove('docker:runtime/1');+expect(mockedApiFetchJSON).not.toHaveBeenCalled();- expect(mockedApiFetch).not.toHaveBeenCalled();+ expect(mockedApiFetch).toHaveBeenCalledWith(+ '/api/agents/docker/runtimes/runtime%2F1',+ expect.objectContaining({ method: 'DELETE' }),+ );});- it('throws Remove-not-yet-supported for a kubernetes connection id', async () => {- await expect(ConnectionsAPI.remove('kubernetes:cluster/1')).rejects.toThrow(- 'Remove is not yet supported for kubernetes connections',- );+ it('kubernetes connection delegates to the cluster delete endpoint with the suffix path', async () => {+ mockedApiFetch.mockResolvedValueOnce({+ ok: true,+ text: () => Promise.resolve(JSON.stringify({ success: true })),+ } as unknown as Response);++ await ConnectionsAPI.remove('kubernetes:cluster/1');+expect(mockedApiFetchJSON).not.toHaveBeenCalled();- expect(mockedApiFetch).not.toHaveBeenCalled();+ expect(mockedApiFetch).toHaveBeenCalledWith(+ '/api/agents/kubernetes/clusters/cluster%2F1',+ expect.objectContaining({ method: 'DELETE' }),+ );});it('throws Unknown-connection-type for an unrecognized prefix on remove', async () => {diff --git a/frontend-modern/src/api/connections.ts b/frontend-modern/src/api/connections.tsindex d86557b24d..747fe02767 100644--- a/frontend-modern/src/api/connections.ts+++ b/frontend-modern/src/api/connections.ts@@ -304,8 +304,11 @@ export class ConnectionsAPI {await MonitoringAPI.deleteAgent(suffix);return;case 'docker':+ await MonitoringAPI.deleteDockerRuntime(suffix);+ return;case 'kubernetes':- throw new Error(`Remove is not yet supported for ${type} connections`);+ await MonitoringAPI.deleteKubernetesCluster(suffix);+ return;default:throw new Error(`Unknown connection type: ${type}`);}diff --git a/frontend-modern/src/components/Settings/InfrastructureAgentDoctorPage.tsx b/frontend-modern/src/components/Settings/InfrastructureAgentDoctorPage.tsxindex af5fd1270b..0a2f8bcae9 100644--- a/frontend-modern/src/components/Settings/InfrastructureAgentDoctorPage.tsx+++ b/frontend-modern/src/components/Settings/InfrastructureAgentDoctorPage.tsx@@ -14,6 +14,7 @@ import { InlineDetailTableRow } from '@/components/shared/InlineDetailTableRow';import { copyToClipboard } from '@/utils/clipboard';import { formatRelativeTime } from '@/utils/format';import { notificationStore } from '@/stores/notifications';+import { MonitoringAPI } from '@/api/monitoring';import {getUnifiedAgentClipboardCopyErrorMessage,getUnifiedAgentClipboardCopySuccessMessage,@@ -190,6 +191,38 @@ export const InfrastructureAgentDoctorPage: Component<InfrastructureAgentDoctorPconst [expansionOverrides, setExpansionOverrides] = createSignal<ReadonlyMap<string, boolean>>(new Map(),);+ const [reenrollPendingId, setReenrollPendingId] = createSignal('');+ const allowReenroll = async (target: InfrastructureAgentDoctorTarget) => {+ const separator = target.connectionId.indexOf(':');+ const type = separator > 0 ? target.connectionId.slice(0, separator) : '';+ const id = separator > 0 ? target.connectionId.slice(separator + 1) : '';+ if (!id) {+ notificationStore.error('This diagnostic does not include a reconnectable agent ID.');+ return;+ }+ setReenrollPendingId(target.connectionId);+ try {+ if (type === 'docker') {+ await MonitoringAPI.allowDockerRuntimeReenroll(id);+ } else if (type === 'kubernetes') {+ await MonitoringAPI.allowKubernetesClusterReenroll(id);+ } else if (type === 'agent') {+ await MonitoringAPI.allowHostAgentReenroll(id);+ } else {+ throw new Error(`Allow re-enrol is not supported for ${type || 'unknown'} diagnostics.`);+ }+ notificationStore.success(`${target.displayName} can re-enrol on its next report.`);+ await props.onRetryDiagnostics?.();+ } catch (error) {+ notificationStore.error(+ error instanceof Error+ ? error.message+ : `Failed to allow ${target.displayName} to re-enrol.`,+ );+ } finally {+ setReenrollPendingId('');+ }+ };const isExpanded = (target: InfrastructureAgentDoctorTarget) =>expansionOverrides().get(target.connectionId) ?? props.targets.length === 1;const toggleExpanded = (target: InfrastructureAgentDoctorTarget) => {@@ -436,7 +469,12 @@ export const InfrastructureAgentDoctorPage: Component<InfrastructureAgentDoctorP(target.diagnostic?.repairActions ?? []).filter((action) =>action.code !== 'copy_upgrade_command' &&- action.code !== 'repair_authentication',+ action.code !== 'repair_authentication' &&+ action.code !== 'allow_reenroll',+ );+ const canAllowReenroll = () =>+ (target.diagnostic?.repairActions ?? []).some(+ (action) => action.code === 'allow_reenroll' && action.supported,);const uninstallHandoff = () =>getInfrastructureAgentDoctorUninstallHandoff(target);@@ -567,6 +605,28 @@ export const InfrastructureAgentDoctorPage: Component<InfrastructureAgentDoctorP)}</For>+ <Show when={canAllowReenroll()}>+ <div class="rounded-md border border-border bg-surface px-3 py-2 text-xs">+ <div class="font-medium text-base-content">Allow re-enrol</div>+ <div class="mt-0.5 text-muted">+ Clear the removal block so this agent can reconnect on its next+ report.+ </div>+ <Button+ type="button"+ variant="outline"+ size="sm"+ class="mt-2"+ disabled={reenrollPendingId() === target.connectionId}+ onClick={() => void allowReenroll(target)}+ >+ {reenrollPendingId() === target.connectionId+ ? 'Allowing…'+ : 'Allow re-enrol'}+ </Button>+ </div>+ </Show>+<Show when={target.needsUpdate || target.needsCredentialRepair}><Showwhen={!target.commandBlockedReason}