Skip to content

Commit

Permalink
Merge pull request #117 from depot/billy/bad-state-logging
Browse files Browse the repository at this point in the history
log on why machine/change is unnecessary
  • Loading branch information
billyb2 authored Nov 6, 2024
2 parents 5ef57c3 + b4f0d9c commit c3f07ed
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/utils/aws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,23 @@ async function reconcileMachine(state: Record<string, Instance>, machine: GetDes
(i) => i.Tags?.some((t) => t.Key === 'depot-machine-id' && t.Value === machine.resourceId),
)

if (matches.length == 0) {
console.log(`No matching machine instance with resource ID: ${machine.resourceId}`)
}

for (const current of matches) {
const currentState = current ? currentMachineState(current) : 'unknown'

// Skip if already at the desired state
if (currentState === machine.desiredState) return
if (currentState === machine.desiredState) {
console.log(`Machine instance with resource ID ${machine.resourceId} is in desired state ${machine.desiredState}`)
return
}

if (!current || !current.InstanceId) return
if (!current || !current.InstanceId) {
console.log(`No machine instance with resource ID: ${machine.resourceId}`)
return
}

if (machine.desiredState === GetDesiredStateResponse_MachineState.RUNNING) {
if (currentState === GetDesiredStateResponse_MachineState.PENDING) return
Expand Down

0 comments on commit c3f07ed

Please sign in to comment.