-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[improve][broker] Add parameter check for create/update cluster. #19151
Conversation
@codelipenghui @eolivelli @Jason918 @congbobo184 @nicoloboschi |
Codecov Report
@@ Coverage Diff @@
## master #19151 +/- ##
============================================
- Coverage 47.46% 44.29% -3.17%
+ Complexity 10727 10057 -670
============================================
Files 711 713 +2
Lines 69456 69683 +227
Branches 7452 7483 +31
============================================
- Hits 32964 30865 -2099
- Misses 32810 35206 +2396
+ Partials 3682 3612 -70
Flags with carried forward coverage won't be shown. Click here to find out more.
|
pulsar-common/src/test/java/org/apache/pulsar/common/policies/data/ClusterDataTest.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LinuxInfoUtils.java
Outdated
Show resolved
Hide resolved
…ce/LinuxInfoUtils.java
@@ -775,7 +773,7 @@ public void resourceQuotas() throws Exception { | |||
TenantInfoImpl admin = TenantInfoImpl.builder() | |||
.allowedClusters(Collections.singleton(cluster)) | |||
.build(); | |||
ClusterDataImpl clusterData = ClusterDataImpl.builder().serviceUrl(cluster).build(); | |||
ClusterDataImpl clusterData = ClusterDataImpl.builder().serviceUrl("http://example.pulsar").build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a breaking change? I haven't reviewed the details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a breaking change; we just didn't have data validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@mattisonchao Is this PR a potential breaking change? Please check #19212 . |
@mattisonchao I wonder if a "https" url would need to be accepted in the serviceUrl just because of backwards compatibility reasons? |
public void checkPropertiesIfPresent() throws IllegalArgumentException { | ||
URIPreconditions.checkURIIfPresent(getServiceUrl(), | ||
uri -> Objects.equals(uri.getScheme(), "http"), | ||
"Illegal service url, example: http://pulsar.example.com:8080"); | ||
URIPreconditions.checkURIIfPresent(getServiceUrlTls(), | ||
uri -> Objects.equals(uri.getScheme(), "https"), | ||
"Illegal service tls url, example: https://pulsar.example.com:8443"); | ||
URIPreconditions.checkURIIfPresent(getBrokerServiceUrl(), | ||
uri -> Objects.equals(uri.getScheme(), "pulsar"), | ||
"Illegal broker service url, example: pulsar://pulsar.example.com:6650"); | ||
URIPreconditions.checkURIIfPresent(getBrokerServiceUrlTls(), | ||
uri -> Objects.equals(uri.getScheme(), "pulsar+ssl"), | ||
"Illegal broker service tls url, example: pulsar+ssl://pulsar.example.com:6651"); | ||
URIPreconditions.checkURIIfPresent(getProxyServiceUrl(), | ||
uri -> Objects.equals(uri.getScheme(), "pulsar") | ||
|| Objects.equals(uri.getScheme(), "pulsar+ssl"), | ||
"Illegal proxy service url, example: pulsar+ssl://ats-proxy.example.com:4443 " | ||
+ "or pulsar://ats-proxy.example.com:4080"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we document these requirements? Also, what would happen if a user had already created a cluster in a bad state?
Motivation
In the current implementation, we didn't have any cluster data check for
create/update
cluster. it may cause some problems when the user sets the wrong URL.Modifications
Verifying this change
Does this pull request potentially affect one of the following parts:
Documentation
doc-not-needed