-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[fix #8089] expose PulsarAdmin client through Function Context #9246
[fix #8089] expose PulsarAdmin client through Function Context #9246
Conversation
PulsarAdmin getPulsarAdmin(); | ||
|
||
/** | ||
* Get the pulsar admin client by cluster name. |
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 we explain here when it is better to use this method instead of the other ?
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.
Pulsar recently adds support for multiple clusters, i.e. input topics from cluster A and output topics from cluster B. This method just provides the same support for admin calls.
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, just as sijie said, getPulsarAdmin()
will just get the default
pulsar admin client, the other one will let user get pulsar admin client if externalPulsarClusters
is set.
pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/ContextImpl.java
Outdated
Show resolved
Hide resolved
@nlu90 Can you review this since you add the multiple-cluster support there? |
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.
@freeznet the overall change looks really strong! I left a couple of comments regarding backward compatibility. Please take a look.
pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/InstanceUtils.java
Outdated
Show resolved
Hide resolved
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java
Outdated
Show resolved
Hide resolved
pulsar-functions/localrun/src/main/java/org/apache/pulsar/functions/LocalRunner.java
Outdated
Show resolved
Hide resolved
...functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/JavaInstanceStarter.java
Outdated
Show resolved
Hide resolved
if (instanceConfig.getFunctionDetails().getRuntime() == Function.FunctionDetails.Runtime.JAVA) { | ||
// TODO: for now only Java function context exposed pulsar admin, so python/go no need to pass this argument | ||
// until pulsar admin client enabled in python/go function context. | ||
if (pulsarWebServiceUrl != null) { |
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.
we need to add a flag in the function worker config to control whether to expose PulsarAdmin through context. Because the new function worker will add this --web_serviceurl
to the command line that is not able to recognize by the function instance. So we need to have a flag to allow people to do the following update sequence:
- Update function worker with exposing pulsar admin disabled.
- Update all the functions to the new image that understand
--web_serviceurl
- Update function worker to enable exposing pulsar admin.
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, flag added, also add some tests when exposePulsarAdminClientEnabled=false
e7ea3af
to
3912b3c
Compare
@eolivelli @sijie @nlu90 code changed according to your review, PTAL when you have time, thanks |
ad59e70
to
6b9e067
Compare
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.
@freeznet The change looks really great! Thank you for your contribution!
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
Thanks for this feature.
It will ease developing functions and especially connectors
/pulsarbot run-failure-checks |
1ee8f5e
to
55a1dcc
Compare
/pulsarbot run-failure-checks |
2 similar comments
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
c1f9684
to
5116c0d
Compare
/pulsarbot run-failure-checks |
1 similar comment
/pulsarbot run-failure-checks |
throw exception & fix dependency throw exceptions add example function add ExposeAdminClientEnabled in functions_worker.yml move module with right path style revert changes
5116c0d
to
30d90e7
Compare
/pulsarbot run-failure-checks |
@codelipenghui will this pr in 2.7.1 release? |
sorry for the late reply. @sijie I just notice this change and am wondering the necessity of exposing the whole admin client from functions to users. Maybe we can have some discussion when you are available |
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>pulsar-common</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>pulsar-client-original</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>pulsar-package-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> |
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.
Is it intentional that these dependencies are included? This change seems to be causing a major regression to Pulsar IO connectors. Please see #9572 . /cc @sijie @eolivelli
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 size of Pulsar IO connectors files get back to normal after changing the scope of pulsar-client-admin-api
in pulsar-functions/api-java/pom.xml
from <scope>compile</scope>
to <scope>provided</scope>
.
However I'm a bit concerned about the usefulness of the new pulsar-client-admin-api library since it's not really a standalone api dependency. It pulls in all dependencies. WDYT?
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.
Size of https://hub.docker.com/layers/streamnative/pulsar-all/2.8.0-rc-202102022225/images/sha256-50d6a03312262d5b60efbb29e8c4a3f2245d1317ee25164e18bbd43a0d86113c?context=exploreis 2.91GB ,
on the previous day, it was 2.25GB:
https://hub.docker.com/layers/streamnative/pulsar-all/2.8.0-rc-202102012227/images/sha256-04d33735218a612dd53c7963a35bbe9d8c9a0db1625555aa501cfa95821e029f?context=explore
The ≈700MB increase most likely happened after this PR was merged.
…pache#9246) Fixes apache#8089 - add `getPulsarAdmin()` and `getPulsarAdmin(String clusterName)` in function `Context` - add implementation of above interface in `ContextImpl` - add passing `pulsarWebServiceUrl` to function runtimes - add passing `pulsarWebServiceUrl` to `LocalRunner` / `JavaInstanceStarter` - add `"--web-service-url"` parameter to `LocalRunner` admin command - add unit tests - add example function - add `exposeAdminClientEnabled` in `functions_worker.yml`
Fixes #8089
Motivation
#8089 addressed that making pulsar admin client api calls is conflict with Jersey library. This PR expose
PulsarAdmin
client throughFunction Context
, so the function implementers can use PulsarAdmin to do whatever they want to do.Modifications
getPulsarAdmin()
andgetPulsarAdmin(String clusterName)
in functionContext
ContextImpl
pulsarWebServiceUrl
to function runtimespulsarWebServiceUrl
toLocalRunner
/JavaInstanceStarter
"--web-service-url"
parameter toLocalRunner
admin commandexposeAdminClientEnabled
infunctions_worker.yml
Verifying this change
This change added tests and can be verified as follows:
JavaInstanceStarter
getPulsarAdmin
Does this pull request potentially affect one of the following parts:
Documentation