[fix][admin] Allow defaultNumPartitions for non-partitioned autoTopicCreation override
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
AutoTopicCreationOverridevalidation to allowdefaultNumPartitionsto be set whentopicType=non-partitioned(value is accepted and persisted). - Kept runtime behavior unchanged:
defaultNumPartitionsis 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 testmvn -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.
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.
Updated
validateOverrideto keep topic type validation and allowdefaultNumPartitionsforNON_PARTITIONEDonly whennull,0, or1. Updated unit tests to cover0,1, and reject2.
Please add this information to the PR description.
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.