Skip to content
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

PIP 45: Deprecate zookeeper settings #14147

Merged

Conversation

codelipenghui
Copy link
Contributor

Motivation

To deprecate the zookeeper settings. PIP 45 introduced a unified metadata store API for Pulsar,
so we should make the metadata-related configuration start with metadataStore, not zooKeeper.

Modification

change zooKeeperSessionTimeoutMillis to metadataStoreSessionTimeoutMillis
change zooKeeperOperationTimeoutSeconds to metadataStoreOperationTimeoutSeconds
change zooKeeperCacheExpirySeconds to metadataStoreCacheExpirySeconds

Compatibility

Introduced set method for the deprecated configurations. If the broker read the configurations
from the old version config file, the configuration loader will use the set method to apply the
configured value to new configurations.

Tests

Add new tests to make sure the change will not introduce a regression.

@codelipenghui codelipenghui added the doc-required Your PR changes impact docs and you will update later. label Feb 7, 2022
@codelipenghui codelipenghui self-assigned this Feb 7, 2022
@codelipenghui codelipenghui added this to the 2.10.0 milestone Feb 7, 2022
To deprecate the zookeeper settings. PIP 45 introduced unified metadata store API for Pulsar,
so we should make the metadata related configuration start with `metadataStore`, not `zooKeeper`.

change `zooKeeperSessionTimeoutMillis` to `metadataStoreSessionTimeoutMillis`
change `zooKeeperOperationTimeoutSeconds` to `metadataStoreOperationTimeoutSeconds`
change `zooKeeperCacheExpirySeconds` to `metadataStoreCacheExpirySeconds`

Introduced set method for the deprecated configurations. If the broker read the configurations
from the old version config file, the configuration loader will use the set method to apply the
configued value to new configurations.

Add new test to make sure the change will not introduce regression.
@codelipenghui codelipenghui force-pushed the penghui/deprecate-zookeeper-settings branch from f2c1186 to dcea79d Compare February 7, 2022 10:22
@codelipenghui codelipenghui changed the title Deprecate zookeeper settings PIP 45: Deprecate zookeeper settings Feb 7, 2022
f.set(obj, value(trim(v), f));
try {
Method method = Reflections.getSetMethod(obj.getClass(), f);
method.invoke(obj, value(v, f));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v --> trim(v) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

@nodece nodece left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@FieldContext(
category = CATEGORY_SERVER,
doc = "ZooKeeper cache expiry time in seconds"
doc = "ZooKeeper cache expiry time in seconds. "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd better use deprecated = true in fieldContext instead of doc.

testConfigFile.delete();
}
try (PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(testConfigFile)))) {
printWriter.println("zooKeeperSessionTimeoutMillis=60");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add another test where the configuration contains both zooKeeper* and metadataStore* properties ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicoloboschi I have changed the PR, could you please help review it again?

@@ -1609,9 +1609,6 @@ public static WorkerConfig initializeWorkerConfigFromBrokerConfig(ServiceConfigu
workerConfig.setAuthorizationEnabled(brokerConfig.isAuthorizationEnabled());
workerConfig.setAuthorizationProvider(brokerConfig.getAuthorizationProvider());
workerConfig.setConfigurationMetadataStoreUrl(brokerConfig.getConfigurationMetadataStoreUrl());
workerConfig.setZooKeeperSessionTimeoutMillis(brokerConfig.getZooKeeperSessionTimeoutMillis());
workerConfig.setZooKeeperOperationTimeoutSeconds(brokerConfig.getZooKeeperOperationTimeoutSeconds());

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that we need to set metadataStoreSessionTimeoutMillis etc. for the workerConfig here.

Comment on lines 75 to 77
@FieldContext(doc = "ZooKeeper session timeout in milliseconds. "
+ "@deprecated - Use metadataStoreSessionTimeoutMillis instead.")
private long zooKeeperSessionTimeoutMillis = 30000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@FieldContext(doc = "ZooKeeper session timeout in milliseconds. "
+ "@deprecated - Use metadataStoreSessionTimeoutMillis instead.")
private long zooKeeperSessionTimeoutMillis = 30000;
@Deprecated
@FieldContext(doc = "ZooKeeper session timeout in milliseconds. "
+ "@deprecated - Use metadataStoreSessionTimeoutMillis instead.",
deprecated = true)
private long zooKeeperSessionTimeoutMillis = 30000;

It's better to add deprecated here.

Comment on lines 79 to 81
@FieldContext(doc = "ZooKeeper cache expiry time in seconds. "
+ "@deprecated - Use metadataStoreCacheExpirySeconds instead.")
private int zooKeeperCacheExpirySeconds = 300;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@FieldContext(doc = "ZooKeeper cache expiry time in seconds. "
+ "@deprecated - Use metadataStoreCacheExpirySeconds instead.")
private int zooKeeperCacheExpirySeconds = 300;
@Deprecated
@FieldContext(doc = "ZooKeeper cache expiry time in seconds. "
+ "@deprecated - Use metadataStoreCacheExpirySeconds instead.",
deprecated = true)
private int zooKeeperCacheExpirySeconds = 300;

It's better to add deprecated here.

@codelipenghui
Copy link
Contributor Author

@nicoloboschi @Jason918 @RobertIndie @hangc0276 @nodece I have pushed new commits to make sure the change will not break running Pulsar in the Docker environment because we are using a script to change the config value. For the helm chart, it will use the new config file but with old config names, as @nicoloboschi mentioned both of the new configs and the deprecated configs will be present in the new config file. So I changed the default value of the deprecated configs to -1, the new config value only is applied while the old value is absent.

@@ -53,5 +59,55 @@ public void testConfigFileDefaults() throws Exception {
}
}

@Test
public void testBackwardCompatibility() throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about testZooKeeperConfigurationBackwardCompatibilty ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to keep testBackwardCompatibility(), if we have other changes need to keep backward compatibility, we can just add items to the test, otherwise, we need many tests methods.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@nicoloboschi nicoloboschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, great work

@merlimat merlimat merged commit 3e06571 into apache:master Feb 9, 2022
@Anonymitaet Anonymitaet added doc-complete Your PR changes impact docs and the related docs have been already added. and removed doc-required Your PR changes impact docs and you will update later. labels Feb 10, 2022
@codelipenghui codelipenghui deleted the penghui/deprecate-zookeeper-settings branch April 12, 2022 08:15
Nicklee007 pushed a commit to Nicklee007/pulsar that referenced this pull request Apr 20, 2022
* Deprecate zookeeper settings

To deprecate the zookeeper settings. PIP 45 introduced unified metadata store API for Pulsar,
so we should make the metadata related configuration start with `metadataStore`, not `zooKeeper`.

change `zooKeeperSessionTimeoutMillis` to `metadataStoreSessionTimeoutMillis`
change `zooKeeperOperationTimeoutSeconds` to `metadataStoreOperationTimeoutSeconds`
change `zooKeeperCacheExpirySeconds` to `metadataStoreCacheExpirySeconds`

Introduced set method for the deprecated configurations. If the broker read the configurations
from the old version config file, the configuration loader will use the set method to apply the
configued value to new configurations.

Add new test to make sure the change will not introduce regression.

* Apply comment

* Apply comment

* Apply comment

* Apply comment

* Apply comment.
@codelipenghui codelipenghui restored the penghui/deprecate-zookeeper-settings branch May 17, 2022 01:22
@codelipenghui codelipenghui deleted the penghui/deprecate-zookeeper-settings branch May 17, 2022 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-complete Your PR changes impact docs and the related docs have been already added.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet