GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||
GeezerVison is showing github.com — [fix][broker] Match namespace isolation policy brokers given as host:port by aywengo · Pull Request #26829 · apache/pulsar Conversation
|
| File | Description |
|---|---|
NamespaceIsolationPolicyImpl.java |
Adds host/port matching and URL port handling. |
NamespaceIsolationPolicyImplTest.java |
Tests port-aware and IPv6 matching. |
LoadManagerShared.java |
Checks policies against hosts and broker IDs. |
BrokerIsolationPoliciesFilterTest.java |
Tests asynchronous broker-ID filtering. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
c8b6f59 to
b32aa98
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
IPv6 IDs, reporting paths, and shared-pool isolation remain incorrect for port-specific policies.
🧠 Review effort: Balanced
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Anchored host-port regexes are misclassified as host-only and therefore never applied.
🧠 Review effort: Balanced
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
IPv6 URL normalization and port-specific matching against IPv6 hosts can currently produce incorrect policy results.
0 open findings
In code that hasn't changed since last review
pulsar-common/src/main/java/org/apache/pulsar/common/policies/impl/NamespaceIsolationPolicyImpl.java:65
URL#getHost() keeps brackets around IPv6 literals, so the explicitly supported host-only IPv6 policy 2001:db8::1 does not match http://[2001:db8::1]:8080 in either findPrimaryBrokers or findSecondaryBrokers. Normalize the URL host before applying both host and broker-ID matching.
This issue also appears on line 137 of the same file.
🧠 Review effort: Balanced
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…port Brokers are identified as host:port (e.g. in `pulsar-admin brokers list` and `pulsar-admin ns-isolation-policy brokers`), but namespace isolation policies were only ever matched against the broker host. As a result a policy with `--primary hostname1:8080` was accepted but never applied, and the `ns-isolation-policy brokers/broker` admin endpoints reported no policy for brokers that did match a host-only policy. - NamespaceIsolationPolicyImpl: match a broker against the full value first and, if it has a numeric port suffix, against the host part. findPrimaryBrokers/findSecondaryBrokers now also consider host:port. - LoadManagerShared: check isolation policies against both the broker host and the broker id (host:port). Fixes apache#15795
URL#getHost returns IPv6 literals in brackets while broker ids use the bare address, so findPrimaryBrokers/findSecondaryBrokers now match the bare form and keep matching the bracketed form for backward compatibility.
Address review feedback: matching the full broker id against every policy regex, and stripping a trailing port from any value, changed how existing host regexes are applied (e.g. `broker.*[13]` matched `broker2:8081`, and the last segment of an IPv6 host was taken for a port). Host regexes are now matched against the broker host exactly as before. Only policy entries that name a specific port (`host:port`) are matched against the broker id, through new isPrimaryBrokerId/isSecondaryBrokerId methods. Such entries never matched before, so existing policies keep their current placement.
… reporting - A broker reserved as primary by a port-specific entry (host:port) was still considered shared for namespaces without an isolation policy, because the shared-pool check only looked at the broker host. The load manager now also excludes such brokers from the shared pool. - `ns-isolation-policy brokers/broker` and the namespace ownership status now match host entries against the broker host and port-specific entries against the broker id, the same way placement does. - Placement tests use SimpleResourceAllocationPolicies with real stored policies instead of a partial mock.
Allow an optional trailing $ so entries such as ^broker1:8080$ are matched against the broker id instead of being treated as host-only.
80da8b4 to
cd2cdb1
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on #15795 and for iterating on the earlier feedback. Matching port-specific entries against the broker id keeps existing host-only policies unchanged. The shared-pool exclusion, the ClustersBase and ownership-status handling, and the placement tests with real policies are good additions.
Placement works for the entry forms that HOST_PORT_REGEX recognises. The main point is that it recognises only a few shapes. Other port entries, and any IPv6 entry, silently never match. A simpler rule would handle all of them: treat any entry that contains : as possibly port-specific, and also match it against the bracketed host:port form.
The other comments are small follow-ups: a few missing regression tests, docs for the accepted entry form, and a misleading code comment in isPrimaryBrokerIdInAnyPolicy.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Address review feedback: recognising port-specific entries by their regex
shape missed valid entries such as `broker1:8080|broker2:8080`,
`broker1:80[0-9]{2}` and any IPv6 entry, which then silently never matched.
- An entry that contains ':' is now matched against both the broker host and
host:port. Entries without ':' keep their current meaning.
- host:port is built with HostAndPort, so an IPv6 broker uses the bracketed
form, e.g. `\[2001:db8::1\]:8080`, and the last address segment is never
taken for a port.
- findPrimaryBrokers/findSecondaryBrokers also match the bare IPv6 host.
- Document the accepted forms in the --primary/--secondary help text.
- Drop the misleading fail-closed comment in isPrimaryBrokerIdInAnyPolicy.
- Add AdminApi2Test coverage for reporting and ownership status with a
host:port primary entry.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The : rule is in, and I traced each shape from my earlier review through the new code. They all match now. The three open points are addressed. I did not run the build or the tests.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@codelipenghui please review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…port (apache#26829) (cherry picked from commit 25fe96c)
…port (apache#26829) (cherry picked from commit 25fe96c)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
在配置ns-isolation-policy 的时候broker的配置不能采用hostname:端口
There was an error while loading. Please reload this page.