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
Make RestController pluggable #98187
Make RestController pluggable #98187
Conversation
This commit changes the ActionModules to allow the RestController to be provided by an internal plugin. It rename `RestInterceptorActionPlugin` to `RestServerActionPlugin` and adds a new `getRestController` method to it. There may be multiple RestServerActionPlugins installed on a node, but only 1 may provide a Rest Wrapper (getRestHandlerInterceptor) and only 1 may provide a RestController (getRestController).
Pinging @elastic/es-core-infra (Team:Core/Infra) |
Hi @tvernum, I've created a changelog YAML for you. |
@elasticmachine update branch |
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 it looks great, I left few comments to help me understand the direction taken
@@ -40,7 +40,15 @@ public void testQualifiedExports() { | |||
|
|||
// The package containing the RestInterceptor type, org.elasticsearch.plugins.interceptor, | |||
// should only be exported to security. |
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.
perhaps a comment needs to be updated too?
} | ||
} | ||
|
||
public void test3rdPartyRestControllerIsNotInstalled() { |
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.
can this really happen? we only export the org.elasticsearch.plugins.interceptor
to serverless and security.
Someone would have to run ES server without java9 modules? (tests don't have them enabled)
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.
Yes, it's possible to have a plugin that is not a module, in which case qualified exports are not respected.
Perhaps we need to get to a place where we require that plugins are modularized, but we don't today.
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 that if a plugin is not a module it would compile, but it would fail at runtime
I would expect that we would get a runtime exception along the lines
Exception in thread "main" java.lang.IllegalAccessError: superinterface check failed: class wrong.plugin.XYZ (in unnamed module @0x19469ea2) cannot access class org.elasticsearch.plugins.interceptor.RestServerActionPlugin (in module org.elasticserach.server) because module org.elasticsearch.server does not export org.elasticsearch.plugins.interceptor to unnamed module @0x19469ea2
(note the above message I 'hand crafted' basing on a simple reproduction project structure with 4 classes)
at the same time I don't mind this test, I just thought we don't need to wory about this (I don't test for other internal plugins)
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.
TIL.
I thought I had tested with a non-modularized plugin, but I suspect it might have worked because I temporarily had an open export.
); | ||
headersToCopy = headers; | ||
|
||
var customController = getRestServerComponent( |
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 plan is to support multiple API Versions on the same cluster, right?
isn't the limit of one plugin implementing RestServerActionPlugin prevent us to do this?
When reading the doc I was imagining we would like to provide multiple RestControllers - one per one Version supported.
how will customController support multiple API versions?
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.
Right now we're only supporting 1 API version, so that's a future problem.
However, I'd expect it to be a single rest controller in that case with some additional logic for dispatch - similar to how the existing controller handles V7 endpoints.
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.
LGTM
This commit changes the ActionModules to allow the RestController to be provided by an internal plugin.
It renames
RestInterceptorActionPlugin
toRestServerActionPlugin
and adds a newgetRestController
method to it.There may be multiple RestServerActionPlugins installed on a node, but only 1 may provide a Rest Wrapper (getRestHandlerInterceptor) and only 1 may provide a RestController (getRestController).