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

[api][pulsar-client]Add get version command for pulsar rest api, pulsar-admin, pulsar-client #9975

Conversation

tuteng
Copy link
Member

@tuteng tuteng commented Mar 19, 2021

(If this PR fixes a github issue, please add Fixes #<xyz>.)

Fixes #9969

Motivation

Add the version command:
Get broker version by rest API:

curl http://localhost:8080/admin/v2/brokers/version

Get broker version by pulsar-admin:

./bin/pulsar-admin brokers version

Get broker version by the command pulsar:

./bin/pulsar version

Get version of pulsar admin client:

./bin/pulsar-admin -v
./bin/pulsra-admin --version

Get version of pulsar client:

./bin/pulsar-client -v
./bin/pulsra-client --version

Modifications

  • Add rest API for get version of broker
  • Add getVersion for the command pulsar
  • Add getVersion for the command pulsar-admin
  • Add getVersion for the command pulsar-client

Verifying this change

  • Add unit test
  • Add integration test

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

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API: (yes / no)
  • The schema: (yes / no / don't know)
  • The default values of configurations: (yes / no)
  • The wire protocol: (yes / no)
  • The rest endpoints: (yes / no)
  • The admin cli options: (yes / no)
  • Anything that affects deployment: (yes / no / don't know)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
  • If a feature is not applicable for documentation, explain why?
  • If a feature is not documented yet in this PR, please create a followup issue for adding the documentation

@tuteng tuteng changed the title Add get version command for pulsar rest api, pulsar-admin, pulsar-client [api][pulsar-client]Add get version command for pulsar rest api, pulsar-admin, pulsar-client Mar 19, 2021
@tuteng tuteng self-assigned this Mar 19, 2021
@tuteng tuteng added area/admin area/broker area/client component/rest doc-required Your PR changes impact docs and you will update later. labels Mar 19, 2021
@tuteng tuteng added this to the 2.8.0 milestone Mar 19, 2021
/**
* Pulsar version entry point.
*/
public class PulsarVersionStarter {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this change?

Copy link
Member Author

@tuteng tuteng Mar 22, 2021

Choose a reason for hiding this comment

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

Yes, I found that other commands such as pulsar broker, pulsar proxy are a public class with a main function, pulsar version as a separate command, also needs to be a class with a main function, otherwise, it needs to be a subcommand of other commands

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.

+1
Overall looks good.

I left a proposal, probably for a future enhancement


@Override
void run() throws Exception {
System.out.println( getAdmin().brokers().getVersion());
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that we have a little usability problem here.

The user does not know which broker reported the version.

Proposals:

  • return the address of the broker that reported the version (a BrokerInfo structure ?)
  • add a (optional) parameter to specify the id of the broker that we want to query

In a Pulsar cluster usually you have the same version of the software, but this may not be the case during upgrades or in case you have special versions of Pulsar on some nodes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I agree with you, but I think the current version of the broker can be queried explicitly using the pulsar-admin brokers version command, for example, the pulsar-admin brokers version command will use the webServiceUrl configuration in the client.conf configuration file, and of course, the webServiceUrl parameter can be used to specify the address of the broker to be queried by the command pulsar-admin --admin-url, In a pulsar cluster upgrade, multiple versions of the broker will exist at the same time, and with the --admin-url parameter, we can explicitly get the version of the specified broker

@Anonymitaet
Copy link
Member

Anonymitaet commented Mar 23, 2021

@tuteng thanks for your contribution.

For docs side:

  • REST API & pulsar-admin
    You've added descriptions, they will be shown on websites.

  • pulsar-client
    Think descriptions should be added to the pulsar-client page.
    Our community has submitted a request that it is better to generate the pulsar-client page (https://pulsar.apache.org/docs/en/next/pulsar-admin/) from code automatically for a long time. In this case, we do not need to add descriptions manually, which eats up much time. May I know the process of the automatic work? Many thanks

@tuteng
Copy link
Member Author

tuteng commented Mar 23, 2021

@codelipenghui PTAL

@codelipenghui codelipenghui merged commit 5d85a2f into apache:master Mar 23, 2021
@Anonymitaet
Copy link
Member

Add docs w/ other changes here.

@Anonymitaet Anonymitaet removed the doc-required Your PR changes impact docs and you will update later. label Mar 26, 2021
codelipenghui pushed a commit that referenced this pull request Mar 30, 2021
…ar-admin, pulsar-client (#9975)

Add the version command:
Get broker version by rest API:

```
curl http://localhost:8080/admin/v2/brokers/version
```
Get broker version by `pulsar-admin`:
```
./bin/pulsar-admin brokers version
```
Get broker version by the command `pulsar`:
```
./bin/pulsar version
```

Get version of pulsar admin client:
```
./bin/pulsar-admin -v
./bin/pulsra-admin --version
```

Get version of pulsar client:
```
./bin/pulsar-client -v
./bin/pulsra-client --version

(cherry picked from commit 5d85a2f)
@codelipenghui codelipenghui added the cherry-picked/branch-2.7 Archived: 2.7 is end of life label Mar 30, 2021
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.

Add the version command for the command pulsar, pulsar-admin, pulsar-client etc
6 participants