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
[Issue #5395][broker] Implement AutoTopicCreation by namespace override #6471
[Issue #5395][broker] Implement AutoTopicCreation by namespace override #6471
Conversation
Hi @sijie, I am unsure if the documentation that I added is enough. Is there another place I should be adding docs? Could you point me to it? Thanks. |
@jiazhai @codelipenghui can you help review this pull request? |
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.
The changes looks good, Some suggestions on naming:
Is it better to named to set-topic-auto-creation-policy
and get-topic-auto-creation-policy
?
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"), | ||
@ApiResponse(code = 404, message = "Tenant or cluster or namespace doesn't exist"), | ||
@ApiResponse(code = 400, message = "Invalid autoTopicCreation override") }) | ||
public void setAllowAutoTopicCreationOverride(@PathParam("tenant") String tenant, @PathParam("namespace") String namespace, |
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 better to leverage with AsyncResponse
, you can take a look https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/PersistentTopics.java#L198.
@ApiOperation(value = "Remove override of broker's allowAutoTopicCreation in a namespace") | ||
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"), | ||
@ApiResponse(code = 404, message = "Tenant or cluster or namespace doesn't exist") }) | ||
public void removeAllowAutoTopicCreationOverride(@PathParam("tenant") String tenant, @PathParam("namespace") String namespace) { |
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.
Same as above comment.
Thanks @codelipenghui . I made changes to use |
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.
I also want to suggest something in the name. All the namespace level policies are overwritten the broker level configurations, so do we need to add overwrite
to the method name?
validateAdminAccessForTenant(namespaceName.getTenant()); | ||
validatePoliciesReadOnlyAccess(); | ||
|
||
if (!AutoTopicCreationOverride.isValidOverride(autoTopicCreationOverride)) { | ||
throw new RestException(Status.PRECONDITION_FAILED, "Invalid configuration for autoTopicCreationOverride"); | ||
} |
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.
We'd better complete the asyncResponse
when there are RunTimeException occurs. Otherwise, the client just can get a 500
response but can't get any error messages.
validateAdminAccessForTenant(namespaceName.getTenant()); | ||
validatePoliciesReadOnlyAccess(); |
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.
Same as above comment.
@codelipenghui I don't quite understand your naming suggestion. The new setting is an I added catches in the top level call in order to complete the async response. Let me know if you have any more suggestions. Thanks |
/pulsarbot run-failure-checks |
fyi tests passing now @codelipenghui |
@klevy-toast Can you help fix the checkstyle issue? The master branch enables checkstyle for pulsar-admin. |
/pulsarbot run-failure-checks |
@klevy-toast thank you so much for your contributions! |
For merge conflict. mark as 2.5.2 and cherry-picked into branch-2.5 |
…de (#6471) Fixes #5395 This change introduces a new namespace policy `autoTopicCreationOverride`, which will enable an override of broker `autoTopicCreation` settings on the namespace level. You may keep `autoTopicCreation` disabled for the broker and allow it on a specific namespace using this feature. - Add new namespace policy: `autoTopicCreationOverride` and associated API / CLI interface for setting and removing. Defaults to non-partitioned type, but also allows partitioned topics. - Modifies BrokerService: when checking `autoTopicCreation` configuration, the broker first retrieves namespace policies from zookeeper. If the `autoTopicCreationOverride` policy exists for that namespace then it uses those settings. If not, falls back to broker configuration. - Slight refactor to move `TopicType` enum to pulsar-common and add `autoTopicCreationOverride` to pulsar-common. (cherry picked from commit fdc3a9b)
Docs have been added: |
…override (apache#6471) Fixes apache#5395 ### Motivation This change introduces a new namespace policy `autoTopicCreationOverride`, which will enable an override of broker `autoTopicCreation` settings on the namespace level. You may keep `autoTopicCreation` disabled for the broker and allow it on a specific namespace using this feature. ### Modifications - Add new namespace policy: `autoTopicCreationOverride` and associated API / CLI interface for setting and removing. Defaults to non-partitioned type, but also allows partitioned topics. - Modifies BrokerService: when checking `autoTopicCreation` configuration, the broker first retrieves namespace policies from zookeeper. If the `autoTopicCreationOverride` policy exists for that namespace then it uses those settings. If not, falls back to broker configuration. - Slight refactor to move `TopicType` enum to pulsar-common and add `autoTopicCreationOverride` to pulsar-common.
PR apache#6471 introduced the possibility to set auto topic creation settings at the namespace level PR apache#6685 is a fix to take into account the auto topic creation setting when creating a subscription but it uses the broker configuration and doesn't see the namespace level setting that was introduced in apache#6471 This fix uses the method that fetches config overrides in ZK instead of the one from the broker configuration. This way the method of the pulsar-admin uses the value set for the namespace for auto-topic-creation
PR apache#6471 introduced the possibility to set auto topic creation settings at the namespace level PR apache#6685 is a fix to take into account the auto topic creation setting when creating a subscription but it uses the broker configuration and doesn't see the namespace level setting that was introduced in apache#6471 This fix uses the method that fetches config overrides in ZK instead of the one from the broker configuration. This way the method of the pulsar-admin uses the value set for the namespace for auto-topic-creation
PR apache#6471 introduced the possibility to set auto topic creation settings at the namespace level PR apache#6685 is a fix to take into account the auto topic creation setting when creating a subscription but it uses the broker configuration and doesn't see the namespace level setting that was introduced in apache#6471 This fix uses the method that fetches config overrides in ZK instead of the one from the broker configuration. This way the method of the pulsar-admin uses the value set for the namespace for auto-topic-creation
PR apache#6471 introduced the possibility to set auto topic creation settings at the namespace level PR apache#6685 is a fix to take into account the auto topic creation setting when creating a subscription but it uses the broker configuration and doesn't see the namespace level setting that was introduced in apache#6471 This fix uses the method that fetches config overrides in ZK instead of the one from the broker configuration. This way the method of the pulsar-admin uses the value set for the namespace for auto-topic-creation
) PR #6471 introduced the possibility to set auto topic creation settings at the namespace level PR #6685 is a fix to take into account the auto topic creation setting when creating a subscription but it uses the broker configuration and doesn't see the namespace level setting that was introduced in #6471 This fix uses the method that fetches config overrides in ZK instead of the one from the broker configuration. This way the method of the pulsar-admin uses the value set for the namespace for auto-topic-creation
) PR #6471 introduced the possibility to set auto topic creation settings at the namespace level PR #6685 is a fix to take into account the auto topic creation setting when creating a subscription but it uses the broker configuration and doesn't see the namespace level setting that was introduced in #6471 This fix uses the method that fetches config overrides in ZK instead of the one from the broker configuration. This way the method of the pulsar-admin uses the value set for the namespace for auto-topic-creation (cherry picked from commit 965a80f)
) PR #6471 introduced the possibility to set auto topic creation settings at the namespace level PR #6685 is a fix to take into account the auto topic creation setting when creating a subscription but it uses the broker configuration and doesn't see the namespace level setting that was introduced in #6471 This fix uses the method that fetches config overrides in ZK instead of the one from the broker configuration. This way the method of the pulsar-admin uses the value set for the namespace for auto-topic-creation (cherry picked from commit 965a80f)
…che#12699) PR apache#6471 introduced the possibility to set auto topic creation settings at the namespace level PR apache#6685 is a fix to take into account the auto topic creation setting when creating a subscription but it uses the broker configuration and doesn't see the namespace level setting that was introduced in apache#6471 This fix uses the method that fetches config overrides in ZK instead of the one from the broker configuration. This way the method of the pulsar-admin uses the value set for the namespace for auto-topic-creation (cherry picked from commit 965a80f) (cherry picked from commit a034d14)
…che#12699) PR apache#6471 introduced the possibility to set auto topic creation settings at the namespace level PR apache#6685 is a fix to take into account the auto topic creation setting when creating a subscription but it uses the broker configuration and doesn't see the namespace level setting that was introduced in apache#6471 This fix uses the method that fetches config overrides in ZK instead of the one from the broker configuration. This way the method of the pulsar-admin uses the value set for the namespace for auto-topic-creation
Fixes #5395
Motivation
This change introduces a new namespace policy
autoTopicCreationOverride
, which will enable an override of brokerautoTopicCreation
settings on the namespace level. You may keepautoTopicCreation
disabled for the broker and allow it on a specific namespace using this feature.Modifications
autoTopicCreationOverride
and associated API / CLI interface for setting and removing. Defaults to non-partitioned type, but also allows partitioned topics.autoTopicCreation
configuration, the broker first retrieves namespace policies from zookeeper. If theautoTopicCreationOverride
policy exists for that namespace then it uses those settings. If not, falls back to broker configuration.TopicType
enum to pulsar-common and addautoTopicCreationOverride
to pulsar-common.Verifying this change
(Please pick either of the following options)
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
POST
andDELETE
for/{tenant}/{namespace}/allowAutoTopicCreationOverride
in order to set new namespace policy)POST
andDELETE
for/{tenant}/{namespace}/allowAutoTopicCreationOverride
in order to set new namespace policy)set-allow-auto-topic-creation-override
anddelete-allow-auto-topic-creation-override
)Documentation