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

MONGOCRYPT-749 Retry rewrapManyDataKey encrypt requests #922

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

adriandole
Copy link
Contributor

No description provided.

@adriandole adriandole marked this pull request as ready for review December 12, 2024 16:09
@kevinAlbs kevinAlbs self-requested a review December 30, 2024 17:32
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_NEED_KMS); // To encrypt.
ASSERT((kms = mongocrypt_ctx_next_kms_ctx(ctx)));
ASSERT(mongocrypt_kms_ctx_fail(kms)); // Simulate driver-side network failure for an encrypt request.
ASSERT((kms = mongocrypt_ctx_next_kms_ctx(ctx))); // Assert fails. Expected KMS request to retry but did not.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ASSERT((kms = mongocrypt_ctx_next_kms_ctx(ctx))); // Assert fails. Expected KMS request to retry but did not.
ASSERT((kms = mongocrypt_ctx_next_kms_ctx(ctx))); // Expect KMS request to retry.

_mongocrypt_ctx_rmd_datakey_t *it = rmdctx->datakeys;
while (it != NULL) {
_mongocrypt_ctx_datakey_t *dkctx = (_mongocrypt_ctx_datakey_t *)it->dkctx;
if (dkctx->kms.should_retry) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (dkctx->kms.should_retry) {
if (dkctx->kms.should_retry) {
dkctx->kms.should_retry = false; // Reset retry state.

Similar to other contexts (example), reset should_retry before returning.

ASSERT((kms = mongocrypt_ctx_next_kms_ctx(ctx)));
ASSERT(mongocrypt_kms_ctx_fail(kms)); // Simulate driver-side network failure for an encrypt request.
ASSERT((kms = mongocrypt_ctx_next_kms_ctx(ctx))); // Assert fails. Expected KMS request to retry but did not.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ASSERT_OK(mongocrypt_kms_ctx_feed(kms, TEST_FILE("./test/data/rmd/kms-encrypt-reply-a.txt")), kms);
ASSERT(mongocrypt_kms_ctx_bytes_needed(kms) == 0);
ASSERT_OK(!mongocrypt_ctx_next_kms_ctx(ctx), ctx);
ASSERT_OK(mongocrypt_ctx_kms_done(ctx), ctx);
ASSERT_STATE_EQUAL(mongocrypt_ctx_state(ctx), MONGOCRYPT_CTX_READY);

Suggest testing feeding the retried KMS context. This catches the missing should_retry = false.

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.

2 participants