Skip to content

Commit efe582c

Browse files
committed
fix(server): store the probe reason in failed host status
1 parent 18dd4cd commit efe582c

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎apps/server/src/device/DeviceService.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,10 @@ it.effect.each([
759759
for (const readiness of [service.readiness(), service.agentReadinessIfSupported()]) {
760760
const error = yield* readiness.pipe(Effect.flip);
761761
expect(error).toMatchObject({ reason: expected, cause: failure });
762+
expect((yield* service.state).hostStatuses[LOCAL_DEVICE_HOST_ID]).toEqual({
763+
status: "failed",
764+
detail: expected,
765+
});
762766
}
763767
for (const state of [yield* service.list, yield* service.retryHost(LOCAL_DEVICE_HOST_ID)]) {
764768
expect(state.hostStatuses[LOCAL_DEVICE_HOST_ID]).toEqual({

‎apps/server/src/device/DeviceService.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,13 @@ export const makeWithHosts = Effect.fn("DeviceService.makeWithHosts")(function*
273273
)
274274
.pipe(
275275
Effect.tapError((error) =>
276-
setHostStatus(host.id, { status: "failed", detail: error.message }),
276+
setHostStatus(host.id, {
277+
status: "failed",
278+
detail:
279+
error._tag === "DeviceHostError" && error.step === "probe"
280+
? sshProbeFailureMessage(error)
281+
: error.message,
282+
}),
277283
),
278284
Effect.mapError(
279285
(error) =>
@@ -328,7 +334,13 @@ export const makeWithHosts = Effect.fn("DeviceService.makeWithHosts")(function*
328334
)
329335
.pipe(
330336
Effect.tapError((error) =>
331-
setHostStatus(host.id, { status: "failed", detail: error.message }),
337+
setHostStatus(host.id, {
338+
status: "failed",
339+
detail:
340+
error._tag === "DeviceHostError" && error.step === "probe"
341+
? sshProbeFailureMessage(error)
342+
: error.message,
343+
}),
332344
),
333345
Effect.mapError(
334346
(error) =>

0 commit comments

Comments
 (0)