Skip to content
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

Merged

Conversation

freeznet
Copy link
Contributor

@freeznet freeznet commented Jan 20, 2021

Fixes #8089

Motivation

#8089 addressed that making pulsar admin client api calls is conflict with Jersey library. This PR expose PulsarAdmin client through Function Context, so the function implementers can use PulsarAdmin to do whatever they want to do.

Modifications

  • 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

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • add unit tests to verify the args passing from process runtime / k8s runtime to JavaInstanceStarter
  • add unit tests to verify getPulsarAdmin
  • add integration tests to verify if pulsar admin works well [WIP]

Does this pull request potentially affect one of the following parts:

  • The admin cli options: (yes)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

PulsarAdmin getPulsarAdmin();

/**
* Get the pulsar admin client by cluster name.
Copy link
Contributor

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 ?

Copy link
Member

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.

Copy link
Contributor Author

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.

@sijie
Copy link
Member

sijie commented Jan 20, 2021

@nlu90 Can you review this since you add the multiple-cluster support there?

Copy link
Member

@sijie sijie left a 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/api-java/pom.xml 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) {
Copy link
Member

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:

  1. Update function worker with exposing pulsar admin disabled.
  2. Update all the functions to the new image that understand --web_serviceurl
  3. Update function worker to enable exposing pulsar admin.

Copy link
Contributor Author

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

@freeznet freeznet force-pushed the freeznet/add-admin-client-to-function-context branch 2 times, most recently from e7ea3af to 3912b3c Compare January 25, 2021 13:33
@freeznet
Copy link
Contributor Author

freeznet commented Jan 25, 2021

@eolivelli @sijie @nlu90 code changed according to your review, PTAL when you have time, thanks

@freeznet freeznet force-pushed the freeznet/add-admin-client-to-function-context branch 2 times, most recently from ad59e70 to 6b9e067 Compare January 27, 2021 06:07
Copy link
Member

@sijie sijie left a 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!

Copy link
Contributor

@eolivelli eolivelli left a 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

@freeznet
Copy link
Contributor Author

/pulsarbot run-failure-checks

@freeznet freeznet force-pushed the freeznet/add-admin-client-to-function-context branch 2 times, most recently from 1ee8f5e to 55a1dcc Compare January 30, 2021 14:49
@freeznet
Copy link
Contributor Author

/pulsarbot run-failure-checks

2 similar comments
@freeznet
Copy link
Contributor Author

/pulsarbot run-failure-checks

@freeznet
Copy link
Contributor Author

/pulsarbot run-failure-checks

@freeznet freeznet force-pushed the freeznet/add-admin-client-to-function-context branch from c1f9684 to 5116c0d Compare February 1, 2021 03:14
@freeznet
Copy link
Contributor Author

freeznet commented Feb 1, 2021

/pulsarbot run-failure-checks

1 similar comment
@freeznet
Copy link
Contributor Author

freeznet commented Feb 1, 2021

/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
@freeznet freeznet force-pushed the freeznet/add-admin-client-to-function-context branch from 5116c0d to 30d90e7 Compare February 1, 2021 14:49
@freeznet
Copy link
Contributor Author

freeznet commented Feb 1, 2021

/pulsarbot run-failure-checks

@sijie sijie merged commit 0469dfe into apache:master Feb 2, 2021
@freeznet
Copy link
Contributor Author

freeznet commented Feb 5, 2021

@codelipenghui will this pr in 2.7.1 release?

@Anonymitaet Anonymitaet added the doc-required Your PR changes impact docs and you will update later. label Feb 7, 2021
@nlu90
Copy link
Member

nlu90 commented Feb 8, 2021

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

Comment on lines +35 to +52
<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>
Copy link
Member

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

Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Anonymitaet Anonymitaet removed the doc-required Your PR changes impact docs and you will update later. label Mar 9, 2021
merlimat pushed a commit to merlimat/pulsar that referenced this pull request Apr 6, 2021
…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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jersey library conflict in Pulsar Functions
7 participants