Skip to content

Commit

Permalink
Fail proxy startup if brokerServiceURL is missing scheme (apache#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 f839ea2)
  • Loading branch information
michaeljmarshall authored and nicoloboschi committed Apr 28, 2022
1 parent 76697a4 commit abf9070
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 13 deletions.
3 changes: 2 additions & 1 deletion conf/proxy.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ metadataStoreUrl=
# The metadata store URL for the configuration data. If empty, we fall back to use metadataStoreUrl
configurationMetadataStoreUrl=

# 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 @@ -150,12 +150,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 @@ -162,6 +162,16 @@ public ProxyServiceStarter(String[] args) throws Exception {
config.setConfigurationMetadataStoreUrl(configurationMetadataStoreUrl);
}

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.getMetadataStoreUrl()), "metadataStoreUrl 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 @@ -756,8 +756,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|
|metadataStoreUrl| Metadata store quorum connection string (as a comma-separated list) ||
|configurationMetadataStoreUrl| 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
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,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
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
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
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 abf9070

Please sign in to comment.