Skip to content

Commit 425bda9

Browse files
committed
Adding fix for max-runtime
1 parent 1a30131 commit 425bda9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

handlers/src/scheduler.ts

+12
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,18 @@ export async function processStateAction(stateMachineArn: string, action: AutoSt
540540
}
541541
}
542542
if (action.action === "stop" || action.action === "reboot") {
543+
// When max-runtime is used we must check the previous start time to ensure we should be proceeding
544+
if (resource.tags.maxRuntime && resource.state === "running") {
545+
const when = calculateWhen(resource.startTime, Number(resource.tags.maxRuntime)).toISOString();
546+
if (action.when !== when) {
547+
return {
548+
...action,
549+
execute: false,
550+
reason: "Start time does not match",
551+
resource
552+
}
553+
}
554+
}
543555
await startExecution(stateMachineArn, resource, nextAction(resource, action));
544556
if (resource.state === "running") {
545557
console.log(`${action.resourceType} ${action.resourceId} is running, ${action.action === "stop" ? "stopping" : "rebooting"}...`);

0 commit comments

Comments
 (0)