Skip to content

Commit

Permalink
Fail proxy startup if brokerServiceURL is missing scheme (#14682)
Browse files Browse the repository at this point in the history
Make Pulsar Proxy fail on start up with a helpful error message if the `brokerServiceURL` or the `brokerServiceURLTLS` configurations are invalid.

I recently ran into an issue where the configured URL did not have the `pulsar://` or the `pulsar+ssl://` prefix. It would have been very helpful if the proxy had just failed on startup when it had an invalid config.

* Update documentation
* Add validation checks to the `ProxyServiceStarter` class.

(cherry picked from commit 342a5df)
(cherry picked from commit 0a169d9)
  • Loading branch information
michaeljmarshall authored and lhotari committed Jun 1, 2022
1 parent 03fb6ed commit 6bafef1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion conf/proxy.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ zookeeperServers=
# Configuration store connection string (as a comma-separated list)
configurationStoreServers=

# if Service Discovery is Disabled this url should point to the discovery service provider.
# If Service Discovery is Disabled this url should point to the discovery service provider.
# The URL must begin with pulsar:// for plaintext or with pulsar+ssl:// for TLS.
brokerServiceURL=
brokerServiceURLTLS=

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ public class ProxyConfiguration implements PulsarConfiguration {

@FieldContext(
category = CATEGORY_BROKER_DISCOVERY,
doc = "The service url points to the broker cluster"
doc = "The service url points to the broker cluster. URL must have the pulsar:// prefix."
)
private String brokerServiceURL;
@FieldContext(
category = CATEGORY_BROKER_DISCOVERY,
doc = "The tls service url points to the broker cluster"
doc = "The tls service url points to the broker cluster. URL must have the pulsar+ssl:// prefix."
)
private String brokerServiceURLTLS;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ public ProxyServiceStarter(String[] args) throws Exception {
config.setConfigurationStoreServers(configurationStoreServers);
}

if (isNotBlank(config.getBrokerServiceURL())) {
checkArgument(config.getBrokerServiceURL().startsWith("pulsar://"),
"brokerServiceURL must start with pulsar://");
}

if (isNotBlank(config.getBrokerServiceURLTLS())) {
checkArgument(config.getBrokerServiceURLTLS().startsWith("pulsar+ssl://"),
"brokerServiceURLTLS must start with pulsar+ssl://");
}

if ((isBlank(config.getBrokerServiceURL()) && isBlank(config.getBrokerServiceURLTLS()))
|| config.isAuthorizationEnabled()) {
checkArgument(!isEmpty(config.getZookeeperServers()), "zookeeperServers must be provided");
Expand Down
4 changes: 2 additions & 2 deletions site2/docs/reference-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,8 @@ The [Pulsar proxy](concepts-architecture-overview.md#pulsar-proxy) can be config
|forwardAuthorizationCredentials| Forward client authorization credentials to Broker for re-authorization, and make sure authentication is enabled for this to take effect. |false|
|zookeeperServers| The ZooKeeper quorum connection string (as a comma-separated list) ||
|configurationStoreServers| Configuration store connection string (as a comma-separated list) ||
| brokerServiceURL | The service URL pointing to the broker cluster. | |
| brokerServiceURLTLS | The TLS service URL pointing to the broker cluster | |
| brokerServiceURL | The service URL pointing to the broker cluster. Must begin with `pulsar://`. | |
| brokerServiceURLTLS | The TLS service URL pointing to the broker cluster. Must begin with `pulsar+ssl://`. | |
| brokerWebServiceURL | The Web service URL pointing to the broker cluster | |
| brokerWebServiceURLTLS | The TLS Web service URL pointing to the broker cluster | |
| functionWorkerWebServiceURL | The Web service URL pointing to the function worker cluster. It is only configured when you setup function workers in a separate cluster. | |
Expand Down

0 comments on commit 6bafef1

Please sign in to comment.