diff --git a/lib/run-flow.js b/lib/run-flow.js index 3b6fd62..6445619 100644 --- a/lib/run-flow.js +++ b/lib/run-flow.js @@ -1,6 +1,7 @@ const { archive, signOff, syncElevmappa } = require('./archive') const { createTaskTemplate, complete } = require('./e18') const { updateStatusFlow } = require('./update-vigo-status') +const { RETRY_INTERVAL_HOURS, RETRY_MAX_COUNT } = require('../config') const { logger } = require('@vtfk/logger') /** @@ -26,7 +27,8 @@ module.exports = async (blobContent, flowDef) => { } if (blobContent.flow.syncElevmappa.status !== 'finished') { - logger('warn', ['flow', 'syncElevmappa failed', 'Aborting']) + const retryMsg = (blobContent.retryCount >= RETRY_MAX_COUNT) ? `Max retry count ${RETRY_MAX_COUNT} reached, moved to error` : `Will retry in ${(blobContent.retryCount + 1) * RETRY_INTERVAL_HOURS} hours` + logger('warn', ['flow', 'syncElevmappa failed', 'Aborting', retryMsg]) blobContent.flow.status = 'failed' return blobContent } @@ -39,7 +41,8 @@ module.exports = async (blobContent, flowDef) => { } if (blobContent.flow.archive.status !== 'finished') { - logger('warn', ['flow', 'archive failed', 'Aborting']) + const retryMsg = (blobContent.retryCount >= RETRY_MAX_COUNT) ? `Max retry count ${RETRY_MAX_COUNT} reached, moved to error` : `Will retry in ${(blobContent.retryCount + 1) * RETRY_INTERVAL_HOURS} hours` + logger('warn', ['flow', 'archive failed', 'Aborting', retryMsg]) blobContent.flow.status = 'failed' return blobContent } @@ -52,7 +55,8 @@ module.exports = async (blobContent, flowDef) => { } if (blobContent.flow.signOff.status !== 'finished') { - logger('warn', ['flow', 'signOff failed', 'Aborting']) + const retryMsg = (blobContent.retryCount >= RETRY_MAX_COUNT) ? `Max retry count ${RETRY_MAX_COUNT} reached, moved to error` : `Will retry in ${(blobContent.retryCount + 1) * RETRY_INTERVAL_HOURS} hours` + logger('warn', ['flow', 'signOff failed', 'Aborting', retryMsg]) blobContent.flow.status = 'failed' return blobContent } @@ -65,7 +69,8 @@ module.exports = async (blobContent, flowDef) => { } if (blobContent.flow.statusVigo.status !== 'finished') { - logger('warn', ['flow', 'status vigo failed', 'Aborting']) + const retryMsg = (blobContent.retryCount >= RETRY_MAX_COUNT) ? `Max retry count ${RETRY_MAX_COUNT} reached, moved to error` : `Will retry in ${(blobContent.retryCount + 1) * RETRY_INTERVAL_HOURS} hours` + logger('warn', ['flow', 'status vigo failed', 'Aborting', retryMsg]) blobContent.flow.status = 'failed' return blobContent } @@ -78,7 +83,8 @@ module.exports = async (blobContent, flowDef) => { } if (blobContent.flow.e18StatsTask.status !== 'finished') { - logger('warn', ['flow', 'e18 stats task creation failed', 'Aborting']) + const retryMsg = (blobContent.retryCount >= RETRY_MAX_COUNT) ? `Max retry count ${RETRY_MAX_COUNT} reached, moved to error` : `Will retry in ${(blobContent.retryCount + 1) * RETRY_INTERVAL_HOURS} hours` + logger('warn', ['flow', 'e18 stats task creation failed', 'Aborting', retryMsg]) blobContent.flow.status = 'failed' return blobContent } @@ -89,7 +95,8 @@ module.exports = async (blobContent, flowDef) => { } if (blobContent.flow.e18Job.status !== 'finished') { - logger('warn', ['flow', 'e18 job complete failed', 'Aborting']) + const retryMsg = (blobContent.retryCount >= RETRY_MAX_COUNT) ? `Max retry count ${RETRY_MAX_COUNT} reached, moved to error` : `Will retry in ${(blobContent.retryCount + 1) * RETRY_INTERVAL_HOURS} hours` + logger('warn', ['flow', 'e18 job complete failed', 'Aborting', retryMsg]) blobContent.flow.status = 'failed' return blobContent }