-
Notifications
You must be signed in to change notification settings - Fork 73
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
Wrap interactions with .opendistro-job-scheduler-lock in ThreadContext.stashContext to ensure JS can read and write to the index #347
Conversation
The failing check |
13a90dd
to
00c8fab
Compare
@cwperks how does this work if the index exists in the system in older version of the distribution and now moving to system index in version? How does security/OpenSearch handle it? |
7a806e9
to
3309468
Compare
@saratvemulapalli I will create the index as a normal index before installing JS and then install JS with this change and verify that it works as expected. I believe it can be converted without issue, but I'm not positive. Do you know where I can find information on how core treats system indices? I see logic that auto creates system indices if they do not exists, but is there anything else that is special about them in core? In the security plugin what is special about system indices is that no one can delete them unless you connect using admin cert and it matches the admin_dn. I have not been able to replicate the build issues on my dev machine. I wanted to go through the plugin developer experience of working with security so this looked like a good issue to try. |
Edit: The issue I was facing was due to watermark issues on my dev machine. |
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
@saratvemulapalli It's possible to give the index system index protection via the security plugin, and ensure that the plugin can write to it via a PR like this, but I can't currently find a way to make it a system index without steps to migrate like deleting the index and having it be recreated. Making it a formal system index involves extending I will close this PR if its not a change that's desired. I wanted to take an issue to get more familiar with JS without taking one of the issues allocated for CCI. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #347 +/- ##
============================================
- Coverage 37.37% 29.46% -7.92%
+ Complexity 133 99 -34
============================================
Files 22 23 +1
Lines 1188 1171 -17
Branches 109 109
============================================
- Hits 444 345 -99
- Misses 707 805 +98
+ Partials 37 21 -16 ☔ View full report in Codecov by Sentry. |
Re-opening and rebasing this PR. The lock index was marked as a system index using the extension point SystemIndexPlugin.getSystemIndexDescriptor in #474 and maintained backward compatibility. This PR surrounds calls to the lock index in a Resolves errors seen in #492 after the lock index was added in the security plugin's system index list. |
@prudhvigodithi Can you review this change? |
Hey @cwperks thanks for the contribution, Coming from this comment I understand its necessary to stash the thread context in JobScheduler for every CRUD operation on the lock index which is done part of this PR, after this PR I assume (please correct me if I'm wrong) the next step is also to update the the SYSTEM_INDICES list to add |
@prudhvigodithi That's correct. As part of opensearch-project/security#4439, I plan to make a change to feed the registry of system indices from core -> security plugin to avoid having to track them in a separate list in the security plugin. The job scheduler's lock index is one of the system indices that's already included in the registry and needs this change to ensure job-scheduler can interact with the index as desired. This is actually a bug in job-scheduler atm where it will either use the current authenticated user or the roles that were injected into the threadcontext when determining whether a write operation can happen to the lock index. This PR will ensure that job-scheduler will always be able to interact with the index. |
Thanks @cwperks LGTM, since you are working on adding some unit tests, you can either go in a new PR and add them here. |
Just curious are we referring to the |
The registry of system indices meaning that this plugin implements SystemIndexPlugin.getSystemIndexDescriptors(). I'm working on a change to provide protection by default to all plugins that implement SystemIndexPlugin.getSystemIndexDescriptors(), without having to submit a PR to the security repo to add it in the list tracked here: https://github.com/opensearch-project/security/blob/main/src/main/java/org/opensearch/security/tools/democonfig/SecuritySettingsConfigurer.java#L49-L80 |
…t.stashContext to ensure JS can read and write to the index (#347) * Make .opendistro-job-scheduler-lock a System Index Signed-off-by: Craig Perkins <[email protected]> * Switch back to private Signed-off-by: Craig Perkins <[email protected]> --------- Signed-off-by: Craig Perkins <[email protected]> (cherry picked from commit eb506e2) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…t.stashContext to ensure JS can read and write to the index (#347) (#647) * Make .opendistro-job-scheduler-lock a System Index * Switch back to private --------- (cherry picked from commit eb506e2) Signed-off-by: Craig Perkins <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Description
This PR wraps every instance of JS interacting with
.opendistro-job-scheduler-lock
inside ofstashContext
which allows the plugin to interact with system indices that have special protections. System indices cannot be inadvertently created, deleted or modified by even the admin user of the cluster which protects the cluster from getting into a corrupted state.This also makes JS extend SystemIndexPlugin which registers it with core a system index.Done separately in #474Issues Resolved
#305
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.