-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds long PAN functionality to send-pan task #3885
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,7 @@ function buildOutput(event, groupedExecutions) { | |
|
||
const parseFailedExecution = (execution) => { | ||
let reason = 'Workflow Failed'; | ||
if (execution.output) reason = JSON.parse(execution.output).exception; | ||
if (execution.error) reason = execution.error; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
https://docs.aws.amazon.com/step-functions/latest/dg/state-fail.html There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also I used |
||
return { arn: execution.executionArn, reason }; | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,16 +41,40 @@ async function sendPAN(event: HandlerEvent): Promise<HandlerOutput> { | |
const { config, input } = event; | ||
const provider = config.provider; | ||
const remoteDir = config.remoteDir || 'pans'; | ||
const panType = config.panType || 'shortPan'; | ||
|
||
const panName = input.pdr.name.replace(/\.pdr/gi, '.pan'); | ||
const panName = input.pdr.name.replace(/\.pdr/gi, '.PAN'); | ||
const uploadPath = path.join(remoteDir, panName); | ||
|
||
if (input.running.length !== 0) { | ||
throw new Error('Executions still running'); | ||
} | ||
|
||
const disposition = (input.failed.length > 0) ? 'FAILED' : 'SUCCESSFUL'; | ||
const pan = pdrHelpers.generateShortPAN(disposition); | ||
let pan; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We decided on 3 pan types:
|
||
switch (panType) { | ||
case 'longPanAlways': | ||
pan = await pdrHelpers.generateLongPAN([...input.completed, ...input.failed]); | ||
log.debug('Created long PAN'); | ||
break; | ||
case 'shortPan': { | ||
const disposition = (input.failed.length > 0) ? 'FAILED' : 'SUCCESSFUL'; | ||
pan = pdrHelpers.generateShortPAN(disposition); | ||
log.debug('Created short PAN'); | ||
break; | ||
} | ||
case 'longPan': { | ||
if (input.failed.length + input.completed.length <= 1) { | ||
const disposition = (input.failed.length > 0) ? 'FAILED' : 'SUCCESSFUL'; | ||
pan = pdrHelpers.generateShortPAN(disposition); | ||
log.debug('Created short PAN'); | ||
} else { | ||
pan = await pdrHelpers.generateLongPAN([...input.completed, ...input.failed]); | ||
log.debug('Created long PAN'); | ||
} | ||
break; | ||
} | ||
default: | ||
throw new Error(`Unknown panType: ${panType}, must be shortPan, longPan, or longPanAlways`); | ||
} | ||
|
||
const localPath = path.join(tmpdir(), panName); | ||
fs.writeFileSync(localPath, pan); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this function for getting some of the granule information from the execution. There could be a better alternative I'm not familiar with