-
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
CUMULUS-3243:Updated granule delete logic #3338
Changes from 1 commit
c97d42f
58ec8d1
e48a3e6
697d166
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ const { | |
DeletePublishedGranule, | ||
ValidationError, | ||
} = require('@cumulus/errors'); | ||
const { RecordDoesNotExist } = require('@cumulus/errors'); | ||
const { | ||
generateMoveFileParams, | ||
} = require('@cumulus/ingest/granule'); | ||
|
@@ -482,6 +483,19 @@ class Granule extends Manager { | |
} | ||
return executionDescription; | ||
} | ||
|
||
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. When granule is not in dynamoDB, unpublish has error: |
||
async update(itemKeys, updates = {}, fieldsToDelete = []) { | ||
let granule; | ||
try { | ||
granule = await super.update(itemKeys, updates, fieldsToDelete); | ||
} catch (error) { | ||
if (!(error instanceof RecordDoesNotExist)) { | ||
throw error; | ||
} | ||
logger.info(`Granule record ${JSON.stringify(itemKeys)} does not exist.`); | ||
} | ||
return granule; | ||
} | ||
} | ||
|
||
module.exports = Granule; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,11 +126,13 @@ const deleteGranuleAndFiles = async (params: { | |
await granulePgModel.delete(trx, { | ||
cumulus_id: pgGranule.cumulus_id, | ||
}); | ||
await granuleModelClient.delete(dynamoGranule); | ||
if (dynamoGranule) { | ||
await granuleModelClient.delete(dynamoGranule); | ||
} | ||
await deleteGranule({ | ||
esClient, | ||
granuleId: dynamoGranule.granuleId, | ||
collectionId: dynamoGranule.collectionId, | ||
granuleId: pgGranule.granule_id, | ||
collectionId: granuleToPublishToSns.collectionId, | ||
index: process.env.ES_INDEX, | ||
ignore: [404], | ||
}); | ||
|
@@ -145,7 +147,7 @@ const deleteGranuleAndFiles = async (params: { | |
deletedFiles: files, | ||
}; | ||
} catch (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. When granule is not in dynamoDB, delete has error: |
||
logger.debug(`Error deleting granule with ID ${pgGranule.granule_id} or S3 files ${JSON.stringify(dynamoGranule.files)}: ${JSON.stringify(error)}`); | ||
logger.debug(`Error deleting granule with ID ${pgGranule.granule_id} or S3 files ${JSON.stringify(files)}: ${JSON.stringify(error)}`); | ||
// Delete is idempotent, so there may not be a DynamoDB | ||
// record to recreate | ||
if (dynamoGranule) { | ||
|
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.
The change is already in master branch