Skip to content

Commit

Permalink
Added retry info to logger - to get more info in teams alert
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgtho committed Jul 1, 2022
1 parent 859020b commit 72b2f64
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/run-flow.js
Original file line number Diff line number Diff line change
@@ -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')

/**
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 72b2f64

Please sign in to comment.