@cumulus/message 10.1.1-alpha.0 → 10.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Collections.d.ts +0 -3
- package/Collections.d.ts.map +1 -1
- package/Collections.js +14 -14
- package/Collections.js.map +1 -1
- package/Executions.d.ts +4 -19
- package/Executions.d.ts.map +1 -1
- package/Executions.js +3 -51
- package/Executions.js.map +1 -1
- package/Granules.d.ts +10 -76
- package/Granules.d.ts.map +1 -1
- package/Granules.js +2 -140
- package/Granules.js.map +1 -1
- package/LICENSE +60 -0
- package/PDRs.d.ts +12 -18
- package/PDRs.d.ts.map +1 -1
- package/PDRs.js +4 -73
- package/PDRs.js.map +1 -1
- package/README.md +75 -36
- package/StepFunctions.d.ts +1 -1
- package/StepFunctions.js +6 -2
- package/StepFunctions.js.map +1 -1
- package/package.json +9 -8
- package/src/Collections.ts +12 -13
- package/src/Executions.ts +7 -77
- package/src/Granules.ts +3 -214
- package/src/PDRs.ts +13 -99
- package/src/StepFunctions.ts +1 -1
- package/src/types.ts +0 -5
- package/tsconfig.tsbuildinfo +1 -1
- package/types.d.ts +0 -4
- package/types.d.ts.map +1 -1
- package/workflows.d.ts +1 -1
- package/workflows.d.ts.map +1 -1
- package/src/utils.ts +0 -17
- package/utils.d.ts +0 -8
- package/utils.d.ts.map +0 -1
- package/utils.js +0 -26
- package/utils.js.map +0 -1
package/PDRs.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Message } from '@cumulus/types';
|
|
2
|
-
import { ApiPdr } from '@cumulus/types/api/pdrs';
|
|
3
2
|
interface PDR {
|
|
4
3
|
name: string;
|
|
5
4
|
PANSent: boolean;
|
|
@@ -8,6 +7,11 @@ interface PDR {
|
|
|
8
7
|
interface MessageWithOptionalPayloadPdr extends Message.CumulusMessage {
|
|
9
8
|
payload: {
|
|
10
9
|
pdr?: PDR;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface MessageWithOptionalPdrStats extends Message.CumulusMessage {
|
|
13
|
+
payload: {
|
|
14
|
+
pdr: PDR;
|
|
11
15
|
failed?: unknown[];
|
|
12
16
|
running?: unknown[];
|
|
13
17
|
completed?: unknown[];
|
|
@@ -67,30 +71,30 @@ export declare const getMessagePdrName: (message: MessageWithOptionalPayloadPdr)
|
|
|
67
71
|
/**
|
|
68
72
|
* Get the number of running executions for a PDR, if any.
|
|
69
73
|
*
|
|
70
|
-
* @param {
|
|
74
|
+
* @param {MessageWithOptionalPdrStats} message - A workflow message
|
|
71
75
|
* @returns {number} Number of running executions
|
|
72
76
|
*
|
|
73
77
|
* @alias module:PDRs
|
|
74
78
|
*/
|
|
75
|
-
export declare const getMessagePdrRunningExecutions: (message:
|
|
79
|
+
export declare const getMessagePdrRunningExecutions: (message: MessageWithOptionalPdrStats) => number;
|
|
76
80
|
/**
|
|
77
81
|
* Get the number of completed executions for a PDR, if any.
|
|
78
82
|
*
|
|
79
|
-
* @param {
|
|
83
|
+
* @param {MessageWithOptionalPdrStats} message - A workflow message
|
|
80
84
|
* @returns {number} Number of completed executions
|
|
81
85
|
*
|
|
82
86
|
* @alias module:PDRs
|
|
83
87
|
*/
|
|
84
|
-
export declare const getMessagePdrCompletedExecutions: (message:
|
|
88
|
+
export declare const getMessagePdrCompletedExecutions: (message: MessageWithOptionalPdrStats) => number;
|
|
85
89
|
/**
|
|
86
90
|
* Get the number of failed executions for a PDR, if any.
|
|
87
91
|
*
|
|
88
|
-
* @param {
|
|
92
|
+
* @param {MessageWithOptionalPdrStats} message - A workflow message
|
|
89
93
|
* @returns {number} Number of failed executions
|
|
90
94
|
*
|
|
91
95
|
* @alias module:PDRs
|
|
92
96
|
*/
|
|
93
|
-
export declare const getMessagePdrFailedExecutions: (message:
|
|
97
|
+
export declare const getMessagePdrFailedExecutions: (message: MessageWithOptionalPdrStats) => number;
|
|
94
98
|
/**
|
|
95
99
|
* Get the PDR stats from a workflow message, if any.
|
|
96
100
|
*
|
|
@@ -100,7 +104,7 @@ export declare const getMessagePdrFailedExecutions: (message: MessageWithOptiona
|
|
|
100
104
|
*
|
|
101
105
|
* @alias module:PDRs
|
|
102
106
|
*/
|
|
103
|
-
export declare const getMessagePdrStats: (message:
|
|
107
|
+
export declare const getMessagePdrStats: (message: MessageWithOptionalPdrStats) => PdrStats;
|
|
104
108
|
/**
|
|
105
109
|
* Get the percent completion of PDR executions
|
|
106
110
|
*
|
|
@@ -110,15 +114,5 @@ export declare const getMessagePdrStats: (message: MessageWithOptionalPayloadPdr
|
|
|
110
114
|
* @alias module:PDRs
|
|
111
115
|
*/
|
|
112
116
|
export declare const getPdrPercentCompletion: (stats: PdrStats) => number;
|
|
113
|
-
/**
|
|
114
|
-
* Generate a PDR record for the API from the message.
|
|
115
|
-
*
|
|
116
|
-
* @param {MessageWithOptionalPayloadPdr} message - A workflow message object
|
|
117
|
-
* @param {string} [updatedAt] - Optional updated timestamp to apply to record
|
|
118
|
-
* @returns {ExecutionRecord} An PDR API record
|
|
119
|
-
*
|
|
120
|
-
* @alias module:Executions
|
|
121
|
-
*/
|
|
122
|
-
export declare const generatePdrApiRecordFromMessage: (message: MessageWithOptionalPayloadPdr, updatedAt?: number) => ApiPdr | undefined;
|
|
123
117
|
export {};
|
|
124
118
|
//# sourceMappingURL=PDRs.d.ts.map
|
package/PDRs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PDRs.d.ts","sourceRoot":"","sources":["src/PDRs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PDRs.d.ts","sourceRoot":"","sources":["src/PDRs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,UAAU,GAAG;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,UAAU,6BAA8B,SAAQ,OAAO,CAAC,cAAc;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,KACd,MAQF,CAAC"}
|
package/PDRs.js
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const errors_1 = require("@cumulus/errors");
|
|
8
|
-
const logger_1 = __importDefault(require("@cumulus/logger"));
|
|
9
|
-
const Collections_1 = require("./Collections");
|
|
10
|
-
const Executions_1 = require("./Executions");
|
|
11
|
-
const Providers_1 = require("./Providers");
|
|
12
|
-
const workflows_1 = require("./workflows");
|
|
13
|
-
const logger = new logger_1.default({ sender: '@cumulus/message/PDRs' });
|
|
3
|
+
exports.getPdrPercentCompletion = exports.getMessagePdrStats = exports.getMessagePdrFailedExecutions = exports.getMessagePdrCompletedExecutions = exports.getMessagePdrRunningExecutions = exports.getMessagePdrName = exports.getMessagePdrPANMessage = exports.getMessagePdrPANSent = exports.messageHasPdr = exports.getMessagePdr = void 0;
|
|
14
4
|
/**
|
|
15
5
|
* Get the PDR object from a workflow message, if any.
|
|
16
6
|
*
|
|
@@ -64,7 +54,7 @@ exports.getMessagePdrName = getMessagePdrName;
|
|
|
64
54
|
/**
|
|
65
55
|
* Get the number of running executions for a PDR, if any.
|
|
66
56
|
*
|
|
67
|
-
* @param {
|
|
57
|
+
* @param {MessageWithOptionalPdrStats} message - A workflow message
|
|
68
58
|
* @returns {number} Number of running executions
|
|
69
59
|
*
|
|
70
60
|
* @alias module:PDRs
|
|
@@ -74,7 +64,7 @@ exports.getMessagePdrRunningExecutions = getMessagePdrRunningExecutions;
|
|
|
74
64
|
/**
|
|
75
65
|
* Get the number of completed executions for a PDR, if any.
|
|
76
66
|
*
|
|
77
|
-
* @param {
|
|
67
|
+
* @param {MessageWithOptionalPdrStats} message - A workflow message
|
|
78
68
|
* @returns {number} Number of completed executions
|
|
79
69
|
*
|
|
80
70
|
* @alias module:PDRs
|
|
@@ -84,7 +74,7 @@ exports.getMessagePdrCompletedExecutions = getMessagePdrCompletedExecutions;
|
|
|
84
74
|
/**
|
|
85
75
|
* Get the number of failed executions for a PDR, if any.
|
|
86
76
|
*
|
|
87
|
-
* @param {
|
|
77
|
+
* @param {MessageWithOptionalPdrStats} message - A workflow message
|
|
88
78
|
* @returns {number} Number of failed executions
|
|
89
79
|
*
|
|
90
80
|
* @alias module:PDRs
|
|
@@ -132,63 +122,4 @@ const getPdrPercentCompletion = (stats) => {
|
|
|
132
122
|
return progress;
|
|
133
123
|
};
|
|
134
124
|
exports.getPdrPercentCompletion = getPdrPercentCompletion;
|
|
135
|
-
/**
|
|
136
|
-
* Generate a PDR record for the API from the message.
|
|
137
|
-
*
|
|
138
|
-
* @param {MessageWithOptionalPayloadPdr} message - A workflow message object
|
|
139
|
-
* @param {string} [updatedAt] - Optional updated timestamp to apply to record
|
|
140
|
-
* @returns {ExecutionRecord} An PDR API record
|
|
141
|
-
*
|
|
142
|
-
* @alias module:Executions
|
|
143
|
-
*/
|
|
144
|
-
const generatePdrApiRecordFromMessage = (message, updatedAt = Date.now()) => {
|
|
145
|
-
const pdr = (0, exports.getMessagePdr)(message);
|
|
146
|
-
// We got a message with no PDR (OK)
|
|
147
|
-
if (!pdr) {
|
|
148
|
-
logger.info('No PDRs to process on the message');
|
|
149
|
-
return undefined;
|
|
150
|
-
}
|
|
151
|
-
// We got a message with a PDR but no name to identify it (Not OK)
|
|
152
|
-
if (!pdr.name) {
|
|
153
|
-
throw new errors_1.CumulusMessageError(`Could not find name on PDR object ${JSON.stringify(pdr)}`);
|
|
154
|
-
}
|
|
155
|
-
const collectionId = (0, Collections_1.getCollectionIdFromMessage)(message);
|
|
156
|
-
if (!collectionId) {
|
|
157
|
-
throw new errors_1.CumulusMessageError('meta.collection required to generate a PDR record');
|
|
158
|
-
}
|
|
159
|
-
const providerId = (0, Providers_1.getMessageProviderId)(message);
|
|
160
|
-
if (!providerId) {
|
|
161
|
-
throw new errors_1.CumulusMessageError('meta.provider required to generate a PDR record');
|
|
162
|
-
}
|
|
163
|
-
const status = (0, workflows_1.getMetaStatus)(message);
|
|
164
|
-
if (!status) {
|
|
165
|
-
throw new errors_1.CumulusMessageError('meta.status required to generate a PDR record');
|
|
166
|
-
}
|
|
167
|
-
const arn = (0, Executions_1.getMessageExecutionArn)(message);
|
|
168
|
-
if (!arn) {
|
|
169
|
-
throw new errors_1.CumulusMessageError('cumulus_meta.state_machine and cumulus_meta.execution_name required to generate a PDR record');
|
|
170
|
-
}
|
|
171
|
-
const execution = (0, Executions_1.getExecutionUrlFromArn)(arn);
|
|
172
|
-
const stats = (0, exports.getMessagePdrStats)(message);
|
|
173
|
-
const progress = (0, exports.getPdrPercentCompletion)(stats);
|
|
174
|
-
const now = Date.now();
|
|
175
|
-
const workflowStartTime = (0, workflows_1.getMessageWorkflowStartTime)(message);
|
|
176
|
-
const record = {
|
|
177
|
-
pdrName: pdr.name,
|
|
178
|
-
collectionId,
|
|
179
|
-
status,
|
|
180
|
-
provider: providerId,
|
|
181
|
-
progress,
|
|
182
|
-
execution,
|
|
183
|
-
PANSent: (0, exports.getMessagePdrPANSent)(message),
|
|
184
|
-
PANmessage: (0, exports.getMessagePdrPANMessage)(message),
|
|
185
|
-
stats,
|
|
186
|
-
createdAt: (0, workflows_1.getMessageWorkflowStartTime)(message),
|
|
187
|
-
timestamp: now,
|
|
188
|
-
updatedAt,
|
|
189
|
-
duration: (0, workflows_1.getWorkflowDuration)(workflowStartTime, now),
|
|
190
|
-
};
|
|
191
|
-
return record;
|
|
192
|
-
};
|
|
193
|
-
exports.generatePdrApiRecordFromMessage = generatePdrApiRecordFromMessage;
|
|
194
125
|
//# sourceMappingURL=PDRs.js.map
|
package/PDRs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PDRs.js","sourceRoot":"","sources":["src/PDRs.ts"],"names":[],"mappings":"
|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GAAG,GAAG,CAAC;KAChB;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAVW,QAAA,uBAAuB,2BAUlC"}
|
package/README.md
CHANGED
|
@@ -23,9 +23,6 @@ from a Cumulus message</p>
|
|
|
23
23
|
<dt><a href="#module_Queue">Queue</a></dt>
|
|
24
24
|
<dd><p>Utility functions for parsing queue information from a Cumulus message</p>
|
|
25
25
|
</dd>
|
|
26
|
-
<dt><a href="#module_StepFunctions">StepFunctions</a></dt>
|
|
27
|
-
<dd><p>Utility functions for working with AWS Step Function events/messages</p>
|
|
28
|
-
</dd>
|
|
29
26
|
</dl>
|
|
30
27
|
|
|
31
28
|
### Functions
|
|
@@ -47,6 +44,10 @@ the collectionId used in elasticsearch indexing</p>
|
|
|
47
44
|
<dt><a href="#exp_module_Collections--getCollectionIdFromMessage">getCollectionIdFromMessage(message)</a> ⇒ <code>string</code> | <code>undefined</code> ⏏</dt>
|
|
48
45
|
<dd><p>Get collection ID from execution message.</p>
|
|
49
46
|
</dd>
|
|
47
|
+
<dt><a href="#unwrapDeadLetterCumulusMessage">unwrapDeadLetterCumulusMessage(messageBody)</a> ⇒ <code>Object</code></dt>
|
|
48
|
+
<dd><p>Unwrap dead letter Cumulus message, which may be wrapped in a
|
|
49
|
+
States cloudwatch event, which is wrapped in an SQS message.</p>
|
|
50
|
+
</dd>
|
|
50
51
|
<dt><a href="#exp_module_Granules--getMessageGranules">getMessageGranules(message)</a> ⇒ <code>Array.<Object></code> | <code>undefined</code> ⏏</dt>
|
|
51
52
|
<dd><p>Get granules from payload?.granules of a workflow message.</p>
|
|
52
53
|
</dd>
|
|
@@ -95,6 +96,29 @@ the collectionId used in elasticsearch indexing</p>
|
|
|
95
96
|
<dt><a href="#exp_module_Providers--getMessageProviderId">getMessageProviderId(message)</a> ⇒ <code>undefined</code> | <code>string</code> ⏏</dt>
|
|
96
97
|
<dd><p>Get the provider ID from a workflow message, if any.</p>
|
|
97
98
|
</dd>
|
|
99
|
+
<dt><a href="#exp_module_StepFunctions--pullStepFunctionEvent">pullStepFunctionEvent(event)</a> ⇒ <code>Promise.<Object></code> ⏏</dt>
|
|
100
|
+
<dd><p>Given a Step Function event, replace specified key in event with contents
|
|
101
|
+
of S3 remote message</p>
|
|
102
|
+
</dd>
|
|
103
|
+
<dt><a href="#exp_module_StepFunctions--parseStepMessage">parseStepMessage(stepMessage, stepName)</a> ⇒ <code>Promise.<Object></code> ⏏</dt>
|
|
104
|
+
<dd><p>Parse step message with CMA keys and replace specified key in event with contents
|
|
105
|
+
of S3 remote message</p>
|
|
106
|
+
</dd>
|
|
107
|
+
<dt><a href="#getFailedStepName">getFailedStepName(events, failedStepEvent)</a> ⇒ <code>string</code></dt>
|
|
108
|
+
<dd><p>Searches the Execution step History for the TaskStateEntered pertaining to
|
|
109
|
+
the failed task Id. HistoryEvent ids are numbered sequentially, starting at
|
|
110
|
+
one.</p>
|
|
111
|
+
</dd>
|
|
112
|
+
<dt><a href="#lastFailedEventStep">lastFailedEventStep(events)</a> ⇒ <code>HistoryEventList</code> | <code>undefined</code></dt>
|
|
113
|
+
<dd><p>Finds all failed execution events and returns the last one in the list.</p>
|
|
114
|
+
</dd>
|
|
115
|
+
<dt><a href="#getFailedExecutionMessage">getFailedExecutionMessage(inputCumulusMessage, getExecutionHistoryFunction)</a> ⇒ <code>Object</code></dt>
|
|
116
|
+
<dd><p>Get message to use for publishing failed execution notifications.</p>
|
|
117
|
+
<p>Try to get the input to the last failed step in the execution so we can
|
|
118
|
+
update the status of any granules/PDRs that don't exist in the initial execution
|
|
119
|
+
input.</p>
|
|
120
|
+
<p>Falls back to overall execution input.</p>
|
|
121
|
+
</dd>
|
|
98
122
|
<dt><a href="#exp_module_workflows--getMetaStatus">getMetaStatus(message)</a> ⇒ <code>Message.WorkflowStatus</code> | <code>undefined</code> ⏏</dt>
|
|
99
123
|
<dd><p>Get the status of a workflow message, if any.</p>
|
|
100
124
|
</dd>
|
|
@@ -354,63 +378,78 @@ Determine if there is a queue and queue execution limit in the message.
|
|
|
354
378
|
| --- | --- | --- |
|
|
355
379
|
| message | <code>MessageWithQueueInfo</code> | A workflow message object |
|
|
356
380
|
|
|
357
|
-
<a name="
|
|
381
|
+
<a name="deconstructCollectionId"></a>
|
|
358
382
|
|
|
359
|
-
###
|
|
360
|
-
|
|
383
|
+
### deconstructCollectionId(collectionId) ⇒ <code>Object</code>
|
|
384
|
+
Returns the name and version of a collection based on
|
|
385
|
+
the collectionId used in elasticsearch indexing
|
|
361
386
|
|
|
362
|
-
**
|
|
363
|
-
|
|
364
|
-
const StepFunctions = require('@cumulus/message/StepFunctions');
|
|
365
|
-
```
|
|
387
|
+
**Kind**: global function
|
|
388
|
+
**Returns**: <code>Object</code> - name and version as object
|
|
366
389
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
390
|
+
| Param | Type | Description |
|
|
391
|
+
| --- | --- | --- |
|
|
392
|
+
| collectionId | <code>string</code> | collectionId used in elasticsearch index |
|
|
370
393
|
|
|
371
|
-
<a name="
|
|
394
|
+
<a name="unwrapDeadLetterCumulusMessage"></a>
|
|
372
395
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
396
|
+
### unwrapDeadLetterCumulusMessage(messageBody) ⇒ <code>Object</code>
|
|
397
|
+
Unwrap dead letter Cumulus message, which may be wrapped in a
|
|
398
|
+
States cloudwatch event, which is wrapped in an SQS message.
|
|
376
399
|
|
|
377
|
-
**Kind**:
|
|
378
|
-
**Returns**: <code>
|
|
379
|
-
**Throws**:
|
|
400
|
+
**Kind**: global function
|
|
401
|
+
**Returns**: <code>Object</code> - the cumulus message or nearest available object
|
|
380
402
|
|
|
381
|
-
|
|
403
|
+
| Param | Type | Description |
|
|
404
|
+
| --- | --- | --- |
|
|
405
|
+
| messageBody | <code>Object</code> | received SQS message |
|
|
382
406
|
|
|
407
|
+
<a name="getFailedStepName"></a>
|
|
408
|
+
|
|
409
|
+
### getFailedStepName(events, failedStepEvent) ⇒ <code>string</code>
|
|
410
|
+
Searches the Execution step History for the TaskStateEntered pertaining to
|
|
411
|
+
the failed task Id. HistoryEvent ids are numbered sequentially, starting at
|
|
412
|
+
one.
|
|
413
|
+
|
|
414
|
+
**Kind**: global function
|
|
415
|
+
**Returns**: <code>string</code> - name of the current stepfunction task or 'UnknownFailedStepName'.
|
|
383
416
|
|
|
384
417
|
| Param | Type | Description |
|
|
385
418
|
| --- | --- | --- |
|
|
386
|
-
|
|
|
419
|
+
| events | <code>Array.<HistoryEvent></code> | Step Function events array |
|
|
420
|
+
| failedStepEvent | <code>HistoryEvent</code> | Step Function's failed event. |
|
|
387
421
|
|
|
388
|
-
<a name="
|
|
422
|
+
<a name="lastFailedEventStep"></a>
|
|
389
423
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
of S3 remote message
|
|
424
|
+
### lastFailedEventStep(events) ⇒ <code>HistoryEventList</code> \| <code>undefined</code>
|
|
425
|
+
Finds all failed execution events and returns the last one in the list.
|
|
393
426
|
|
|
394
|
-
**Kind**:
|
|
395
|
-
**Returns**: <code>
|
|
427
|
+
**Kind**: global function
|
|
428
|
+
**Returns**: <code>HistoryEventList</code> \| <code>undefined</code> - - the last lambda or activity that failed in the
|
|
429
|
+
event array, or an empty array.
|
|
396
430
|
|
|
397
431
|
| Param | Type | Description |
|
|
398
432
|
| --- | --- | --- |
|
|
399
|
-
|
|
|
400
|
-
| stepName | <code>string</code> | Name of the step |
|
|
433
|
+
| events | <code>Array.<HistoryEventList></code> | array of AWS Stepfunction execution HistoryEvents |
|
|
401
434
|
|
|
402
|
-
<a name="
|
|
435
|
+
<a name="getFailedExecutionMessage"></a>
|
|
403
436
|
|
|
404
|
-
###
|
|
405
|
-
|
|
406
|
-
|
|
437
|
+
### getFailedExecutionMessage(inputCumulusMessage, getExecutionHistoryFunction) ⇒ <code>Object</code>
|
|
438
|
+
Get message to use for publishing failed execution notifications.
|
|
439
|
+
|
|
440
|
+
Try to get the input to the last failed step in the execution so we can
|
|
441
|
+
update the status of any granules/PDRs that don't exist in the initial execution
|
|
442
|
+
input.
|
|
443
|
+
|
|
444
|
+
Falls back to overall execution input.
|
|
407
445
|
|
|
408
446
|
**Kind**: global function
|
|
409
|
-
**Returns**: <code>Object</code> -
|
|
447
|
+
**Returns**: <code>Object</code> - - CumulusMessage Execution step message or execution input message
|
|
410
448
|
|
|
411
449
|
| Param | Type | Description |
|
|
412
450
|
| --- | --- | --- |
|
|
413
|
-
|
|
|
451
|
+
| inputCumulusMessage | <code>Object</code> | Workflow execution input message |
|
|
452
|
+
| getExecutionHistoryFunction | <code>function</code> | Testing override for mock/etc of StepFunctions.getExecutionHistory |
|
|
414
453
|
|
|
415
454
|
|
|
416
455
|
## About Cumulus
|
package/StepFunctions.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export declare const getFailedStepName: (events: AWS.StepFunctions.HistoryEvent[
|
|
|
50
50
|
* Finds all failed execution events and returns the last one in the list.
|
|
51
51
|
*
|
|
52
52
|
* @param {Array<HistoryEventList>} events - array of AWS Stepfunction execution HistoryEvents
|
|
53
|
-
* @returns {
|
|
53
|
+
* @returns {HistoryEventList | undefined} - the last lambda or activity that failed in the
|
|
54
54
|
* event array, or an empty array.
|
|
55
55
|
*/
|
|
56
56
|
export declare const lastFailedEventStep: (events: AWS.StepFunctions.HistoryEvent[]) => AWS.StepFunctions.HistoryEvent | undefined;
|
package/StepFunctions.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -138,7 +142,7 @@ exports.getFailedStepName = getFailedStepName;
|
|
|
138
142
|
* Finds all failed execution events and returns the last one in the list.
|
|
139
143
|
*
|
|
140
144
|
* @param {Array<HistoryEventList>} events - array of AWS Stepfunction execution HistoryEvents
|
|
141
|
-
* @returns {
|
|
145
|
+
* @returns {HistoryEventList | undefined} - the last lambda or activity that failed in the
|
|
142
146
|
* event array, or an empty array.
|
|
143
147
|
*/
|
|
144
148
|
const lastFailedEventStep = (events) => {
|
package/StepFunctions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepFunctions.js","sourceRoot":"","sources":["src/StepFunctions.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"StepFunctions.js","sourceRoot":"","sources":["src/StepFunctions.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWb,iDAAyC;AACzC,qDAA6B;AAC7B,qDAA6B;AAE7B,qEAAwE;AACxE,yEAAiG;AAEjG,gEAAkD;AAClD,6DAAqC;AAErC,6CAAsD;AAEtD,MAAM,GAAG,GAAG,IAAI,gBAAM,CAAC;IACrB,MAAM,EAAE,gCAAgC;CACzC,CAAC,CAAC;AAOH,MAAM,+BAA+B,GAAG,CACtC,eAAgC,EACR,EAAE;IAC1B,MAAM,SAAS,GAAuC;QACpD,OAAO,EAAE,QAAQ;QACjB,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE,SAAS;QAClB,SAAS,EAAE,WAAW;QACtB,SAAS,EAAE,QAAQ;KACpB,CAAC;IAEF,OAAO,SAAS,CAAC,eAAe,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACI,MAAM,qBAAqB,GAAG,KAAK,EACxC,KAEC,EACiB,EAAE;IACpB,IAAI,CAAC,KAAK,CAA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A+B,CACpD,cAAc,CAAC,MAAM,CAAC,MAAyB,CAChD,CAAC;IACF,IAAA,aAAG,EAAC,kBAAkB,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;IAEvD,IAAA,aAAG,EACD,kBAAkB,EAClB,iCAAiC,EACjC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAC/B,CAAC;IAEF,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAC;AA3BW,QAAA,mCAAmC,uCA2B9C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cumulus/message",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.3",
|
|
4
4
|
"description": "Utilities for building and parsing Cumulus messages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"GIBS",
|
|
@@ -38,16 +38,17 @@
|
|
|
38
38
|
"author": "Cumulus Authors",
|
|
39
39
|
"license": "Apache-2.0",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@cumulus/aws-client": "10.
|
|
42
|
-
"@cumulus/common": "10.
|
|
43
|
-
"@cumulus/errors": "10.
|
|
44
|
-
"@cumulus/logger": "10.
|
|
45
|
-
"@cumulus/types": "10.
|
|
41
|
+
"@cumulus/aws-client": "10.1.3",
|
|
42
|
+
"@cumulus/common": "10.1.3",
|
|
43
|
+
"@cumulus/errors": "10.1.3",
|
|
44
|
+
"@cumulus/logger": "10.1.3",
|
|
45
|
+
"@cumulus/types": "10.1.3",
|
|
46
46
|
"jsonpath-plus": "^3.0.0",
|
|
47
|
-
"lodash": "^4.17.
|
|
47
|
+
"lodash": "^4.17.21",
|
|
48
48
|
"uuid": "^8.2.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/uuid": "^8.0.0"
|
|
52
|
-
}
|
|
52
|
+
},
|
|
53
|
+
"gitHead": "3dfabef58c4647d3ae5a64997bacaad5d6b274e1"
|
|
53
54
|
}
|
package/src/Collections.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
import { Message } from '@cumulus/types';
|
|
4
|
+
const collectionIdSeparator = '___';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Utility functions for generating collection information or parsing collection information
|
|
@@ -17,8 +18,6 @@ type CollectionInfo = {
|
|
|
17
18
|
version: string
|
|
18
19
|
};
|
|
19
20
|
|
|
20
|
-
export const collectionIdSeparator = '___';
|
|
21
|
-
|
|
22
21
|
/**
|
|
23
22
|
* Returns the collection ID.
|
|
24
23
|
*
|
|
@@ -37,24 +36,24 @@ export const constructCollectionId = (name: string, version: string) =>
|
|
|
37
36
|
*
|
|
38
37
|
* @param {string} collectionId - collectionId used in elasticsearch index
|
|
39
38
|
* @returns {Object} name and version as object
|
|
40
|
-
*
|
|
41
|
-
* @alias module:Collections
|
|
42
39
|
*/
|
|
43
40
|
export const deconstructCollectionId = (collectionId: string) => {
|
|
44
41
|
let name;
|
|
45
42
|
let version;
|
|
46
43
|
try {
|
|
47
|
-
|
|
44
|
+
const last = collectionId.lastIndexOf(collectionIdSeparator);
|
|
45
|
+
name = collectionId.substring(0, last);
|
|
46
|
+
version = collectionId.substring(last + collectionIdSeparator.length);
|
|
47
|
+
if (name && version) {
|
|
48
|
+
return {
|
|
49
|
+
name,
|
|
50
|
+
version,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
48
53
|
} catch (error) {
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
if (name && version) {
|
|
52
|
-
return {
|
|
53
|
-
name,
|
|
54
|
-
version,
|
|
55
|
-
};
|
|
54
|
+
// do nothing, error thrown below
|
|
56
55
|
}
|
|
57
|
-
throw new Error(`invalid collectionId: ${collectionId}`);
|
|
56
|
+
throw new Error(`invalid collectionId: ${JSON.stringify(collectionId)}`);
|
|
58
57
|
};
|
|
59
58
|
|
|
60
59
|
/**
|
package/src/Executions.ts
CHANGED
|
@@ -11,31 +11,9 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import isString from 'lodash/isString';
|
|
14
|
-
import isNil from 'lodash/isNil';
|
|
15
|
-
import omitBy from 'lodash/omitBy';
|
|
16
|
-
|
|
17
14
|
import { Message } from '@cumulus/types';
|
|
18
|
-
import { ExecutionRecord } from '@cumulus/types/api/executions';
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
getMessageAsyncOperationId,
|
|
22
|
-
} from './AsyncOperations';
|
|
23
|
-
import {
|
|
24
|
-
getCollectionIdFromMessage,
|
|
25
|
-
} from './Collections';
|
|
26
|
-
import {
|
|
27
|
-
getMetaStatus,
|
|
28
|
-
getMessageWorkflowTasks,
|
|
29
|
-
getMessageWorkflowStartTime,
|
|
30
|
-
getMessageWorkflowStopTime,
|
|
31
|
-
getMessageWorkflowName,
|
|
32
|
-
getWorkflowDuration,
|
|
33
|
-
} from './workflows';
|
|
34
|
-
import { parseException } from './utils';
|
|
35
15
|
|
|
36
|
-
|
|
37
|
-
payload: object
|
|
38
|
-
}
|
|
16
|
+
import { getMetaStatus } from './workflows';
|
|
39
17
|
|
|
40
18
|
/**
|
|
41
19
|
* Build execution ARN from a state machine ARN and execution name
|
|
@@ -174,14 +152,14 @@ export const getMessageCumulusVersion = (
|
|
|
174
152
|
/**
|
|
175
153
|
* Get the workflow original payload, if any.
|
|
176
154
|
*
|
|
177
|
-
* @param {
|
|
155
|
+
* @param {Message.CumulusMessage} message - A workflow message object
|
|
178
156
|
* @returns {unknown|undefined} The workflow original payload
|
|
179
157
|
*
|
|
180
158
|
* @alias module:Executions
|
|
181
159
|
*/
|
|
182
160
|
export const getMessageExecutionOriginalPayload = (
|
|
183
|
-
message:
|
|
184
|
-
) => {
|
|
161
|
+
message: Message.CumulusMessage
|
|
162
|
+
): unknown | undefined => {
|
|
185
163
|
const status = getMetaStatus(message);
|
|
186
164
|
return status === 'running' ? message.payload : undefined;
|
|
187
165
|
};
|
|
@@ -189,62 +167,14 @@ export const getMessageExecutionOriginalPayload = (
|
|
|
189
167
|
/**
|
|
190
168
|
* Get the workflow final payload, if any.
|
|
191
169
|
*
|
|
192
|
-
* @param {
|
|
170
|
+
* @param {Message.CumulusMessage} message - A workflow message object
|
|
193
171
|
* @returns {unknown|undefined} The workflow final payload
|
|
194
172
|
*
|
|
195
173
|
* @alias module:Executions
|
|
196
174
|
*/
|
|
197
175
|
export const getMessageExecutionFinalPayload = (
|
|
198
|
-
message:
|
|
199
|
-
) => {
|
|
176
|
+
message: Message.CumulusMessage
|
|
177
|
+
): unknown | undefined => {
|
|
200
178
|
const status = getMetaStatus(message);
|
|
201
179
|
return status === 'running' ? undefined : message.payload;
|
|
202
180
|
};
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Generate an execution record for the API from the message.
|
|
206
|
-
*
|
|
207
|
-
* @param {MessageWithPayload} message - A workflow message object
|
|
208
|
-
* @param {string} [updatedAt] - Optional updated timestamp to apply to record
|
|
209
|
-
* @returns {ExecutionRecord} An execution API record
|
|
210
|
-
*
|
|
211
|
-
* @alias module:Executions
|
|
212
|
-
*/
|
|
213
|
-
export const generateExecutionApiRecordFromMessage = (
|
|
214
|
-
message: MessageWithPayload,
|
|
215
|
-
updatedAt = Date.now()
|
|
216
|
-
): ExecutionRecord => {
|
|
217
|
-
const arn = getMessageExecutionArn(message);
|
|
218
|
-
if (isNil(arn)) throw new Error('Unable to determine execution ARN from Cumulus message');
|
|
219
|
-
|
|
220
|
-
const status = getMetaStatus(message);
|
|
221
|
-
if (!status) throw new Error('Unable to determine status from Cumulus message');
|
|
222
|
-
|
|
223
|
-
const now = Date.now();
|
|
224
|
-
const workflowStartTime = getMessageWorkflowStartTime(message);
|
|
225
|
-
const workflowStopTime = getMessageWorkflowStopTime(message);
|
|
226
|
-
const collectionId = getCollectionIdFromMessage(message);
|
|
227
|
-
|
|
228
|
-
const record: ExecutionRecord = {
|
|
229
|
-
name: getMessageExecutionName(message),
|
|
230
|
-
cumulusVersion: getMessageCumulusVersion(message),
|
|
231
|
-
arn,
|
|
232
|
-
asyncOperationId: getMessageAsyncOperationId(message),
|
|
233
|
-
parentArn: getMessageExecutionParentArn(message),
|
|
234
|
-
execution: getExecutionUrlFromArn(arn),
|
|
235
|
-
tasks: getMessageWorkflowTasks(message),
|
|
236
|
-
error: parseException(message.exception),
|
|
237
|
-
type: getMessageWorkflowName(message),
|
|
238
|
-
collectionId,
|
|
239
|
-
status,
|
|
240
|
-
createdAt: workflowStartTime,
|
|
241
|
-
timestamp: now,
|
|
242
|
-
updatedAt,
|
|
243
|
-
originalPayload: getMessageExecutionOriginalPayload(message),
|
|
244
|
-
finalPayload: getMessageExecutionFinalPayload(message),
|
|
245
|
-
duration: getWorkflowDuration(workflowStartTime, workflowStopTime),
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
const updated = <ExecutionRecord>omitBy(record, isNil);
|
|
249
|
-
return updated;
|
|
250
|
-
};
|