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

[refactor][cli][PIP-280] Refactor pulsar-client-tools module #20764

Merged
merged 45 commits into from
Oct 16, 2023
Merged

[refactor][cli][PIP-280] Refactor pulsar-client-tools module #20764

merged 45 commits into from
Oct 16, 2023

Conversation

JooHyukKim
Copy link
Contributor

@JooHyukKim JooHyukKim commented Jul 9, 2023

PIP: #20691

Motivation

  • In the current Pulsar codebase, the logic to parse CLI arguments for measurement units like time and bytes is scattered across various CLI classes. Each value read has its distinct parsing implementation, leading to a lack of code reuse.

Modifications

  • Implement validators and converters to replace manual parsing logic in Cmd classes
  • Apply refactor to...
    • CmdNamespaces
    • CmdPersistetTopics
    • CmdTopicPolicies
    • CmdTopics
    • TimeUnitTo

Verifying this change

  • Make sure that the change passes the CI checks.

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

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: https://github.com/JooHyukKim/pulsar/pull/18

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jul 9, 2023
@JooHyukKim JooHyukKim marked this pull request as draft July 11, 2023 12:57
@JooHyukKim
Copy link
Contributor Author

@tisonkun May I ask for a review? 🙏🏼

@JooHyukKim JooHyukKim changed the title [refactor][cli][PIP-280] Refactor CLI parameters in pulsar-client-tools module [refactor][cli][PIP-280] Refactor pulsar-client-tools module Sep 4, 2023
@tisonkun
Copy link
Member

Thanks for your contribution! I'll give a review this weekend.

Copy link
Member

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution @JooHyukKim!

This patch is in a good direction. Comments inline. And please check the CI failure.

final int retentionTimeInMin = retentionTimeInSec != -1
? (int) TimeUnit.SECONDS.toMinutes(retentionTimeInSec)
: retentionTimeInSec.intValue();
final int retentionSizeInMB = sizeLimit != -1
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we can later move this size conversion to ByteUnitUtil also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True true 👍🏼, added to #21056

@@ -1311,23 +1297,16 @@ void run() throws PulsarAdminException {
BacklogQuota.Builder builder = BacklogQuota.builder().retentionPolicy(policy);
if (backlogQuotaType == BacklogQuota.BacklogQuotaType.destination_storage) {
// set quota by storage size
if (limitStr == null) {
if (limit == 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 may use a Nonnull ValueValidator here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, I did not touch limit and limitTimeInSec because they both have meaningful exception message such as...

    throw new ParameterException("Quota type of 'destination_storage' needs a size limit");

... this, so may not fit, and plus Validators and Converters are both passed static via annotation, so... kinda tricky.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for your explanation! Let's keep it AS IS then.

Copy link
Member

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

LGTM. We should try to fix the CI issue.

@JooHyukKim
Copy link
Contributor Author

Thanks for the review! @tisonkun

I suspect the OWASP dependency check workflow might not run for commits/PRs from maintainers. This might slow down fixes, but I haven't yet succeeded in verifying. 🧐

@JooHyukKim
Copy link
Contributor Author

/pulsarbot rerun-failure-checks

@tisonkun
Copy link
Member

tisonkun commented Sep 25, 2023

@JooHyukKim Please read the CI output before retry, it gives:

pulsar-cli-utils-3.2.0-SNAPSHOT.jar unaccounted for in LICENSE

So you may need to update some LICENSE file. Please check the CI output for details.

@JooHyukKim JooHyukKim marked this pull request as draft September 27, 2023 15:14
@JooHyukKim
Copy link
Contributor Author

Converted to draft PR as we have couple of failures to fix.
Anyone is welcome to pick up and go on.

@tisonkun
Copy link
Member

Rebase on #20663. Let's test once more.

@tisonkun tisonkun marked this pull request as ready for review October 10, 2023 15:34
Signed-off-by: tison <wander4096@gmail.com>
@codecov-commenter
Copy link

Codecov Report

Merging #20764 (cf43812) into master (c35524d) will increase coverage by 0.02%.
Report is 3 commits behind head on master.
The diff coverage is 75.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #20764      +/-   ##
============================================
+ Coverage     73.25%   73.27%   +0.02%     
+ Complexity    32517    32510       -7     
============================================
  Files          1888     1888              
  Lines        140246   140067     -179     
  Branches      15443    15408      -35     
============================================
- Hits         102736   102633     -103     
+ Misses        29419    29373      -46     
+ Partials       8091     8061      -30     
Flag Coverage Δ
inttests 24.30% <5.00%> (+0.06%) ⬆️
systests 24.71% <0.00%> (-0.03%) ⬇️
unittests 72.58% <75.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...n/java/org/apache/pulsar/admin/cli/CliCommand.java 59.15% <ø> (+1.20%) ⬆️
...org/apache/pulsar/client/cli/PulsarClientTool.java 68.45% <100.00%> (+1.09%) ⬆️
...g/apache/pulsar/admin/cli/CmdPersistentTopics.java 65.02% <0.00%> (+0.24%) ⬆️
.../org/apache/pulsar/admin/cli/CmdTopicPolicies.java 90.67% <85.71%> (+2.02%) ⬆️
...ava/org/apache/pulsar/admin/cli/CmdNamespaces.java 78.39% <76.19%> (+1.96%) ⬆️
...in/java/org/apache/pulsar/admin/cli/CmdTopics.java 81.17% <61.11%> (+2.22%) ⬆️

... and 62 files with indirect coverage changes

@tisonkun tisonkun merged commit a7acdf6 into apache:master Oct 16, 2023
43 of 45 checks passed
@tisonkun
Copy link
Member

Thanks for your contributon! The first migration step is merged now :D

vraulji567 pushed a commit to vraulji567/pulsar that referenced this pull request Oct 16, 2023
…e#20764)

Signed-off-by: tison <wander4096@gmail.com>
Co-authored-by: tison <wander4096@gmail.com>
@JooHyukKim
Copy link
Contributor Author

@tisonkun Thank you also for considerate time investment on this one! I will try to pick up where I left off 👍🏼.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs ready-to-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants