Skip to content
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

Cumulus 2891 #3593

Open
wants to merge 74 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
44597f7
update files with ecs-client
kwartrosa Dec 13, 2023
98be5eb
update all files
kwartrosa Dec 18, 2023
0b9f014
updated 3 files
kwartrosa Dec 18, 2023
8ebdf8d
update test-services
kwartrosa Dec 19, 2023
bbe2499
update ecs
kwartrosa Dec 19, 2023
95e8e3f
update ecs
kwartrosa Dec 19, 2023
4cdf2ab
update ecs file
kwartrosa Dec 19, 2023
a406365
update async
kwartrosa Dec 19, 2023
c4fdfd6
change variable
kwartrosa Dec 19, 2023
14251b3
update async_op file
kwartrosa Dec 21, 2023
323a970
low hanging linter error fixes
Dec 27, 2023
9288bd4
remove unnecesary async test function
Dec 27, 2023
354dfdf
ecs().listClusters needs to promise (in spite of docs saying it's imp…
Jan 2, 2024
344c5a2
WIP solved double wrap error but failing to capture ecs clusters
Jan 2, 2024
3273422
actually not needed, had to update mocking
Jan 2, 2024
d864695
remove promises in ecs mocking
Jan 2, 2024
9e827b5
further mocking moved to non-promise
Jan 2, 2024
9552b6d
fix missing semi-colon
Jan 2, 2024
e33df37
debug printout
Jan 3, 2024
1281027
debug printout
Jan 3, 2024
ef23312
debug printout
Jan 3, 2024
82fe4b7
debugging to see if timeouts occur in bamboo
Jan 4, 2024
6eb389b
debugging to see if timeouts occur in bamboo
Jan 4, 2024
9f50e5e
debugging to see if timeouts occur in bamboo
Jan 4, 2024
bb92470
merge master
Jan 24, 2024
18d15a2
updated files
kwartrosa Jan 26, 2024
e5b6ea4
Update CHANGELOG.md
kwartrosa Jan 31, 2024
82b11d1
merge master
Jan 31, 2024
895e076
removed leftover debug timeout
Jan 31, 2024
7335565
fixed changes
kwartrosa Jan 31, 2024
66fbac6
Merge branch 'CUMULUS-2891' of https://github.com/nasa/cumulus into C…
kwartrosa Jan 31, 2024
9e5d411
fixed merge conflict
kwartrosa Jan 31, 2024
d80908a
update from review
kwartrosa Jan 31, 2024
460e0e5
update from review
kwartrosa Feb 1, 2024
d83eefc
updated
kwartrosa Feb 2, 2024
b833f8d
update files
kwartrosa Feb 5, 2024
7716d04
debug code
kwartrosa Feb 5, 2024
6c8dc38
update after lint
kwartrosa Feb 6, 2024
1590f2b
update inventory
kwartrosa Feb 8, 2024
af69b27
update inventory
kwartrosa Feb 8, 2024
8357520
update inventory
kwartrosa Feb 8, 2024
e6bacd5
update inventory
kwartrosa Feb 8, 2024
623ece7
Merge branch 'CUMULUS-2891' of https://github.com/nasa/cumulus into C…
Nnaga1 Feb 9, 2024
31895fe
huddle review results fix
Nnaga1 Feb 9, 2024
201370f
Merge branch 'master' into CUMULUS-2891
Nnaga1 Feb 9, 2024
6b6bbf9
fix unit tests
Nnaga1 Feb 10, 2024
5cfbe4f
Merge branch 'CUMULUS-2891' of https://github.com/nasa/cumulus into C…
Nnaga1 Feb 10, 2024
c17011a
update from review
kwartrosa Feb 12, 2024
dcb9eec
Update package.json
kwartrosa Feb 12, 2024
939e6d7
Update package.json
kwartrosa Feb 12, 2024
5785fb7
Update package.json
kwartrosa Feb 12, 2024
93b0857
Update packages/aws-client/src/types.ts
kwartrosa Feb 12, 2024
0adbdcb
Merge branch 'master' into CUMULUS-2891
kwartrosa Feb 12, 2024
4c581c9
update
kwartrosa Feb 12, 2024
6d0cbe2
Update types.ts
kwartrosa Feb 12, 2024
6d14b80
update lint
kwartrosa Feb 12, 2024
a4cdd79
Merge branch 'CUMULUS-2891' of https://github.com/nasa/cumulus into C…
Nnaga1 Feb 12, 2024
c2b66c6
Merge branch 'CUMULUS-2891' of https://github.com/nasa/cumulus into C…
kwartrosa Feb 12, 2024
014d2f9
lint issue resolved
kwartrosa Feb 12, 2024
97a69e5
update inventory
kwartrosa Feb 12, 2024
9fddb6a
update ecsStub
kwartrosa Feb 13, 2024
02c3ed0
update statefile
kwartrosa Feb 13, 2024
3914b32
Merge branch 'master' into CUMULUS-2891
kwartrosa Feb 13, 2024
628d7eb
update with stub
kwartrosa Feb 13, 2024
a70eba2
update aws
kwartrosa Feb 13, 2024
8f7ecf1
ecs change
kwartrosa Feb 13, 2024
b9558e4
update ecs
kwartrosa Feb 13, 2024
3ae5084
update ecs
kwartrosa Feb 13, 2024
d95782a
update ecs
kwartrosa Feb 13, 2024
3f1d59f
Merge branch 'CUMULUS-2891' of https://github.com/nasa/cumulus into C…
Nnaga1 Feb 13, 2024
57fe1f8
update services
kwartrosa Feb 13, 2024
17745e2
Merge branch 'CUMULUS-2891' of https://github.com/nasa/cumulus into C…
Nnaga1 Feb 13, 2024
3cd232e
fixing stubs
Nnaga1 Feb 13, 2024
7bf5231
deleted comment
kwartrosa Feb 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ instructions](https://nasa.github.io/cumulus/docs/upgrade-notes/upgrade-rds-clus
migration from Aurora PostgreSQl v11 to v13. See Migration Notes for more details.
- **CUMULUS-3564**
- Update webpack configuration to explicitly disable chunking
- **CUMULUS-2891**
- Updated ECS code to aws sdk v3
- **CUMULUS-2895**
- Updated KMS code to aws sdk v3
- **CUMULUS-2888**
Expand Down
1 change: 1 addition & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@cumulus/test-processing": "18.2.0"
},
"devDependencies": {
"@aws-sdk/client-ecs": "^3.447.0",
"@cumulus/test-data": "18.2.0"
}
}
2 changes: 1 addition & 1 deletion example/spec/helpers/ecsHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function findAsyncOperationTaskDefinitionForDeployment(stackName) {
sort: 'ASC',
};
// eslint-disable-next-line no-await-in-loop
const response = await ecs().listTaskDefinitions(params).promise();
const response = await ecs().listTaskDefinitions(params);
nextToken = response.nextToken;
const taskDefinitionArns = response.taskDefinitionArns;
taskDefinitionArn = taskDefinitionArns[taskDefinitionArns.length - 1];
Expand Down
14 changes: 6 additions & 8 deletions example/spec/parallel/testAPI/bulkDeleteFailureSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const { fakeGranuleFactoryV2, fakeExecutionFactoryV2 } = require('@cumulus/api/lib/testUtils');
const { deleteAsyncOperation, getAsyncOperation } = require('@cumulus/api-client/asyncOperations');
const { ecs } = require('@cumulus/aws-client/services');
const { waitUntilTasksStopped } = require('@aws-sdk/client-ecs');
const {
getClusterArn,
loadCollection,
Expand Down Expand Up @@ -140,21 +141,18 @@ describe('POST /granules/bulkDelete with a failed bulk delete operation', () =>
const describeTasksResponse = await ecs().describeTasks({
cluster: clusterArn,
tasks: [taskArn],
}).promise();
});

expect(describeTasksResponse.tasks.length).toEqual(1);
});

it('eventually generates the correct output', async () => {
expect(beforeAllSucceeded).toBeTrue();

await ecs().waitFor(
'tasksStopped',
{
cluster: clusterArn,
tasks: [taskArn],
}
).promise();
await waitUntilTasksStopped(
{ client: ecs(), maxWaitTime: 600, maxDelay: 1, minDelay: 1 },
{ cluster: clusterArn, tasks: [taskArn] }
);

const asyncOperation = await getAsyncOperation({
prefix: config.stackName,
Expand Down
14 changes: 6 additions & 8 deletions example/spec/parallel/testAPI/bulkDeleteSuccessSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const { waitUntilTasksStopped } = require('@aws-sdk/client-ecs');
const get = require('lodash/get');
const pAll = require('p-all');

Expand Down Expand Up @@ -254,21 +255,18 @@ describe('POST /granules/bulkDelete', () => {
const describeTasksResponse = await ecs().describeTasks({
cluster: clusterArn,
tasks: [taskArn],
}).promise();
});

expect(describeTasksResponse.tasks.length).toEqual(1);
});

it('eventually generates the correct output', async () => {
expect(beforeAllSucceeded).toBeTrue();

await ecs().waitFor(
'tasksStopped',
{
cluster: clusterArn,
tasks: [taskArn],
}
).promise();
await waitUntilTasksStopped(
{ client: ecs(), maxWaitTime: 600, maxDelay: 1, minDelay: 1 },
{ cluster: clusterArn, tasks: [taskArn] }
);

const asyncOperation = await getAsyncOperation({
prefix,
Expand Down
15 changes: 7 additions & 8 deletions example/spec/parallel/testAPI/bulkOperationsSuccessSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const { waitUntilTasksStopped } = require('@aws-sdk/client-ecs');

const get = require('lodash/get');
const pAll = require('p-all');

Expand Down Expand Up @@ -258,7 +260,7 @@ describe('POST /granules/bulk', () => {
const describeTasksResponse = await ecs().describeTasks({
cluster: clusterArn,
tasks: [taskArn],
}).promise();
});

expect(describeTasksResponse.tasks.length).toEqual(1);
}
Expand All @@ -267,13 +269,10 @@ describe('POST /granules/bulk', () => {
it('eventually generates the correct output', async () => {
if (beforeAllFailed) fail('beforeAll() failed');
else {
await ecs().waitFor(
'tasksStopped',
{
cluster: clusterArn,
tasks: [taskArn],
}
).promise();
await waitUntilTasksStopped(
{ client: ecs(), maxWaitTime: 600, maxDelay: 1, minDelay: 1 },
{ cluster: clusterArn, tasks: [taskArn] }
);

const asyncOperation = await getAsyncOperation({
prefix,
Expand Down
13 changes: 6 additions & 7 deletions example/spec/serial/AsyncOperationRunnerFailingLambdaSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const { waitUntilTasksStopped } = require('@aws-sdk/client-ecs');

const get = require('lodash/get');
const { v4: uuidv4 } = require('uuid');
const { createAsyncOperation, deleteAsyncOperation } = require('@cumulus/api-client/asyncOperations');
Expand Down Expand Up @@ -70,13 +72,10 @@ describe('The AsyncOperation task runner executing a failing lambda function', (

taskArn = runTaskResponse.tasks[0].taskArn;

await ecs().waitFor(
'tasksStopped',
{
cluster,
tasks: [taskArn],
}
).promise();
await waitUntilTasksStopped(
{ client: ecs(), maxWaitTime: 600, maxDelay: 1, minDelay: 1 },
{ cluster: cluster, tasks: [taskArn] }
);

asyncOperation = await waitForAsyncOperationStatus({
id: asyncOperationId,
Expand Down
13 changes: 6 additions & 7 deletions example/spec/serial/AsyncOperationRunnerNonExistentLambdaSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const { waitUntilTasksStopped } = require('@aws-sdk/client-ecs');

const { v4: uuidv4 } = require('uuid');

const { createAsyncOperation, deleteAsyncOperation } = require('@cumulus/api-client/asyncOperations');
Expand Down Expand Up @@ -59,13 +61,10 @@ describe('The AsyncOperation task runner running a non-existent lambda function'

const taskArn = runTaskResponse.tasks[0].taskArn;

await ecs().waitFor(
'tasksStopped',
{
cluster,
tasks: [taskArn],
}
).promise();
await waitUntilTasksStopped(
{ client: ecs(), maxWaitTime: 600, maxDelay: 1, minDelay: 1 },
{ cluster: cluster, tasks: [taskArn] }
);

asyncOperation = await waitForAsyncOperationStatus({
id: asyncOperationId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const { waitUntilTasksStopped } = require('@aws-sdk/client-ecs');
const get = require('lodash/get');
const { v4: uuidv4 } = require('uuid');
const { startECSTask } = require('@cumulus/async-operations');
Expand Down Expand Up @@ -67,13 +68,10 @@ describe('The AsyncOperation task runner with a non-existent payload', () => {

taskArn = runTaskResponse.tasks[0].taskArn;

await ecs().waitFor(
'tasksStopped',
{
cluster,
tasks: [taskArn],
}
).promise();
await waitUntilTasksStopped(
{ client: ecs(), maxWaitTime: 600, maxDelay: 1, minDelay: 1 },
{ cluster: cluster, tasks: [taskArn] }
);

asyncOperation = await waitForAsyncOperationStatus({
id: asyncOperationId,
Expand Down
12 changes: 5 additions & 7 deletions example/spec/serial/AsyncOperationRunnerNonJsonPayloadSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const { waitUntilTasksStopped } = require('@aws-sdk/client-ecs');
const get = require('lodash/get');
const { v4: uuidv4 } = require('uuid');

Expand Down Expand Up @@ -74,13 +75,10 @@ describe('The AsyncOperation task runner with a non-JSON payload', () => {

taskArn = runTaskResponse.tasks[0].taskArn;

await ecs().waitFor(
'tasksStopped',
{
cluster,
tasks: [taskArn],
}
).promise();
await waitUntilTasksStopped(
{ client: ecs(), maxWaitTime: 600, maxDelay: 1, minDelay: 1 },
{ cluster: cluster, tasks: [taskArn] }
);

asyncOperation = await waitForAsyncOperationStatus({
id: asyncOperationId,
Expand Down
13 changes: 6 additions & 7 deletions example/spec/serial/AsyncOperationRunnerSuccessfulLambdaSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const { waitUntilTasksStopped } = require('@aws-sdk/client-ecs');

const get = require('lodash/get');
const { v4: uuidv4 } = require('uuid');
const { createAsyncOperation, deleteAsyncOperation, listAsyncOperations } = require('@cumulus/api-client/asyncOperations');
Expand Down Expand Up @@ -74,13 +76,10 @@ describe('The AsyncOperation task runner executing a successful lambda function'

taskArn = runTaskResponse.tasks[0].taskArn;

await ecs().waitFor(
'tasksStopped',
{
cluster,
tasks: [taskArn],
}
).promise();
await waitUntilTasksStopped(
{ client: ecs(), maxWaitTime: 600, maxDelay: 1, minDelay: 1 },
{ cluster: cluster, tasks: [taskArn] }
);

asyncOperation = await waitForAsyncOperationStatus({
id: asyncOperationId,
Expand Down
1 change: 1 addition & 0 deletions packages/async-operations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"author": "Cumulus Authors",
"license": "Apache-2.0",
"dependencies": {
"@aws-sdk/client-ecs": "^3.477.0",
"@aws-sdk/client-lambda": "^3.447.0",
"@cumulus/aws-client": "18.2.0",
"@cumulus/db": "18.2.0",
Expand Down
8 changes: 3 additions & 5 deletions packages/async-operations/src/async_operations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ECS } from 'aws-sdk';
import { RunTaskCommandOutput } from '@aws-sdk/client-ecs';
import { Knex } from 'knex';
import { FunctionConfiguration } from '@aws-sdk/client-lambda';
import { ecs, s3, lambda } from '@cumulus/aws-client/services';
Expand All @@ -13,8 +13,6 @@ import {
import Logger from '@cumulus/logger';
import { ApiAsyncOperation, AsyncOperationType } from '@cumulus/types/api/async_operations';
import { v4 as uuidv4 } from 'uuid';
import type { AWSError } from 'aws-sdk/lib/error';
import type { PromiseResult } from 'aws-sdk/lib/request';

import type {
AsyncOperationPgModelObject,
Expand All @@ -30,7 +28,7 @@ const {

const logger = new Logger({ sender: '@cumulus/async-operation' });

type StartEcsTaskReturnType = Promise<PromiseResult<ECS.RunTaskResponse, AWSError>>;
type StartEcsTaskReturnType = Promise<RunTaskCommandOutput>;

export const getLambdaConfiguration = async (
functionName: string
Expand Down Expand Up @@ -120,7 +118,7 @@ export const startECSTask = async ({
},
],
},
}).promise();
});
};

export const createAsyncOperation = async (
Expand Down
8 changes: 2 additions & 6 deletions packages/async-operations/tests/test-async_operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,8 @@ test.before(async (t) => {
ecsClient = ecs();
ecsClient.runTask = (params) => {
stubbedEcsRunTaskParams = params;
return {
promise: () => {
if (!stubbedEcsRunTaskResult) return Promise.reject(new Error('stubbedEcsRunTaskResult has not yet been set'));
return Promise.resolve(stubbedEcsRunTaskResult);
},
};
if (!stubbedEcsRunTaskResult) return Promise.reject(new Error('stubbedEcsRunTaskResult has not yet been set'));
return Promise.resolve(stubbedEcsRunTaskResult);
};

t.context.functionConfig = {
Expand Down
1 change: 1 addition & 0 deletions packages/aws-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@aws-sdk/client-s3": "^3.447.0",
"@aws-sdk/client-sns": "^3.447.0",
"@aws-sdk/client-sqs": "^3.447.0",
"@aws-sdk/client-ecs": "^3.447.0",
"@aws-sdk/lib-dynamodb": "^3.447.0",
"@aws-sdk/lib-storage": "^3.447.0",
"@aws-sdk/s3-request-presigner": "^3.447.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/aws-client/src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import { S3 } from '@aws-sdk/client-s3';
import { SQS } from '@aws-sdk/client-sqs';
import { DynamoDBDocument, TranslateConfig } from '@aws-sdk/lib-dynamodb';
import { SNS } from '@aws-sdk/client-sns';
import { ECS } from '@aws-sdk/client-ecs';
import * as AWS from 'aws-sdk';

import awsClient from './client';

export const apigateway = awsClient(APIGatewayClient, '2015-07-09');
export const ecs = awsClient(AWS.ECS, '2014-11-13');
export const ecs = awsClient(ECS, '2014-11-13');
export const ec2 = awsClient(AWS.EC2, '2016-11-15');
export const s3 = awsClient(S3, '2006-03-01');
export const kinesis = awsClient(Kinesis, '2013-12-02');
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-client/src/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const localStackPorts = {
DynamoDBClient: 4566,
DynamoDBStreamsClient: 4566,
ec2: 4566,
ecs: 4566,
ECS: 4566,
es: 4566,
firehose: 4566,
iam: 4566,
Expand Down
20 changes: 17 additions & 3 deletions packages/aws-client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,23 @@ import { Kinesis } from '@aws-sdk/client-kinesis';
import { KMS } from '@aws-sdk/client-kms';
import { Lambda } from '@aws-sdk/client-lambda';
import { S3 } from '@aws-sdk/client-s3';
import { ECS } from '@aws-sdk/client-ecs';
import { SNS } from '@aws-sdk/client-sns';
import { SQS } from '@aws-sdk/client-sqs';

export type AWSClientTypes = APIGatewayClient | CloudFormation | CloudWatchEvents | DynamoDB
| DynamoDBClient | DynamoDBStreamsClient | KMS | Kinesis | Lambda | S3 | SNS | SQS
| AWS.Service | AWS.DynamoDB.DocumentClient;
export type AWSClientTypes =
APIGatewayClient |
DynamoDB |
DynamoDBClient |
DynamoDBStreamsClient |
Lambda |
ECS |
S3 |
SNS |
SQS |
CloudWatchEvents |
CloudFormation |
Kinesis |
KMS |
AWS.Service |
AWS.DynamoDB.DocumentClient;