5990: Fix security plugin issue - #20822
Conversation
Signed-off-by: Deepti24 <chauhan.deepti24@gmail.com>
PR Reviewer Guide 🔍(Review updated until commit b06469a)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to b06469a
Previous suggestionsSuggestions up to commit 25fdcdc
|
|
❌ Gradle check result for 25fdcdc: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Deepti24 <chauhan.deepti24@gmail.com>
|
Persistent review updated to latest commit b06469a |
|
❌ Gradle check result for b06469a: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
/check |
|
@Deepti24 I think we can simplify the changes. I believe cwperks#345 would solve the issue. If I understand correctly, the issue is specifically on transient headers that have registered propagators. The code correctly handles the case where these headers are propagated from parent context -> stashed context but there is an issue on the restore workflow. In the PR I linked to above it modifies the restore logic to check for the transients with propagators from within the stashed context and ensures they are propagated back to the parent context. I think that would be all the needed changes too because CURRENT_SPAN already had a thread context propagator defined in ThreadContextBasedTracerContextStorage |
|
@cwperks Yes this should work but just curious we could have done same for rest headers as well ? Just trying to understand why did we go with headersToCopy approach there ? |
There's a few different types of ThreadContext headers:
Its since moved on to allowing more headers and actually allows plugins to also define headers (1) to copy when stashing the context. btw stashing the context is done in cases where the system needs to change from user-context -> system context for performing system operations like reading/writing to a system index. I definitely think there could be cleanup in this area and would even start to think about removal of |
|
Thanks for the detailed response @cwperks
|
| UnaryOperator<RestHandler> restWrapper = null; | ||
| for (ActionPlugin plugin : actionPlugins) { | ||
| UnaryOperator<RestHandler> newRestWrapper = plugin.getRestHandlerWrapper(threadPool.getThreadContext(), headers); | ||
| UnaryOperator<RestHandler> newRestWrapper = plugin.getRestHandlerWrapper(threadPool.getThreadContext(), headers, transients); |
There was a problem hiding this comment.
@Deepti24 this change is unclear to me: the span, if propagated, should be set in thread context (transient headers), there should be no custom logic involved (ideally) to carry it forward
There was a problem hiding this comment.
Hey @reta , @cwperks has opened a separate PR to fix this issue in thread propagation itself : https://github.com/cwperks/OpenSearch/pull/345/changes
I think that would be smaller fix for this
But to explain the issue, there is a bug in security plugin (due to how restore and stash Context work).
So I tried to follow the pattern of how headersToCopy are used, tried doing same for transientsToCopy. Then would use that in security plugin as mentioned below:
https://github.com/opensearch-project/security/pull/6000/changes
But yes, ideally we should follow the pattern you mentioned.
There was a problem hiding this comment.
@reta there's a bug on the restore path described here: #20822 (comment)
The transient headers are correctly propagating from parent tc -> stashed tc, but not from stashed tc -> restored parent tc.
|
This PR is stalled because it has been open for 30 days with no activity. |

Description
We are trying to fix: opensearch-project/security#5990
We need to pass transients that should be copied. This change addresses that
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
opensearch-project/security#5990
Testing was done as follows:
A couple of points in PR:
Check List
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.