-
Notifications
You must be signed in to change notification settings - Fork 108
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
Jk/cumulus 3992 #3912
base: feature/CUMULUS-3751
Are you sure you want to change the base?
Jk/cumulus 3992 #3912
Conversation
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.
Looks great @Jkovarik. I recognize this is a WIP so if any of my comments end up OBE or unrelated, that's fine.
return returnCustomValidationErrors(res, body); | ||
} | ||
|
||
if (!process.env.system_bucket) { |
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.
Do we perhaps want to check these ENVs before we parse the payload?
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.
💯 6b1e57d
packages/api/endpoints/granules.js
Outdated
deconstructCollectionId(body.sourceCollectionId) | ||
); | ||
// check collection returned | ||
if (pgCollection === undefined) { |
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 believe the BaseModel get
will throw, not return undefined?
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.
Great catch - this was a leftover from an earlier implementation approach.
collection_cumulus_id: pgCollection.cumulus_id, | ||
}); | ||
query.select('granule_id'); | ||
query.limit(body.batchSize); |
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.
This defaults to 100, right? Will delete this comment if confirmed 😄
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.
Yes, zod has it set to default at 100
packages/api/endpoints/granules.js
Outdated
@@ -1229,6 +1379,7 @@ router.delete('/:collectionId/:granuleId', del); | |||
|
|||
module.exports = { | |||
bulkDelete, | |||
bulkMoveCollection, |
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.
This is pretty minor/unimportant but would bulkChangeCollection
or bulkUpdateCollection
make more sense? I think "Move" is probably the most accurate but if I'm reading this endpoint for the first time and I don't know what the endpoint does, I feel like "MoveCollection" is less self-explanatory... I think.
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.
UI is important though, and naming things is hard.
I don't hate bulk change collection...... 🤔
and neither does a huddle audience. TODO.
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.
packages/api/lib/rulesHelpers.js
Outdated
*/ | ||
async function buildPayload(rule) { | ||
// makes sure the workflow exists | ||
const bucket = getRequiredEnvVar('system_bucket'); | ||
const stack = getRequiredEnvVar('stackName'); | ||
const workflowFileKey = workflows.getWorkflowFileKey(stack, rule.workflow); | ||
const workflowFileKey = workflows.getWorkflowFileKey(stack, rule.workflow || ''); |
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.
Does this fix a specific issue where rule.workflow was coming in as undefined or something?
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.
Good question: No, it fixes the type assertions - rule.workflow can be undefined.
That said, it should probably be more properly fixed as such:
})) | ||
); | ||
// index PG Granules into ES | ||
await Promise.all( |
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.
Yeah, bummer. Do we want to add any comments or move ES-related setup to a place that's easily fenced off and removed for the forward release?
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.
Hmm, yeah, probably that's a good QOL refactor for the main merge. TODO.
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.
Check out 77c70b4
}); | ||
|
||
test.serial('bulkMoveCollection generates the proper payload and calls startExecution with it', async (t) => { | ||
process.env.CUMULUS_VERSION = 'fakeVersion'; |
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.
nit: prefer realistic values
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.
}; | ||
await bulkMoveCollection(req, res); | ||
t.is('Unable to find state machine ARN for workflow someDumbWorkflow', res.boom.badRequest.firstCall.args[0], 'Error message should match catch for getJsonS3Object'); | ||
}); |
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.
What about a test for a Collection with no Granules?
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.
Seems reasonable enough. 054cfa1 - may refactor/DRY that up a bit, but should cover the thought.
packages/api/endpoints/granules.js
Outdated
}, | ||
}); | ||
|
||
input.cumulus_meta = { ...input?.template.cumulus_meta, ...input.cumulus_meta }; |
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.
is this meant to be ...input.template?.cumulus_meta? I'm not sure what's happening here if input is undefined
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.
Yes - good catch. Functionally it shouldn't happen, but the return from buildPayload isn't certain to return a template value in cases where the s3 object is 0 byte/null/etc.
Summary: Summary of changes
Addresses CUMULUS-3992
Changes
See ticket/comments for more context.
PR Checklist