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][admin] Make failed bin/pulsar-admin source command exit with code 1 (failed) instead of 0 (success) #20503

Merged
merged 4 commits into from
Jun 7, 2023

Conversation

JooHyukKim
Copy link
Contributor

@JooHyukKim JooHyukKim commented Jun 6, 2023

Fixes #20485

Motivation

As title describes, to help users be informed about failed command immediately (presumably automatically, for instances where scripts are written and used).

Currently, when CmdSources commands fail, process returns exit code 0 even though the log shows it is apparently an error. For example, following command bin/pulsar-admin sources create --source-config-file NON-EXISTENT-FILE.yaml will log all error messages, but exit with code 0.

Such current behavior is rooted in CmdSources.BaseCommand.run() method, where Exception thrown by processArguments() is caught and "just" returns. This PR changes that.

Modifications

  • CmdSources : run() to throw exceptions instead of silent-catch and return.

Documentation

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

Matching PR in forked repository

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

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jun 6, 2023
@JooHyukKim JooHyukKim changed the title [fix][admin] Make failed CmdSources.run() throw exceptions instead of silently-fail and return [fix][admin] Make failed source command return exit code 1 insteand of 0 Jun 6, 2023
@JooHyukKim JooHyukKim changed the title [fix][admin] Make failed source command return exit code 1 insteand of 0 [fix][admin] Make failed CmdSources command return exit code 1 insteand of 0 Jun 6, 2023
@JooHyukKim JooHyukKim changed the title [fix][admin] Make failed CmdSources command return exit code 1 insteand of 0 [fix][admin] Make failed CmdSources command return exit code 1 instead of 0 Jun 6, 2023
@JooHyukKim JooHyukKim changed the title [fix][admin] Make failed CmdSources command return exit code 1 instead of 0 [fix][admin] Make failed bin/pulsar-admin source command exit with code 1(failed) instead of 0`(success) Jun 6, 2023
@JooHyukKim JooHyukKim changed the title [fix][admin] Make failed bin/pulsar-admin source command exit with code 1(failed) instead of 0`(success) [fix][admin] Make failed bin/pulsar-admin source command exit with code 1 (failed) instead of 0 (success) Jun 6, 2023
@JooHyukKim JooHyukKim requested a review from mattisonchao June 7, 2023 03:39
@codecov-commenter
Copy link

Codecov Report

Merging #20503 (08ea536) into master (43b3622) will increase coverage by 0.87%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #20503      +/-   ##
============================================
+ Coverage     72.05%   72.92%   +0.87%     
+ Complexity    31718     3697   -28021     
============================================
  Files          1855     1867      +12     
  Lines        138376   138544     +168     
  Branches      15198    15212      +14     
============================================
+ Hits          99703   101038    +1335     
+ Misses        30656    29483    -1173     
- Partials       8017     8023       +6     
Flag Coverage Δ
inttests 24.12% <0.00%> (+0.02%) ⬆️
systests 24.92% <0.00%> (?)
unittests 72.22% <100.00%> (+0.41%) ⬆️

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

Impacted Files Coverage Δ
...n/java/org/apache/pulsar/admin/cli/CmdSources.java 45.03% <100.00%> (+1.72%) ⬆️

... and 206 files with indirect coverage changes

@tisonkun
Copy link
Member

tisonkun commented Jun 7, 2023

Merging...

Thanks for your contribution @JooHyukKim!

@tisonkun tisonkun merged commit f53cdda into apache:master Jun 7, 2023
@tisonkun tisonkun added this to the 3.1.0 milestone Jun 7, 2023
@JooHyukKim JooHyukKim deleted the 20485 branch June 16, 2023 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli doc-not-needed Your PR changes do not impact docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return exit code 1 when pulsar-admin commands fail
4 participants