Skip to content

[fix][broker] Fix create ns - #17864

Merged
nodece merged 1 commit into
apache:masterfrom
nodece:fix-create-ns
Oct 8, 2022
Merged

[fix][broker] Fix create ns#17864
nodece merged 1 commit into
apache:masterfrom
nodece:fix-create-ns

Conversation

@nodece

@nodece nodece commented Sep 28, 2022

Copy link
Copy Markdown
Member

Motivation

The bundles policy of the namespace is ignored if the namespace is created directly by the NamespaceResources, see the logic of admin service:

private Policies getDefaultPolicesIfNull(Policies policies) {
if (policies == null) {
policies = new Policies();
}
int defaultNumberOfBundles = config().getDefaultNumberOfNamespaceBundles();
if (policies.bundles == null) {
policies.bundles = getBundles(defaultNumberOfBundles);
}
return policies;
}

Modifications

  • Use admin to create a namespace instead of the NamespaceResources

Documentation

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    (Please explain why)

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

Matching PR in forked repository

nodece#4

@nodece nodece added release/2.11.1 area/broker release/blocker Indicate the PR or issue that should block the release until it gets resolved labels Sep 28, 2022
@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Sep 28, 2022
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
@nodece
nodece force-pushed the fix-create-ns branch 2 times, most recently from 4981f0d to a1835b0 Compare September 30, 2022 04:06
Policies nsp = new Policies();
nsp.replication_clusters = Collections.singleton(config.getClusterName());
nsr.createPolicies(ns, nsp);
broker.getAdminClient().namespaces().createNamespace(ns.toString());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, I don't get it, why nsr.createPolicies(ns, nsp); is ignored?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Some policy is ignored because the conf file effects this policy.

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lgtm

What about adding a test case?

@nodece

nodece commented Sep 30, 2022

Copy link
Copy Markdown
Member Author

Lgtm

What about adding a test case?

I think we should add an integration test, what do you think about that?

@nodece
nodece merged commit e1b537f into apache:master Oct 8, 2022
@BewareMyPower

Copy link
Copy Markdown
Contributor

Could you clarify which policies are affected?

@nodece

nodece commented Dec 9, 2022

Copy link
Copy Markdown
Member Author

Could you clarify which policies are affected?

See the PR description.

@BewareMyPower BewareMyPower removed release/blocker Indicate the PR or issue that should block the release until it gets resolved release/2.11.1 labels Dec 9, 2022
@BewareMyPower

Copy link
Copy Markdown
Contributor

If only the number of bundles were affected, could you use another solution? This PR brings a breaking change to the standalone. We need to add an integration test to protect it.

@nodece

nodece commented Dec 9, 2022

Copy link
Copy Markdown
Member Author

If only the number of bundles were affected, could you use another solution?

No.

This PR brings a breaking change to the standalone. We need to add an integration test to protect it.

Good catch. Let me add an integration test for this.

@BewareMyPower

Copy link
Copy Markdown
Contributor

For how to reproduce it, you can reference the pulsar-test-service-start.sh, which uses standalone-ssl.conf as the config file. In additional, even if Pulsar service is ready was printed, the standalone actually didn't start successfully. You can log in the docker container and run bin/pulsar standalone -nss -nfw directly, you should see the following logs:

2022-12-09T07:45:12,311+0000 [main] INFO  org.apache.pulsar.broker.PulsarService - created admin with url http://localhost:8080
2022-12-09T07:45:12,664+0000 [pulsar-web-46-15] ERROR org.apache.pulsar.broker.admin.v2.Namespaces - [anonymous] Failed to create namespace public/default
java.util.concurrent.CompletionException: org.apache.pulsar.broker.web.RestException: Unauthorized to validateTenantOperation for originalPrincipal [null] and clientAppId [anonymous] about operation [CREATE_NAMESPACE] on tenant [public]
        at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315) ~[?:?]
        at java.util.concurrent.CompletableFuture.uniAcceptNow(CompletableFuture.java:761) ~[?:?]
        at java.util.concurrent.CompletableFuture.uniAcceptStage(CompletableFuture.java:735) ~[?:?]
        at java.util.concurrent.CompletableFuture.thenAccept(CompletableFuture.java:2182) ~[?:?]
        at org.apache.pulsar.broker.web.PulsarWebResource.validateTenantOperationAsync(PulsarWebResource.java:995) ~[org.apache.pulsar-pulsar-broker-2.11.0.jar:2.11.0]
        at org.apache.pulsar.broker.admin.impl.NamespacesBase.internalCreateNamespace(NamespacesBase.java:138) ~[org.apache.pulsar-pulsar-broker-2.11.0.jar:2.11.0]
        at org.apache.pulsar.broker.admin.v2.Namespaces.createNamespace(Namespaces.java:166) ~[org.apache.pulsar-pulsar-broker-2.11.0.jar:2.11.0]

@nodece

nodece commented Dec 9, 2022

Copy link
Copy Markdown
Member Author

Because you didn't set up the brokerClientAuthenticationPlugin and brokerClientAuthenticationParameters in the standalone-ssl.conf.

Comment on lines -397 to -399
Policies nsp = new Policies();
nsp.replication_clusters = Collections.singleton(config.getClusterName());
nsr.createPolicies(ns, nsp);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not fix it by something like:

nsp.bundles = /* ... */;

It would be more clear for what's the default bundle policy of the standalone and not affected by the PulsarAdmin implementations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So far, I've only found the bundle issue, I'm not sure about the other factors, so using the admin.

@BewareMyPower

Copy link
Copy Markdown
Contributor

Because you didn't set up the brokerClientAuthenticationPlugin and brokerClientAuthenticationParameters in the standalone-ssl.conf.

The previous deployment also didn't set up these two configs and it has worked for a long time.

@BewareMyPower

Copy link
Copy Markdown
Contributor

It's a real-world breaking change, not something like "it's an API that might already be used somewhere". The current semantics have already been applied in the standalone deployment of the C++/Python client tests.

I just confirmed that the Golang client tests would also fail after this change.

https://github.com/apache/pulsar-client-go/blob/055b00b83ccfef4ea12a593e3678cb4bdd18311c/integration-tests/conf/standalone.conf#L112-L115

Other ecosystems are not confirmed. But I think it's enough.

Breaking change is a breaking change not for "how it should be used", but for "whether it has already been used".

@Technoboy- Technoboy- added this to the 2.12.0 milestone Dec 12, 2022
Technoboy- pushed a commit that referenced this pull request Dec 12, 2022
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
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.
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.

6 participants