Skip to content

Commit

Permalink
agent: allow expired allocations to be reallocated with force
Browse files Browse the repository at this point in the history
  • Loading branch information
dwerner committed Oct 23, 2024
1 parent c0933a7 commit 6293b58
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/indexer-common/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,14 @@ export const validateActionInputs = async (
// allocationID must belong to active allocation
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const allocation = await networkMonitor.allocation(action.allocationID!)
if (allocation.status !== AllocationStatus.ACTIVE) {

const forcedReallocate =
action.type === ActionType.REALLOCATE && action.force === true
// TODO && isZeroPOI(action.poi)

if (forcedReallocate) {
logger.info(`forcing reallocate of id = '${action.allocationID}'`)
} else if (allocation.status !== AllocationStatus.ACTIVE) {
throw new Error(
`An active allocation does not exist with id = '${action.allocationID}'`,
)
Expand All @@ -151,6 +158,10 @@ export const validateActionInputs = async (
}
}
}

function isZeroPOI(poi: string | undefined): boolean {
return (typeof poi == 'number' && poi == 0) || (typeof poi == 'string' && poi == '0')
}
}

export interface ActionFilter {
Expand Down

0 comments on commit 6293b58

Please sign in to comment.