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

aggregator API: idempotent task creation #1549

Merged
merged 1 commit into from
Aug 2, 2023

Conversation

tgeoghegan
Copy link
Contributor

@tgeoghegan tgeoghegan commented Jun 30, 2023

Makes the task creation endpoint in the aggregator API idempotent, by checking whether a task corresponding to the incoming PostTaskReq already exists. If it does, and all the other task's parameters match the PostTaskReq, then we return 201 Created. If the task exists but some other parameter (e.g., min batch size) differs, we return 409 Conflict.

Deletion was already correctly handled so no new changes or test were needed.

Resolves #1507

@tgeoghegan tgeoghegan requested a review from a team as a code owner June 30, 2023 00:15
"task with same VDAF verify key and task ID already exists with different parameters".to_string(),
Status::Conflict,
);
return Err(datastore::Error::User(err.into()));
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to match on the error received by map_err below for datastore::Error::User, try downcasting to this module's error type, and return that unwrapped error instead if it succeeds. Otherwise, duplicate tasks would just get the "Error storing task" message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I forgot to write a test for the task mutation case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed: I did this to avoid writing identical match arms for the _ case and the case where datastore::Error:User wraps something besides aggregator_api::Error. Too clever?

Copy link
Contributor

@inahga inahga left a comment

Choose a reason for hiding this comment

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

👍

@tgeoghegan tgeoghegan force-pushed the timg/aggregator-api-bearer-token-default branch from 5422828 to 8b4e9ea Compare July 26, 2023 23:52
@tgeoghegan tgeoghegan force-pushed the timg/agg-api-task-idempotence branch from 8a53c17 to a97613f Compare July 27, 2023 23:59
@tgeoghegan tgeoghegan force-pushed the timg/aggregator-api-bearer-token-default branch 3 times, most recently from 69a9546 to c85a508 Compare August 1, 2023 20:19
@tgeoghegan tgeoghegan force-pushed the timg/agg-api-task-idempotence branch from a97613f to 31f73dd Compare August 1, 2023 20:21
Base automatically changed from timg/aggregator-api-bearer-token-default to main August 1, 2023 23:00
Makes the task creation endpoint in the aggregator API idempotent, by
checking whether a task corresponding to the incoming `PostTaskReq`
already exists. If it does, and all the other task's parameters match
the `PostTaskReq`, then we return 201 Created. If the task exists but
some other parameter (e.g., min batch size) differs, we return 409
Conflict.

Deletion was already correctly handled so no new changes or test were
needed.

Resolves #1507
@tgeoghegan tgeoghegan force-pushed the timg/agg-api-task-idempotence branch from 31f73dd to 4a5a9d5 Compare August 1, 2023 23:05
@tgeoghegan tgeoghegan merged commit d4dde00 into main Aug 2, 2023
7 checks passed
@tgeoghegan tgeoghegan deleted the timg/agg-api-task-idempotence branch August 2, 2023 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Aggregator API idempotence
4 participants