Skip to content

Commit

Permalink
agent,common: Move subgraph health safety check to reconcileActions
Browse files Browse the repository at this point in the history
- Previously the safety check occurred later in the process. We should
identify early that a subgraph is failed and safety = true to not
add the action to the queue in the first place. The other benefit
of moving this check is so it has access to the corresponding rule
so the safety property can be used here for control.
  • Loading branch information
fordN committed Jan 26, 2024
1 parent 0f48b17 commit b5cc50e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
22 changes: 20 additions & 2 deletions packages/indexer-agent/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1073,8 +1073,26 @@ export class Agent {
epoch,
)
case true: {
// If no active allocations, create one
if (activeDeploymentAllocations.length === 0) {
// If no active allocations and subgraph health passes safety check, create one
const indexingStatus = (
await this.graphNode.indexingStatus([
deploymentAllocationDecision.deployment,
])
)[0]
const failsHealthCheck =
(indexingStatus &&
indexingStatus.health == 'failed' &&
deploymentAllocationDecision.ruleMatch.rule?.safety) ||
!indexingStatus
if (failsHealthCheck) {
logger.warn(
'Subgraph deployment has failed health check, skipping allocate',
{
indexingStatus,
safety: deploymentAllocationDecision.ruleMatch.rule?.safety,
},
)
} else if (activeDeploymentAllocations.length === 0) {
// Fetch the latest closed allocation, if any
const mostRecentlyClosedAllocation = (
await network.networkMonitor.closedAllocations(
Expand Down
6 changes: 0 additions & 6 deletions packages/indexer-common/src/indexer-management/allocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,6 @@ export class AllocationManager {
`Subgraph deployment, '${deployment.ipfsHash}', is not syncing`,
)
}
if (status && status.health == 'failed') {
throw indexerError(
IndexerErrorCode.IE020,
`Subgraph deployment, '${deployment.ipfsHash}', failed during syncing`,
)
}

logger.debug('Obtain a unique Allocation ID')
const { allocationSigner, allocationId } = uniqueAllocationID(
Expand Down

0 comments on commit b5cc50e

Please sign in to comment.