Skip to content

Commit

Permalink
Fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
IPadawans committed Feb 22, 2024
1 parent a4d47cf commit 53d6c0b
Showing 1 changed file with 41 additions and 18 deletions.
59 changes: 41 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,35 @@ const _getReferenceSourceNodeFromNetwork = async (
return referenceSourceNode
}

const _checkCurrentMetagraphRestart = async (
ssmClient,
event,
referenceSourceNode,
currentMetagraphRestart
) => {
console.log(`Checking current metagraph restart`)
const { closeOpsgenieAlerts, deleteCurrentRestart, restartState, message } = await checkCurrentMetagraphRestart(
ssmClient,
event,
referenceSourceNode,
currentMetagraphRestart
);

if (restartState === DYNAMO_RESTART_STATE.READY) {
console.log(`Current restart READY, validating the nodes`)
await _validateIfAllNodesAreReady(event);
console.log(`All nodes are READY`)

await _checkIfNewSnapshotsAreProducedAfterRestart(event);
}

return {
closeOpsgenieAlerts,
deleteCurrentRestart,
message
}
}

const _handleRestartMetagraph = async (
event,
ssmClient
Expand All @@ -116,34 +145,28 @@ const _handleRestartMetagraph = async (
console.log(`Getting the reference source node`)
const referenceSourceNode = await _getReferenceSourceNodeFromNetwork(event)

if (currentMetagraphRestart.restartType === DYNAMO_RESTART_TYPES.FULL_CLUSTER) {
console.log(`FULL RESTART already in progress`)
return await _checkCurrentMetagraphRestart(
ssmClient,
event,
referenceSourceNode,
currentMetagraphRestart
)
}

console.log(`Getting possible metagraph restart type`)
const metagraphRestartType = await _getMetagraphRestartType(event)

if (
!(currentMetagraphRestart.restartType === DYNAMO_RESTART_TYPES.INDIVIDUAL_NODES && metagraphRestartType.restartType === DYNAMO_RESTART_TYPES.FULL_CLUSTER) &&
currentMetagraphRestart.state !== DYNAMO_RESTART_STATE.NEW
) {
console.log(`Checking current metagraph restart`)
const { closeOpsgenieAlerts, deleteCurrentRestart, restartState, message } = await checkCurrentMetagraphRestart(
return _checkCurrentMetagraphRestart(
ssmClient,
event,
referenceSourceNode,
currentMetagraphRestart
);

if (restartState === DYNAMO_RESTART_STATE.READY) {
console.log(`Current restart READY, validating the nodes`)
await _validateIfAllNodesAreReady(event);
console.log(`All nodes are READY`)

await _checkIfNewSnapshotsAreProducedAfterRestart(event);
}

return {
closeOpsgenieAlerts,
deleteCurrentRestart,
message
}
)
}

try {
Expand Down

0 comments on commit 53d6c0b

Please sign in to comment.