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.

Preserve installed credentials while preparing agent command access

pulse-triage[bot]3760b288929f
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 653ee593a4..1d3b8a3283 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -224,9 +224,15 @@ this host** and sits in the token step, before the credential is minted,
instead of behind the advanced connection options as "Enable legacy combined
command profile". The behaviour behind it is unchanged: default off, an
explicit choice adds `--enable-commands`, records `command-capable`, and mints
-an execution-scoped token; toggling after a mint still regenerates and revokes
-the superseded token, and a `monitoring-only` install still cannot be promoted
-remotely. The old name told the users who need Docker/Podman updates not to
+an execution-scoped token. Toggling after a mint prepares a replacement without
+revoking earlier tokens: a displayed token may already be installed and reporting.
+The new token and its command flags are admitted together; commands stay locked
+while minting, and a failed mint restores the previous complete state. Preparing
+a replacement does not change an installed agent's local command access or any
+existing token's scopes. Rerunning the installer on the intended host is still
+required; explicit token revocation stays in Tokens after checking no agent still
+uses it. A `monitoring-only` install still cannot be promoted remotely.
+The old name told the users who need Docker/Podman updates not to
use the only working route: Docker updates dispatch through the agent command
session, the separate action runner's container actions are unqualified, and
rootful Docker under the safe collector profile carries no update checks or
@@ -234,7 +240,13 @@ actions. The label is owned by `getUnifiedAgentCommandAccessOptionLabel`, which
the locked Docker update pill and the Proxmox setup guide also read, so copy
that sends users to it cannot drift from the checkbox.
`InfrastructureInstallerSection.test.tsx` pins the checkbox in the token step
-with its root-access description.
+with its root-access and replacement descriptions.
+`useInfrastructureOperationsState.branchcov0722pm.test.tsx` exercises atomic
+replacement and failed-mint rollback, including both command-access directions
+without deleting an already-displayed token. `InfrastructureOperationsModel.test.tsx`
+keeps preparation free of the token deletion API. Browser proof exercises the
+actual Infrastructure consumer and token/lookup HTTP fixtures, not native agent
+installation, service-start diagnosis or installed recovery.
### Manual update checks skip images with no registry tag (21 October 2026)
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 959a2c3584..5ad0f49905 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -5153,6 +5153,19 @@ the authoritative analysis outcome.
install-state surface must describe that prepared token path consistently
with the live runtime behavior rather than directing the operator to create
another install token manually.
+ Preparing a different command-access scope through `/api/agent-install-command`
+ must not delete the previous install token through `/api/security/tokens/{id}`.
+ A returned or revealed credential may already be reporting from an installed
+ host; absence of local usage evidence is not evidence it is unused. Minting
+ a replacement preserves the old credential and its scopes. Command flags
+ and the replacement credential become available atomically, or the complete
+ previous command state is restored on failure. The installer explains that
+ preparation does not reconfigure an installed agent and that deliberate
+ revocation belongs in Tokens only after checking no agent still uses it.
+ `InfrastructureOperationsModel.test.tsx`,
+ `useInfrastructureOperationsState.branchcov0722pm.test.tsx` and
+ `InfrastructureInstallerSection.test.tsx` cover this consuming boundary;
+ native service recovery remains separate.
24. Keep connected-infrastructure surface vocabulary canonical across the
shared `/api/state` and reporting/install consumers:
`frontend-modern/src/types/api.ts` must treat `truenas` as a first-class
diff --git a/frontend-modern/src/components/Settings/InfrastructureInstallerSection.tsx b/frontend-modern/src/components/Settings/InfrastructureInstallerSection.tsx
index d0df4c5c04..f43c1a882c 100644
--- a/frontend-modern/src/components/Settings/InfrastructureInstallerSection.tsx
+++ b/frontend-modern/src/components/Settings/InfrastructureInstallerSection.tsx
@@ -368,7 +368,7 @@ export const InfrastructureInstallerSection: Component<InfrastructureInstallerSe
checked={state.enableCommands()}
disabled={state.isGeneratingToken()}
onChange={(event) => void state.setEnableCommands(event.currentTarget.checked)}
- aria-describedby="install-command-access-description"
+ aria-describedby="install-command-access-description install-token-replacement-description"
class="mt-0.5 rounded-sm text-blue-600 focus:ring-blue-500"
/>
{COMMAND_ACCESS_OPTION_LABEL}
@@ -379,6 +379,12 @@ export const InfrastructureInstallerSection: Component<InfrastructureInstallerSe
if you only want monitoring. It cannot be switched on later from Pulse: rerun the
install command with this selected.
</p>
+ <p id="install-token-replacement-description" class="ml-6 mt-2 text-xs text-muted">
+ Changing this choice prepares a new token and command; it does not reconfigure an
+ installed agent. Rerun the installer on the intended host with the new token. Earlier
+ tokens remain valid. Revoke them from Settings → Infrastructure → Tokens only when no
+ agent still uses them.
+ </p>
</div>
<div class="flex gap-2">
diff --git a/frontend-modern/src/components/Settings/__tests__/InfrastructureInstallerSection.test.tsx b/frontend-modern/src/components/Settings/__tests__/InfrastructureInstallerSection.test.tsx
index 8991dbd5e2..c0483405a4 100644
--- a/frontend-modern/src/components/Settings/__tests__/InfrastructureInstallerSection.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/InfrastructureInstallerSection.test.tsx
@@ -67,6 +67,9 @@ describe('InfrastructureInstallerSection', () => {
expect(checkbox).toHaveAccessibleDescription(
/update, start, stop or restart Docker and Podman containers.*run commands as root/,
);
+ expect(checkbox).toHaveAccessibleDescription(
+ /prepares a new token and command.*does not reconfigure an installed agent.*Earlier tokens remain valid.*only when no agent still uses them/,
+ );
expect(
screen.getByText(
'Monitoring only. Pulse cannot run commands or change containers on this host.',
diff --git a/frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsModel.test.tsx b/frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsModel.test.tsx
index bae7390eda..cf6dba8d98 100644
--- a/frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsModel.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/InfrastructureOperationsModel.test.tsx
@@ -455,7 +455,10 @@ describe('infrastructure operations model', () => {
'setEnableCommands(previousEnableCommands);',
);
expect(useInfrastructureInstallStateSource).toContain('setCurrentToken(supersededToken);');
+ expect(useInfrastructureInstallStateSource).not.toContain('SecurityAPI.deleteToken');
expect(infrastructureInstallerSectionSource).toContain('disabled={state.isGeneratingToken()}');
+ expect(infrastructureInstallerSectionSource).toContain('does not reconfigure an installed');
+ expect(infrastructureInstallerSectionSource).toContain('Earlier tokens remain valid.');
});
it('keeps infrastructure install and operations surfaces free of retired commercial telemetry wrappers', () => {
diff --git a/frontend-modern/src/components/Settings/__tests__/useInfrastructureOperationsState.branchcov0722pm.test.tsx b/frontend-modern/src/components/Settings/__tests__/useInfrastructureOperationsState.branchcov0722pm.test.tsx
index 0a3fe7187c..66a3bdb49b 100644
--- a/frontend-modern/src/components/Settings/__tests__/useInfrastructureOperationsState.branchcov0722pm.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/useInfrastructureOperationsState.branchcov0722pm.test.tsx
@@ -463,10 +463,56 @@ describe('useInfrastructureOperationsState command-building closures', () => {
expect(state.currentToken()).toBe('tok-command');
expect(state.commandsUnlocked()).toBe(true);
- expect(mocks.securityDeleteToken).toHaveBeenCalledWith('rec-1');
+ expect(mocks.securityDeleteToken).not.toHaveBeenCalled();
dispose();
});
+ it.each([false, true])(
+ 'keeps an already-installed credential valid when preparing command access from %s',
+ async (previousEnableCommands) => {
+ const { state, dispose } = mountHook();
+ await flushAsync();
+ await state.setEnableCommands(previousEnableCommands);
+ await state.handleGenerateToken();
+
+ // Once revealed, the token may already be reporting from a host. The
+ // install workspace cannot infer that a replaced token is unused.
+ const installedTokens = new Set([state.currentToken()]);
+ mocks.securityDeleteToken.mockImplementation(async () => {
+ installedTokens.delete('tok-1');
+ });
+ mocks.createHostAgentInstallToken.mockResolvedValueOnce({
+ token: 'tok-replacement',
+ record: {
+ id: 'rec-replacement',
+ name: 'Replacement agent token',
+ prefix: 'pul',
+ suffix: 'next',
+ createdAt: '2026-11-02',
+ },
+ });
+
+ await state.setEnableCommands(!previousEnableCommands);
+
+ expect(state.enableCommands()).toBe(!previousEnableCommands);
+ expect(state.currentToken()).toBe('tok-replacement');
+ expect(state.commandsUnlocked()).toBe(true);
+ expect(mocks.createHostAgentInstallToken).toHaveBeenLastCalledWith({
+ enableCommands: !previousEnableCommands,
+ name: expect.any(String),
+ });
+ expect(installedTokens.has('tok-1')).toBe(true);
+ expect(mocks.securityDeleteToken).not.toHaveBeenCalled();
+ const linuxCommand = state
+ .commandSections()
+ .find((section) => section.platform === 'linux');
+ expect(
+ unixBootstrapTestSource(linuxCommand!.snippets[0].command).includes('--enable-commands'),
+ ).toBe(!previousEnableCommands);
+ dispose();
+ },
+ );
+
it('restores the previous complete command state when replacement minting fails', async () => {
const { state, dispose } = mountHook();
await flushAsync();
diff --git a/frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx b/frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx
index a928b3c359..1cf9db03d8 100644
--- a/frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx
+++ b/frontend-modern/src/components/Settings/useInfrastructureInstallState.tsx
@@ -373,18 +373,13 @@ Pulse prepares the first-host install token from setup so you can move straight
notificationStore.info(
value
- ? 'Token regenerated with command execution permission. Copy the install command again.'
- : 'Token regenerated without command execution permission. Copy the install command again.',
+ ? 'New token prepared with command execution permission. Existing tokens remain valid. Rerun the install command on the intended host.'
+ : 'New token prepared without command execution permission. Existing tokens remain valid. Rerun the install command on the intended host.',
5000,
);
- // The superseded token was never handed to an agent; revoke it so
- // toggling does not accumulate orphaned install tokens.
- const supersededTokenId = supersededRecord?.id;
- if (supersededTokenId && supersededTokenId !== latestRecord()?.id) {
- SecurityAPI.deleteToken(supersededTokenId).catch((err) => {
- logger.warn('Failed to revoke superseded install token', err);
- });
- }
+ // A displayed token may already be installed on a reporting host. Preparing
+ // a different scope does not prove it is unused and must not revoke it.
+ // Deliberate revocation stays in Tokens, after the operator checks its use.
};
const resolvedCommandToken = () => {