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][broker] Ignore the exception of creating namespace #18837

Merged
merged 3 commits into from
Dec 12, 2022

Conversation

nodece
Copy link
Member

@nodece nodece commented Dec 9, 2022

Motivation

In the standalone model, when the admin client hasn't permission to create the namespace, the Pulsar will exit.

We should keep the same logic with branch-2.10.

https://github.com/apache/pulsar/blob/branch-2.10/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandalone.java#L409-L414

Modifications

Add try...catch to pack.

Documentation

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

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Dec 9, 2022
@nodece nodece self-assigned this Dec 9, 2022
@nodece nodece added this to the 2.11.0 milestone Dec 9, 2022
try {
broker.getAdminClient().namespaces().createNamespace(ns.toString());
} catch (Exception e) {
log.warn(e.getMessage());
Copy link
Member

@tisonkun tisonkun Dec 9, 2022

Choose a reason for hiding this comment

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

Suggested change
log.warn(e.getMessage());
log.warn("...", e);

Besides, if the default manner to start a standalone cluster falls back to this branch, how can a standalone cluster successfully create the namespace (with what extra configs)?

Copy link
Member Author

@nodece nodece Dec 9, 2022

Choose a reason for hiding this comment

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

When the authentication/authorization is enabled, we should configure the brokerClientAuthenticationPlugin and brokerClientAuthenticationParameters.

To avoid breaking change, so I made this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

The namespace could be created via pulsar-admin with correct authentication info later. See how the C++ client's unit tests set up the test env. https://github.com/apache/pulsar-client-cpp/blob/2018a06e8afcde4de59971cfbc5f653a4f9d7897/build-support/start-test-service-inside-container.sh#L59-L63

@tisonkun
Copy link
Member

tisonkun commented Dec 9, 2022

Cross-reference to #18755.

Copy link
Contributor

@BewareMyPower BewareMyPower left a comment

Choose a reason for hiding this comment

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

Could you add an integration test to avoid the regression?

@nodece nodece force-pushed the ignore-ex-when-create-ns branch from 60b3f2c to 410ca5f Compare December 12, 2022 07:20
@Technoboy- Technoboy- changed the title [fix][broker] ignore the exception of creating namespace [fix][broker] Ignore the exception of creating namespace Dec 12, 2022
@Technoboy- Technoboy- closed this Dec 12, 2022
@Technoboy- Technoboy- reopened this Dec 12, 2022
@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2022

Codecov Report

Merging #18837 (e941351) into master (3180a4a) will decrease coverage by 8.79%.
The diff coverage is 63.63%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #18837      +/-   ##
============================================
- Coverage     46.17%   37.38%   -8.80%     
+ Complexity    10359     5076    -5283     
============================================
  Files           703      414     -289     
  Lines         68845    44670   -24175     
  Branches       7382     4573    -2809     
============================================
- Hits          31788    16699   -15089     
+ Misses        33448    25735    -7713     
+ Partials       3609     2236    -1373     
Flag Coverage Δ
unittests 37.38% <63.63%> (-8.80%) ⬇️

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

Impacted Files Coverage Δ
.../main/java/org/apache/pulsar/PulsarStandalone.java 0.00% <0.00%> (ø)
.../pulsar/broker/service/AbstractBaseDispatcher.java 56.00% <100.00%> (-1.48%) ⬇️
...sistent/PersistentDispatcherMultipleConsumers.java 55.38% <100.00%> (+3.65%) ⬆️
...ava/org/apache/pulsar/broker/admin/v1/Brokers.java 0.00% <0.00%> (-100.00%) ⬇️
...va/org/apache/pulsar/broker/admin/v1/Clusters.java 0.00% <0.00%> (-100.00%) ⬇️
.../org/apache/pulsar/broker/admin/v1/Properties.java 0.00% <0.00%> (-100.00%) ⬇️
...ar/common/naming/PartitionedManagedLedgerInfo.java 0.00% <0.00%> (-100.00%) ⬇️
...naming/RangeEquallyDivideBundleSplitAlgorithm.java 0.00% <0.00%> (-100.00%) ⬇️
...e/pulsar/broker/admin/impl/ResourceQuotasBase.java 0.00% <0.00%> (-96.43%) ⬇️
...he/pulsar/broker/service/AnalyzeBacklogResult.java 0.00% <0.00%> (-92.31%) ⬇️
... and 442 more

Signed-off-by: Zixuan Liu <[email protected]>
@Technoboy- Technoboy- merged commit bdbb118 into apache:master Dec 12, 2022
BewareMyPower added a commit to BewareMyPower/pulsar that referenced this pull request Dec 13, 2022
### Motivation

apache#17864 and
apache#18837 tried to fix the regression
of the namespace bundle policy in standalone by creating the namespace
via `PulsarAdmin`. It brings a problem that the namespace would not be
created successfully if the authentication of the built-in admin client
was not configured.

It brings the regression that makes the set up of the C++ client's unit
tests in branch-2.11 fail. Because the steps are:
- Start a standalone
- Update the policy of `public/default` via `pulsar-admin` without
  creating the namespace

### Modifications

Do not use `PulsarAdmin` to create the namespace when starting the
standalone. Instead, set the bundle policy according to the
`defaultNumberOfNamespaceBundles` config.

Add a `testStandaloneWithRocksDB` to test the namespace can still be
created even if no broker client authentication is configured. Then move
the bundle policy test from `SmokeTest` to this test.
BewareMyPower added a commit to BewareMyPower/pulsar that referenced this pull request Dec 13, 2022
### Motivation

apache#15186 changed the behavior of how
to create the default namespace. However, it brings a regression that
even if the built-in admin didn't have the authentication configured
while the standalone enabled the authentication, the namespace could
still be created successfully. This PR also changed the deploy script to
remove the creation of "public/default" namespace. Instead, it grants
the permission to this namespace directly.

After apache#17864 and
apache#18837, the namespace will be
created by the built-in admin again. But the deploy script would fail.

### Modifications

Create the default namespace via `pulsar-admin` in the deploy script.
Demogorgon314 pushed a commit to Demogorgon314/pulsar that referenced this pull request Dec 26, 2022
Demogorgon314 pushed a commit to Demogorgon314/pulsar that referenced this pull request Dec 29, 2022
lifepuzzlefun pushed a commit to lifepuzzlefun/pulsar that referenced this pull request Jan 10, 2023
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.

5 participants