From 0cdaaa26dc620cbe9d2cb1d2529a209c9ea97e91 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Mon, 28 Oct 2024 14:55:37 -0500 Subject: [PATCH 1/2] feat: add duration logging for start and stop machine Signed-off-by: Chris Goller --- src/utils/fly/reconcile.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils/fly/reconcile.ts b/src/utils/fly/reconcile.ts index 0a7713e..5b723d5 100644 --- a/src/utils/fly/reconcile.ts +++ b/src/utils/fly/reconcile.ts @@ -209,15 +209,21 @@ async function reconcileMachine(state: V1Machine[], machine: GetDesiredStateResp if (machine.desiredState === GetDesiredStateResponse_MachineState.RUNNING) { if (currentState === GetDesiredStateResponse_MachineState.PENDING) return if (currentState === GetDesiredStateResponse_MachineState.DELETED) return + const begin = Date.now() console.log('Starting machine', current.id) await startMachine(current.id) + const duration_ms = Date.now() - begin + console.log('Started machine', current.id, 'in ', duration_ms, 'ms') } if (machine.desiredState === GetDesiredStateResponse_MachineState.STOPPED) { if (currentState === GetDesiredStateResponse_MachineState.PENDING) return if (currentState === GetDesiredStateResponse_MachineState.DELETED) return + const begin = Date.now() console.log('Stopping machine', current.id) await stopAndWait(current) + const duration_ms = Date.now() - begin + console.log('Stopped machine', current.id, current.id, 'in ', duration_ms, 'ms') } if (machine.desiredState === GetDesiredStateResponse_MachineState.DELETED) { From 4b483332cf1655b2f7e964b1b687772a666719a8 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Mon, 28 Oct 2024 14:59:49 -0500 Subject: [PATCH 2/2] feat: add warning for slow machine starts Signed-off-by: Chris Goller --- src/utils/fly/reconcile.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/fly/reconcile.ts b/src/utils/fly/reconcile.ts index 5b723d5..0aa83e5 100644 --- a/src/utils/fly/reconcile.ts +++ b/src/utils/fly/reconcile.ts @@ -211,8 +211,11 @@ async function reconcileMachine(state: V1Machine[], machine: GetDesiredStateResp if (currentState === GetDesiredStateResponse_MachineState.DELETED) return const begin = Date.now() console.log('Starting machine', current.id) - await startMachine(current.id) + const res = await startMachine(current.id) const duration_ms = Date.now() - begin + if (duration_ms > 5000) { + console.log('WARNING: Slow machine start', current.id, 'in ', duration_ms, 'ms', 'result', res) + } console.log('Started machine', current.id, 'in ', duration_ms, 'ms') }