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

Jk/cumulus 3992 #3912

Open
wants to merge 27 commits into
base: feature/CUMULUS-3751
Choose a base branch
from
Open

Jk/cumulus 3992 #3912

wants to merge 27 commits into from

Conversation

Jkovarik
Copy link
Member

@Jkovarik Jkovarik commented Jan 29, 2025

Summary: Summary of changes

Addresses CUMULUS-3992

Changes

  • Update granules API to provide endpoint to fire off bulk granule collection move workflow
  • Updates existing feature integration test to use API endpoint to call step function

See ticket/comments for more context.

PR Checklist

  • Update CHANGELOG
  • Unit tests
  • Ad-hoc testing - Deploy changes and test manually
  • Integration tests

Copy link
Contributor

@npauzenga npauzenga left a 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) {
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 6b1e57d

deconstructCollectionId(body.sourceCollectionId)
);
// check collection returned
if (pgCollection === undefined) {
Copy link
Contributor

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?

Copy link
Member Author

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.

469cffe

collection_cumulus_id: pgCollection.cumulus_id,
});
query.select('granule_id');
query.limit(body.batchSize);
Copy link
Contributor

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 😄

Copy link
Member Author

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

@@ -1229,6 +1379,7 @@ router.delete('/:collectionId/:granuleId', del);

module.exports = {
bulkDelete,
bulkMoveCollection,
Copy link
Contributor

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.

Copy link
Member Author

@Jkovarik Jkovarik Feb 18, 2025

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/
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 || '');
Copy link
Contributor

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?

Copy link
Member Author

@Jkovarik Jkovarik Feb 21, 2025

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:

c5ac10b

}))
);
// index PG Granules into ES
await Promise.all(
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: prefer realistic values

Copy link
Member Author

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');
});
Copy link
Contributor

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?

Copy link
Member Author

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.

@Jkovarik Jkovarik changed the base branch from release-18.5.x to feature/CUMULUS-3751 February 19, 2025 20:20
},
});

input.cumulus_meta = { ...input?.template.cumulus_meta, ...input.cumulus_meta };
Copy link
Contributor

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

Copy link
Member Author

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.

bbbfd8c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants