pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

[fix][admin] Allow defaultNumPartitions for non-partitioned autoTopicCreation override

Open ChimdumebiNebolisa opened this issue 10 months ago • 2 comments

Fixes #24998

Motivation

The current namespace autoTopicCreation override validation rejects defaultNumPartitions when topicType=non-partitioned. This forces clients and IaC tooling to conditionally omit a field based on topic type, which makes the API less consistent and more error-prone.

Modifications

  • Relaxed AutoTopicCreationOverride validation to allow defaultNumPartitions to be set when topicType=non-partitioned (value is accepted and persisted).
  • Kept runtime behavior unchanged: defaultNumPartitions is still only used for partitioned auto-creation.
  • Updated unit test expectations and added a broker test to verify the value is ignored during non-partitioned topic creation.

Verifying this change

This change added tests and can be verified as follows:

  • mvn -pl pulsar-common -Dtest=AutoTopicCreationOverrideTest test
  • mvn -pl pulsar-broker -am -Dtest=AdminApi2Test#testAutoTopicCreationOverrideNonPartitionedDefaultNumPartitionsIgnored -Dsurefire.failIfNoSpecifiedTests=false test

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

  • [ ] Dependencies (add or upgrade a dependency)
  • [x] The public API
  • [ ] The schema
  • [ ] The default values of configurations
  • [ ] The threading model
  • [ ] The binary protocol
  • [x] The REST endpoints
  • [ ] The admin CLI options
  • [ ] The metrics
  • [ ] Anything that affects deployment

Documentation

  • [x] doc-not-needed

Note: Updated validateOverride to preserve topic type validation and allow defaultNumPartitions for NON_PARTITIONED topics only when the value is null, 0, or 1. Updated unit tests to cover 0, 1, and to reject 2.

ChimdumebiNebolisa avatar Jan 19 '26 01:01 ChimdumebiNebolisa

Updated validateOverride to keep topic type validation and allow defaultNumPartitions for NON_PARTITIONED only when null, 0, or 1. Updated unit tests to cover 0, 1, and reject 2.

ChimdumebiNebolisa avatar Jan 19 '26 13:01 ChimdumebiNebolisa

Updated validateOverride to keep topic type validation and allow defaultNumPartitions for NON_PARTITIONED only when null, 0, or 1. Updated unit tests to cover 0, 1, and reject 2.

Please add this information to the PR description.

lhotari avatar Jan 20 '26 08:01 lhotari

Fixed the Broker Group 3 CI failure in 1bdd1b6d0d by updating the stale validation-message assertion.

The exact failing test now passes locally, and git diff --check is clean.

The new CI runs are awaiting maintainer approval.

ChimdumebiNebolisa avatar Aug 21 '26 22:08 ChimdumebiNebolisa