-
Notifications
You must be signed in to change notification settings - Fork 129
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
[Feature/multi_tenancy] Delay context restoring for initializing master key and deleting agent #2866
[Feature/multi_tenancy] Delay context restoring for initializing master key and deleting agent #2866
Conversation
Windows failing on
Linux failing on
Neither is associated with this PR and pass on the alternate OS |
fe781fb
to
a23a437
Compare
@@ -124,6 +124,7 @@ protected void doExecute(Task task, ActionRequest request, ActionListener<Delete | |||
if (TenantAwareHelper | |||
.validateTenantResource(mlFeatureEnabledSetting, tenantId, mlAgent.getTenantId(), actionListener)) { | |||
if (mlAgent.getIsHidden() && !isSuperAdmin) { | |||
context.restore(); |
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.
Or should we stash the context again before the deletion?
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 particular branch doesn't do the deletion, it's returning the 403 message because you are not superadmin and the model is hidden. The else branch keeps the context stashed and does the deletion.
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, I know but I wasn't able to comment there as that wasn't a modified code section. In summary, I was just wondering if we should add context restore in multiple places? Or should we just stash again before performing any DB call. That will keep the stash context scope smaller and more secured IMO.
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.
The previous code used runBefore()
on the action listener which basically just delayed restoring it until the action lister was completed (with success or failure). I was somewhat trying to restore earlier with the initial code but it was too early. This delays it for when it's needed.
I can probably put it back closer to the runBefore()
implementation which is the opposite direction of your wondering... or since it's used in try-with-resources, it actually will be automatically restored as part of that auto-closure, so manually doing anything to it isn't actually required here.
I'm happy to go either way, which do you prefer?
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 agree with you. Let's put it back closer to the runBefore()
and then we can make the changes in main to keep the context scope smaller.
Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
a23a437
to
8351004
Compare
8d9786b
into
opensearch-project:feature/multi_tenancy
Description
Fixes too-eager restoring of context in cases where it needed to still be stashed
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.