Skip to content

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

Merged
tisonkun merged 45 commits intoapache:masterfrom
JooHyukKim:PIP280-CmdTopics
Oct 16, 2023
Merged

[refactor][cli][PIP-280] Refactor pulsar-client-tools module#20764
tisonkun merged 45 commits intoapache:masterfrom
JooHyukKim:PIP280-CmdTopics

Conversation

@JooHyukKim
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

if (backlogQuotaType == BacklogQuota.BacklogQuotaType.destination_storage) {
// set quota by storage size
if (limitStr == null) {
if (limit == null) {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@JooHyukKim JooHyukKim requested a review from tisonkun September 18, 2023 13:39
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

/pulsarbot rerun-failure-checks

@tisonkun
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

codecov-commenter commented Oct 11, 2023

Codecov Report

Attention: Patch coverage is 72.22222% with 15 lines in your changes missing coverage. Please review.

Project coverage is 73.27%. Comparing base (c35524d) to head (cf43812).
Report is 1566 commits behind head on master.

Files with missing lines Patch % Lines
...in/java/org/apache/pulsar/admin/cli/CmdTopics.java 61.11% 6 Missing and 1 partial ⚠️
...ava/org/apache/pulsar/admin/cli/CmdNamespaces.java 76.19% 2 Missing and 3 partials ⚠️
.../org/apache/pulsar/admin/cli/CmdTopicPolicies.java 85.71% 0 Missing and 2 partials ⚠️
...g/apache/pulsar/admin/cli/CmdPersistentTopics.java 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

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% <0.00%> (+0.06%) ⬆️
systests 24.71% <0.00%> (-0.03%) ⬇️
unittests 72.58% <72.22%> (+0.04%) ⬆️

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

Files with missing lines Coverage Δ
...n/java/org/apache/pulsar/admin/cli/CliCommand.java 59.15% <ø> (+1.20%) ⬆️
...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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tisonkun tisonkun merged commit a7acdf6 into apache:master Oct 16, 2023
@tisonkun
Copy link
Copy Markdown
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
Copy Markdown
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