You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "oneby-wang (via GitHub)" <gi...@apache.org> on 2025/09/19 06:26:45 UTC
[PR] [fix][admin] set local policies overwrites "number of bundles" passed during namespace creation [pulsar]
oneby-wang opened a new pull request, #24762:
URL: https://github.com/apache/pulsar/pull/24762
<!-- Either this PR fixes an issue, -->
Fixes [#xyz]([[Bug] set-bookie-affinity-group overwrites "number of bundles" passed during namespace creation · Is](https://github.com/apache/pulsar/issues/23897))
### Motivation
<!-- Explain here the context, and why you're making that change. What is the problem you're trying to solve. -->
Set local policies will overwrite "number of bundles" passed during namespace creation. If we don't call any get namespace policies operation, local policies will not be created, so it will be overwritten.
[pulsar/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/NamespaceBundleFactory.java at 88](https://github.com/apache/pulsar/blob/8879b3ba9daa6de9b8b78bbce89bab68cc37cf0b/pulsar-broker/src/main/java/org/apache/pulsar/common/naming/NamespaceBundleFactory.java#L164-L182)
The following steps can reproduce the problem.
1. pulsar-admin namespaces create t/n --bundles 10
2. pulsar-admin namespaces set-bookie-affinity-group --primary-group temp t/n
3. pulsar-admin namespaces bundles t/n
But the following step will not reproduce the problem.
1. pulsar-admin namespaces create t/n --bundles 10
2. pulsar-admin namespaces bundles t/n
3. pulsar-admin namespaces set-bookie-affinity-group --primary-group temp t/n
4. pulsar-admin namespaces bundles t/n
### Modifications
<!-- Describe the modifications you've done. -->
If local policies is not present, first try to use namespace policies bundle data, then fallback to `config().getDefaultNumberOfNamespaceBundles()`
### Verifying this change
- [ ] Make sure that the change passes the CI checks.
### Does this pull request potentially affect one of the following parts:
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
*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
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
### Matching PR in forked repository
PR in forked repository:
<!--
After opening this PR, the build in apache/pulsar will fail and instructions will
be provided for opening a PR in the PR author's forked repository.
apache/pulsar pull requests should be first tested in your own fork since the
apache/pulsar CI based on GitHub Actions has constrained resources and quota.
GitHub Actions provides separate quota for pull requests that are executed in
a forked repository.
The tests will be run in the forked repository until all PR review comments have
been handled, the tests pass and the PR is approved by a reviewer.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][admin] Set local policies overwrites "number of bundles" passed during namespace creation [pulsar]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #24762:
URL: https://github.com/apache/pulsar/pull/24762#issuecomment-3396533617
## [Codecov](https://app.codecov.io/gh/apache/pulsar/pull/24762?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `31.25000%` with `11 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 74.16%. Comparing base ([`8879b3b`](https://app.codecov.io/gh/apache/pulsar/commit/8879b3ba9daa6de9b8b78bbce89bab68cc37cf0b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`1f566f8`](https://app.codecov.io/gh/apache/pulsar/commit/1f566f87dab95df6dc7aeeb734c32702e08bc43b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 40 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/pulsar/pull/24762?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...pache/pulsar/broker/admin/impl/NamespacesBase.java](https://app.codecov.io/gh/apache/pulsar/pull/24762?src=pr&el=tree&filepath=pulsar-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fbroker%2Fadmin%2Fimpl%2FNamespacesBase.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9hZG1pbi9pbXBsL05hbWVzcGFjZXNCYXNlLmphdmE=) | 31.25% | [10 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/pulsar/pull/24762?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/pulsar/pull/24762?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #24762 +/- ##
=============================================
+ Coverage 38.31% 74.16% +35.84%
- Complexity 13047 33228 +20181
=============================================
Files 1844 1904 +60
Lines 144274 148520 +4246
Branches 16726 17214 +488
=============================================
+ Hits 55279 110145 +54866
+ Misses 81481 29583 -51898
- Partials 7514 8792 +1278
```
| [Flag](https://app.codecov.io/gh/apache/pulsar/pull/24762/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [inttests](https://app.codecov.io/gh/apache/pulsar/pull/24762/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `26.35% <0.00%> (-0.14%)` | :arrow_down: |
| [systests](https://app.codecov.io/gh/apache/pulsar/pull/24762/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `22.75% <0.00%> (+0.02%)` | :arrow_up: |
| [unittests](https://app.codecov.io/gh/apache/pulsar/pull/24762/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `73.67% <31.25%> (+39.20%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Files with missing lines](https://app.codecov.io/gh/apache/pulsar/pull/24762?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [...pache/pulsar/broker/admin/impl/NamespacesBase.java](https://app.codecov.io/gh/apache/pulsar/pull/24762?src=pr&el=tree&filepath=pulsar-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fbroker%2Fadmin%2Fimpl%2FNamespacesBase.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9hZG1pbi9pbXBsL05hbWVzcGFjZXNCYXNlLmphdmE=) | `76.31% <31.25%> (+44.87%)` | :arrow_up: |
... and [1408 files with indirect coverage changes](https://app.codecov.io/gh/apache/pulsar/pull/24762/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][admin] set local policies overwrites "number of bundles" passed during namespace creation [pulsar]
Posted by "oneby-wang (via GitHub)" <gi...@apache.org>.
oneby-wang commented on PR #24762:
URL: https://github.com/apache/pulsar/pull/24762#issuecomment-3311890424
> From the PR description, it seems possible to add a test?
Thanks for advice, I'll add unit test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][admin] Set local policies overwrites "number of bundles" passed during namespace creation [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari merged PR #24762:
URL: https://github.com/apache/pulsar/pull/24762
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][admin] Set local policies overwrites "number of bundles" passed during namespace creation [pulsar]
Posted by "oneby-wang (via GitHub)" <gi...@apache.org>.
oneby-wang commented on PR #24762:
URL: https://github.com/apache/pulsar/pull/24762#issuecomment-3329297570
Seems the anti-affinity works at the bundle level.
https://github.com/apache/pulsar/blob/7c8d3c9210dcaf1d0c3b487af325b7b0a9dc3095/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LoadManagerShared.java#L588-L620
I think this unit test may work in a wrong way due to this PR issue, so I changed numBundles to 1 in createNamespace method.
https://github.com/apache/pulsar/blob/7c8d3c9210dcaf1d0c3b487af325b7b0a9dc3095/tests/integration/src/test/java/org/apache/pulsar/tests/integration/loadbalance/ExtensibleLoadManagerTest.java#L315-L321
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][admin] set local policies overwrites "number of bundles" passed during namespace creation [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on code in PR #24762:
URL: https://github.com/apache/pulsar/pull/24762#discussion_r2362628580
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:
##########
@@ -2907,5 +2908,16 @@ protected CompletableFuture<Set<String>> internalGetNamespaceAllowedClustersAsyn
.thenApply(policies -> policies.allowed_clusters);
}
-
+ private BundlesData getDefaultBundleData() {
+ Optional<Policies> nsPolicies;
+ try {
+ nsPolicies = namespaceResources().getPolicies(namespaceName);
Review Comment:
This is a blocking method, please refactor the solution so that blocking methods aren't used
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][admin] Set local policies overwrites "number of bundles" passed during namespace creation [pulsar]
Posted by "oneby-wang (via GitHub)" <gi...@apache.org>.
oneby-wang commented on PR #24762:
URL: https://github.com/apache/pulsar/pull/24762#issuecomment-3327366738
ExtensibleLoadManagerTest.testAntiaffinityPolicy() unit test failure in fork repository PR.
https://github.com/oneby-wang/pulsar/actions/runs/17970886848/job/51114222121?pr=5
Seems this default bundle config affects unit test.
https://github.com/apache/pulsar/blob/7c8d3c9210dcaf1d0c3b487af325b7b0a9dc3095/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java#L1792-L1793
PoliciesUtil.defaultBundle() method.
https://github.com/apache/pulsar/blob/7c8d3c9210dcaf1d0c3b487af325b7b0a9dc3095/pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/PoliciesUtil.java#L33-L41
Seems some bugs in ExtensibleLoadManager or ExtensibleLoadManagerTest?
https://pulsar.apache.org/docs/3.0.x/administration-load-balance/#distribute-anti-affinity-namespaces-across-failure-domains
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][admin] Set local policies overwrites "number of bundles" passed during namespace creation [pulsar]
Posted by "oneby-wang (via GitHub)" <gi...@apache.org>.
oneby-wang commented on PR #24762:
URL: https://github.com/apache/pulsar/pull/24762#issuecomment-3396422078
/pulsarbot rerun-failure-checks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][admin] set local policies overwrites "number of bundles" passed during namespace creation [pulsar]
Posted by "oneby-wang (via GitHub)" <gi...@apache.org>.
oneby-wang commented on code in PR #24762:
URL: https://github.com/apache/pulsar/pull/24762#discussion_r2365493009
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:
##########
@@ -2907,5 +2908,16 @@ protected CompletableFuture<Set<String>> internalGetNamespaceAllowedClustersAsyn
.thenApply(policies -> policies.allowed_clusters);
}
-
+ private BundlesData getDefaultBundleData() {
+ Optional<Policies> nsPolicies;
+ try {
+ nsPolicies = namespaceResources().getPolicies(namespaceName);
Review Comment:
Nice suggestion, already applied.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][admin] set local policies overwrites "number of bundles" passed during namespace creation [pulsar]
Posted by "oneby-wang (via GitHub)" <gi...@apache.org>.
oneby-wang commented on code in PR #24762:
URL: https://github.com/apache/pulsar/pull/24762#discussion_r2362649408
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:
##########
@@ -2907,5 +2908,16 @@ protected CompletableFuture<Set<String>> internalGetNamespaceAllowedClustersAsyn
.thenApply(policies -> policies.allowed_clusters);
}
-
+ private BundlesData getDefaultBundleData() {
+ Optional<Policies> nsPolicies;
+ try {
+ nsPolicies = namespaceResources().getPolicies(namespaceName);
Review Comment:
There are many synchronous calls in the admin v2 Namespaces. I had no choice but to use a synchronous call here because the upstream methods are using synchronous calls. I plan to submit several PRs to replace the synchronous operations with asynchronous ones after this PR in admin v2 Namespaces. WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][admin] set local policies overwrites "number of bundles" passed during namespace creation [pulsar]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #24762:
URL: https://github.com/apache/pulsar/pull/24762#issuecomment-3310785637
@oneby-wang Please add the following content to your PR description and select a checkbox:
```
- [ ] `doc` <!-- Your PR contains doc changes -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][admin] set local policies overwrites "number of bundles" passed during namespace creation [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on code in PR #24762:
URL: https://github.com/apache/pulsar/pull/24762#discussion_r2362682379
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:
##########
@@ -2907,5 +2908,16 @@ protected CompletableFuture<Set<String>> internalGetNamespaceAllowedClustersAsyn
.thenApply(policies -> policies.allowed_clusters);
}
-
+ private BundlesData getDefaultBundleData() {
+ Optional<Policies> nsPolicies;
+ try {
+ nsPolicies = namespaceResources().getPolicies(namespaceName);
Review Comment:
Oh yes, I see that now. I guess one way to prepare for this would be to already add a `getDefaultBundleDataAsync` method and then have the `getDefaultBundleData` delegate to the async method. That's a pattern that has been used in other locations.
Btw. One surprising detail about getPolicies and getPoliciesAsync method is that the behavior is different. getPoliciesAsync will use the metadata cache, but getPolicies will always make a call to get the content:
https://github.com/apache/pulsar/blob/936afecede8374b14d13e9d48e9372fec1c27447/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/NamespaceResources.java#L121-L138
It's not very great that the behavior is different.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [fix][admin] set local policies overwrites "number of bundles" passed during namespace creation [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on code in PR #24762:
URL: https://github.com/apache/pulsar/pull/24762#discussion_r2362682379
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:
##########
@@ -2907,5 +2908,16 @@ protected CompletableFuture<Set<String>> internalGetNamespaceAllowedClustersAsyn
.thenApply(policies -> policies.allowed_clusters);
}
-
+ private BundlesData getDefaultBundleData() {
+ Optional<Policies> nsPolicies;
+ try {
+ nsPolicies = namespaceResources().getPolicies(namespaceName);
Review Comment:
Oh yes, I see that now. I guess one way to prepare for this would be to already add a `getDefaultBundleDataAsync` method and then have the `getDefaultBundleData` delegate to the async method. That's a pattern that has been used in other locations.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org