Daemon: scope relaxed systemd probes to install flows

This commit is contained in:
Vincent Koc
2026-03-07 16:45:18 -08:00
parent fcb990e369
commit 0d66834f94
6 changed files with 102 additions and 19 deletions

View File

@@ -256,4 +256,27 @@ describe("runDaemonInstall", () => {
expect(installDaemonServiceAndEmitMock).toHaveBeenCalledTimes(1);
expect(actionState.warnings.some((warning) => warning.includes("Auto-generated"))).toBe(true);
});
it("continues Linux install when service probe hits a non-fatal systemd bus failure", async () => {
service.isLoaded.mockRejectedValueOnce(
new Error("systemctl is-enabled unavailable: Failed to connect to bus"),
);
await runDaemonInstall({ json: true });
expect(actionState.failed).toEqual([]);
expect(installDaemonServiceAndEmitMock).toHaveBeenCalledTimes(1);
});
it("fails install when service probe reports an unrelated error", async () => {
service.isLoaded.mockRejectedValueOnce(
new Error("systemctl is-enabled unavailable: read-only file system"),
);
await runDaemonInstall({ json: true });
expect(actionState.failed[0]?.message).toContain("Gateway service check failed");
expect(actionState.failed[0]?.message).toContain("read-only file system");
expect(installDaemonServiceAndEmitMock).not.toHaveBeenCalled();
});
});

View File

@@ -7,6 +7,7 @@ import { resolveGatewayInstallToken } from "../../commands/gateway-install-token
import { loadConfig, resolveGatewayPort } from "../../config/config.js";
import { resolveIsNixMode } from "../../config/paths.js";
import { resolveGatewayService } from "../../daemon/service.js";
import { isNonFatalSystemdInstallProbeError } from "../../daemon/systemd.js";
import { defaultRuntime } from "../../runtime.js";
import { formatCliCommand } from "../command-format.js";
import {
@@ -48,8 +49,12 @@ export async function runDaemonInstall(opts: DaemonInstallOptions) {
try {
loaded = await service.isLoaded({ env: process.env });
} catch (err) {
fail(`Gateway service check failed: ${String(err)}`);
return;
if (isNonFatalSystemdInstallProbeError(err)) {
loaded = false;
} else {
fail(`Gateway service check failed: ${String(err)}`);
return;
}
}
if (loaded) {
if (!opts.force) {