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

Fix namespace policy override ignored when creating subscription #12699

Merged
merged 1 commit into from
Dec 9, 2021

Conversation

cbornet
Copy link
Contributor

@cbornet cbornet commented Nov 9, 2021

Motivation

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

Modifications

This fix uses the BrokerService isAllowAutoTopicCreation 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

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • Undo the changes in PersistentTopicsBase.java and the tests won't pass anymore

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (yes / no) no
  • The public API: (yes / no) no
  • The schema: (yes / no / don't know) no
  • The default values of configurations: (yes / no) no
  • The wire protocol: (yes / no) no
  • The rest endpoints: (yes / no) no
  • The admin cli options: (yes / no) no
  • Anything that affects deployment: (yes / no / don't know) no

Documentation

Check the box below and label this PR (if you have committer privilege).

Need to update docs?

  • doc-required

  • no-need-doc

    It's a fix

  • doc

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Nov 9, 2021
.defaultNumPartitions(3)
.build());

admin.topics().createSubscription(topicString + "-partition-0", subscriptionName, MessageId.earliest);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to subscribe a to specific partition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that's the intent. I've seen it done here so I guess it's OK.
Also this way the topic is created by pulsar().getBrokerService().getTopic() in internalCreateSubscriptionForNonPartitionedTopic instead of pulsar().getBrokerService().fetchPartitionedTopicMetadataCheckAllowAutoCreationAsync() when you don't specify a partition.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I don't understand why change the namespace level policy for topic auto-creation to create partitioned topic with 3 partitions, but here check if able to subscribe to one partition, looks like not able to ensure the partitioned topic has been created?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see. This test doesn't really make sense. I removed it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that currently it's possible to create a topic partition from the subscription creation without the full partitioned topic being created. Is it OK to be able to do that ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@codelipenghui is it OK for you ?

@codelipenghui codelipenghui added this to the 2.10.0 milestone Nov 9, 2021
Copy link
Member

@michaeljmarshall michaeljmarshall 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

@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

@cbornet cbornet force-pushed the auto-topic-subscription branch 2 times, most recently from eebbe33 to 6c5e81f Compare November 10, 2021 10:35
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
@merlimat merlimat merged commit 965a80f into apache:master Dec 9, 2021
lhotari pushed a commit that referenced this pull request Dec 10, 2021
)

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)
@lhotari lhotari added cherry-picked/branch-2.8 Archived: 2.8 is end of life release/2.8.2 and removed release/2.8.3 labels Dec 10, 2021
lhotari pushed a commit that referenced this pull request Dec 10, 2021
)

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)
@lhotari lhotari added the cherry-picked/branch-2.9 Archived: 2.9 is end of life label Dec 10, 2021
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Dec 10, 2021
…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)
@cbornet cbornet deleted the auto-topic-subscription branch December 13, 2021 10:15
fxbing pushed a commit to fxbing/pulsar that referenced this pull request Dec 19, 2021
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-picked/branch-2.8 Archived: 2.8 is end of life cherry-picked/branch-2.9 Archived: 2.9 is end of life doc-not-needed Your PR changes do not impact docs release/2.8.2 release/2.9.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants