Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
migration and standard migrations are consistent and produce identical database schemas.

### Changed
- **CSD-99**
- Changed the `CMR` class to a singleton
- Changed `cmr-utils` functions that call the `CMR` class functions to retry upon 401 authentication failures
- Added functions `checkRefreshLaunchpadToken` and `refreshLaunchpadToken` to the `CMR` class to be invoked upon a 401 authentication failure which removes and/or retrieves a valid launchpad token
- Added functions to the `launchpad-auth` package which adds a lock file for token creation, removes an invalid token, and checks s3 for the token and lock file
- **CUMULUS-4694**
- Add flag to enable/disable iceberg replication
- **CUMULUS-4882**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
const { deleteExecution } = require('@cumulus/api-client/executions');
const { deleteCollection } = require('@cumulus/api-client/collections');
const fs = require('fs');
const { addCollections, addProviders } = require('@cumulus/integration-tests');
const { deleteS3Object, s3ObjectExists } = require('@cumulus/aws-client/S3');
const { constructCollectionId } = require('@cumulus/message/Collections');
const {
getGranule,
removePublishedGranule,
bulkChangeCollection,
} = require('@cumulus/api-client/granules');
const { getExecution } = require('@cumulus/api-client/executions');
Expand All @@ -26,7 +23,7 @@ const {
} = require('../../helpers/testUtils');
const { waitForApiStatus } = require('../../helpers/apiUtils');
const { setupTestGranuleForIngest } = require('../../helpers/granuleUtils');
const { collectionExists } = require('../../helpers/Collections');
const { collectionExists, removeCollectionAndAllDependencies } = require('../../helpers/Collections');
const workflowName = 'IngestAndPublishGranule';

const granuleRegex = '^MOD09GQ\\.A[\\d]{7}\\.[\\w]{6}\\.006\\.[\\d]{13}$';
Expand All @@ -51,7 +48,7 @@ async function getCMRClient(config) {
Object.entries(lambdaConfig.Environment.Variables).forEach(([key, value]) => {
process.env[key] = value;
});
return new CMR(await getCmrSettings());
return CMR.getInstance(await getCmrSettings());
}

describe('The ChangeGranuleCollections workflow', () => {
Expand All @@ -63,7 +60,6 @@ describe('The ChangeGranuleCollections workflow', () => {
let granuleId;
let finalFiles;
let beforeAllFailed = false;
let ingestExecutionArn;
let moveExecutionArn;
let collection;
let sourceCollectionId;
Expand Down Expand Up @@ -128,7 +124,7 @@ describe('The ChangeGranuleCollections workflow', () => {
testDataFolder
);
granuleId = inputPayload.granules[0].granuleId;
ingestExecutionArn = await buildAndStartWorkflow(
await buildAndStartWorkflow(
stackName,
config.bucket,
workflowName,
Expand Down Expand Up @@ -205,21 +201,19 @@ describe('The ChangeGranuleCollections workflow', () => {
}
let cleanup = [];
cleanup = cleanup.concat([
deleteExecution({ prefix: stackName, executionArn: ingestExecutionArn }),
deleteExecution({ prefix: stackName, executionArn: moveExecutionArn }),
deleteCollection({
removeCollectionAndAllDependencies({
prefix: stackName,
collectionName: collection.name,
collectionVersion: collection.version,
}),
deleteCollection({
prefix: stackName,
collectionName: targetCollection.name,
collectionVersion: targetCollection.version,
collection: {
collectionName: collection.name,
collectionVersion: collection.version,
},
}),
removePublishedGranule({
removeCollectionAndAllDependencies({
prefix: stackName,
granuleId,
collection: {
collectionName: targetCollection.name,
collectionVersion: targetCollection.version,
},
}),
]);
await Promise.all(cleanup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ const createCmrClient = async (config) => {
process.env[key] = value;
});
const cmrSettings = await getCmrSettings();
return new CMR(cmrSettings);
return CMR.getInstance(cmrSettings);
};

// ingest a granule xml to CMR
Expand Down
2 changes: 1 addition & 1 deletion example/spec/parallel/testAPI/cmrTokenSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('When using Earthdata Login Token from CMR', () => {
username = process.env.EARTHDATA_USERNAME;
password = process.env.EARTHDATA_PASSWORD;

cmrObject = new CMR({
cmrObject = CMR.getInstance({
provider: 'provider',
username,
password,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/lib/granule-remove-from-cmr.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const _removeGranuleFromCmr = async (granule, collectionId, collectionCmrProvide
}

const cmrSettings = await cmrjsCmrUtils.getCmrSettings({ provider: collectionCmrProvider });
const cmr = new CMR(cmrSettings);
const cmr = CMR.getInstance(cmrSettings);
try {
metadata = await cmr.getGranuleMetadata(granule.cmr_link);
} catch (error) {
Expand Down
4 changes: 3 additions & 1 deletion packages/cmr-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@cumulus/aws-client": "22.1.1",
"@cumulus/common": "22.1.1",
"@cumulus/errors": "22.1.1",
"@cumulus/launchpad-auth": "22.1.1",
"@cumulus/logger": "22.1.1",
"got": "^11.8.5",
"jsonwebtoken": "^9.0.0",
Expand All @@ -48,6 +49,7 @@
"zod": "^3.20.2"
},
"devDependencies": {
"moment": "^2.30.1"
"moment": "^2.30.1",
"p-retry": "^4.2.0"
}
}
Loading
Loading