Skip to content

Commit

Permalink
Merge pull request #103 from depot/feat/failed-fly-machines
Browse files Browse the repository at this point in the history
feat: force delete failed fly machines
  • Loading branch information
goller authored Aug 27, 2024
2 parents e63bb6b + 03930b4 commit fd39bac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/utils/fly/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ export type MachineState =
| 'replaced' // this specific version is no longer current
| 'destroying' // user initiated the machine to be completely removed
| 'destroyed' // machine no longer exists
| 'failed'

// Volumes

Expand Down
6 changes: 4 additions & 2 deletions src/utils/fly/reconcile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ function currentMachineState(machine: V1Machine): GetDesiredStateResponse_Machin
if (instanceState === 'stopped') return GetDesiredStateResponse_MachineState.STOPPED
if (instanceState === 'destroying') return GetDesiredStateResponse_MachineState.DELETING
if (instanceState === 'destroyed') return GetDesiredStateResponse_MachineState.DELETED
if (instanceState === 'failed') return GetDesiredStateResponse_MachineState.ERROR
return GetDesiredStateResponse_MachineState.PENDING
}

Expand Down Expand Up @@ -205,8 +206,9 @@ async function reconcileMachine(state: V1Machine[], machine: GetDesiredStateResp
await stopAndWait(current)
} catch {} // stop can sometime fail, ignore.
}
console.log('Deleting machine', current.id)
await deleteMachine(current.id)
const force = currentState === GetDesiredStateResponse_MachineState.ERROR
force ? console.log('Forcing delete of machine', current.id) : console.log('Deleting machine', current.id)
await deleteMachine(current.id, force)
}
}

Expand Down

0 comments on commit fd39bac

Please sign in to comment.