-
Notifications
You must be signed in to change notification settings - Fork 146
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
applying sdkclient changes to config index #3521
applying sdkclient changes to config index #3521
Conversation
Signed-off-by: Dhrubo Saha <[email protected]>
0452cb5
to
f2e29c1
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3521 +/- ##
============================================
+ Coverage 80.25% 80.27% +0.02%
- Complexity 6906 6921 +15
============================================
Files 610 610
Lines 30077 30143 +66
Branches 3368 3374 +6
============================================
+ Hits 24137 24196 +59
- Misses 4487 4495 +8
+ Partials 1453 1452 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
private PutDataObjectRequest createPutDataObjectRequest(String tenantId, String masterKeyId, String generatedMasterKey) { | ||
return PutDataObjectRequest | ||
.builder() | ||
.tenantId(tenantId) |
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 see the below map stores DEFAULT_TENANT_ID
, but here we are using tenantId
, not sure why we don't keep it consistent.
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.
so DEFAULT_TENANT_ID
is required for tenantMasterKeys
as we can't have any null key in the dictionary. But for single tenancy we can have null tenant id
. Here the logic is for single tenancy (when tenantId is null), we add master key in the DEFAULT_TENANT_ID
key to overcome the null key issue in the hashmap.
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.
For reference, I answered a similar review question on Flow Framework. TLDR:
- old system had a single string variable for non-multitenancy
- new system has a key value map for multitenancy with tenantID as the key
- options to support both in same codebase are to keep a separate String (outside the map) and map (with tenantId keys).
- for simplicity, putting everything in the map avoids lots of conditionals everywhere
- but the map can't have a null key. We ended up using the empty string as our "default" key. It doesn't really matter what string it is
sdkClient | ||
.putDataObjectAsync(createPutDataObjectRequest(tenantId, masterKeyId, generatedMasterKey)) | ||
.whenComplete( | ||
(putDataObjectResponse, throwable1) -> handlePutDataObjectResponse( |
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 like we don't check the response putDataObjectResponse
in the function handlePutDataObjectResponse
, is it what we expect?
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.
addressed.
exceptionRef.set(new ResourceNotFoundException(MASTER_KEY_NOT_READY_ERROR)); | ||
latch.countDown(); | ||
} else { | ||
handleGetDataObjectSuccess(response1, tenantId, masterKeyId, exceptionRef, latch, context); |
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 think there is potential dead loop here. In the function handleGetDataObjectSuccess
, if still getting empty response, the function initializeNewMasterKey
will be executed again, then handleVersionConflictResponse
-> handleGetDataObjectSuccess
-> initializeNewMasterKey
.
Actually in 2.18, the logic is that if getting VersionConflictEngineException
, only re-get index once, won't retry creating index.
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.
addressed.
9f011fa
to
61671ab
Compare
Signed-off-by: Dhrubo Saha <[email protected]>
61671ab
to
c218da4
Compare
) | ||
.whenComplete((response, throwable) -> { | ||
try { | ||
handleVersionConflictResponse(tenantId, masterKeyId, context, response, throwable, exceptionRef, latch); |
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.
one question when handling version conflict. We call getDataObjectAsync(getDataObjectRequest)
-> and if empty -> initializeNewMasterKey
-> putDataObjectAsync
-> find VersionConflictEngineException
-> handleVersionConflict
-> getDataObjectAsync
-> handleVersionConflictResponse
, does the two getDataObjectAsync
totally same? Looks like they send same request. If so, we will also get empty and looks we cannot handle version conflict. Do I miss something?
* applying sdkclient changes to config index Signed-off-by: Dhrubo Saha <[email protected]> * addressed comments Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]> (cherry picked from commit eccfd44)
* applying sdkclient changes to config index Signed-off-by: Dhrubo Saha <[email protected]> * addressed comments Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]> (cherry picked from commit eccfd44)
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.19 2.19
# Navigate to the new working tree
cd .worktrees/backport-2.19
# Create a new branch
git switch --create backport/backport-3521-to-2.19
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 eccfd4484c79555868022c761091ce649e999ab9
# Push it to GitHub
git push --set-upstream origin backport/backport-3521-to-2.19
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.19 Then, create a pull request where the |
* applying sdkclient changes to config index Signed-off-by: Dhrubo Saha <[email protected]> * addressed comments Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]> (cherry picked from commit eccfd44)
* applying sdkclient changes to config index Signed-off-by: Dhrubo Saha <[email protected]> * addressed comments Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]> (cherry picked from commit eccfd44)
* applying sdkclient changes to config index Signed-off-by: Dhrubo Saha <[email protected]> * addressed comments Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]> (cherry picked from commit eccfd44) Co-authored-by: Dhrubo Saha <[email protected]>
Description
applying sdkclient (wrapper of client) to config index during index related operations
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
--signoff
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.