Skip to content

[fix] PIP-457: Remove support for V1 topic names and V1 Admin API (implementation)#25304

Open
merlimat wants to merge 42 commits intoapache:masterfrom
merlimat:pip-457-impl
Open

[fix] PIP-457: Remove support for V1 topic names and V1 Admin API (implementation)#25304
merlimat wants to merge 42 commits intoapache:masterfrom
merlimat:pip-457-impl

Conversation

@merlimat
Copy link
Contributor

@merlimat merlimat commented Mar 9, 2026

This commit implements PIP-457 by removing all V1 topic name support and V1 Admin API endpoints from Apache Pulsar.

Topic naming changes:

  • Remove V1 topic name format (persistent://tenant/cluster/namespace/topic) Only V2 format is now supported (persistent://tenant/namespace/topic)
  • Remove V1 namespace name format (tenant/cluster/namespace) Only V2 format is now supported (tenant/namespace)
  • TopicName and NamespaceName constructors now reject V1 format names
  • fromPersistenceNamingEncoding() still handles 5-part managed ledger names for backward compatibility with existing stored data

V1 Admin API removal:

  • Delete entire org.apache.pulsar.broker.admin.v1 package (Namespaces, PersistentTopics, NonPersistentTopics, Properties, Brokers, BrokerStats, Clusters, Functions, ResourceQuotas, SchemasResource)
  • Delete V1 topic lookup endpoint (broker.lookup.v1.TopicLookup)
  • Delete V1 WebSocket stats endpoint (websocket.admin.v1)
  • Remove V1 servlet registrations from PulsarWebResource, ProxyServiceStarter, WebSocketServiceStarter
  • Remove /admin/v1/ path prefix handling from all client admin impls (BrokerStatsImpl, BrokersImpl, LookupImpl, NamespacesImpl, NonPersistentTopicsImpl, ResourceQuotasImpl, SchemasImpl, TopicPoliciesImpl, TopicsImpl)
  • Remove V1 cluster-aware namespace handling from NamespacesBase

Deprecated Properties API removal:

  • Delete Properties.java interface (V1 term for Tenants)
  • Remove Properties compat bridge methods from TenantsImpl
  • Remove properties() accessor from PulsarAdmin/PulsarAdminImpl

TopicVersion enum removal:

  • Delete TopicVersion.java (V1/V2 enum)
  • Remove TopicVersion parameter from healthcheck API (Brokers interface, BrokersImpl, BrokersBase, CmdBrokers)
  • Remove topicVersion HTTP query parameter from healthcheck requests
  • Simplify PulsarService.runHealthCheck() and BrokerService

V1 heartbeat and SLA namespace cleanup:

  • Remove V1 heartbeat namespace format (pulsar/cluster/brokerId) Rename V2 format methods to be the standard (pulsar/brokerId)
  • Update SLA namespace to V2 format (sla-monitor/brokerId)
  • Simplify HealthChecker to use single heartbeat topic
  • Remove V1 heartbeat registration from ServiceUnitStateTableViewBase

Property to tenant terminology rename:

  • Rename parameter/variable names from "property" to "tenant" in AdminResource, TransactionsBase, and 7 V2 Namespaces endpoints
  • Fix @PathParam("property") to @PathParam("tenant") in V2 Namespaces
  • Rename in test utilities and test variables

Configuration cleanup:

  • Remove allowAutoTopicCreationType config (V1 only)
  • Remove V1 auto-topic-creation settings from broker.conf/standalone.conf

Test cleanup:

  • Delete V1-specific test suites (V1AdminApiTest, V1AdminApi2Test, V1ProducerConsumerTest, V1ProducerConsumerBase, V1ProxyAuthenticationTest)
  • Remove V1 test cases from TopicNameTest, NamespaceNameTest
  • Update all remaining tests to use V2 format exclusively
  • Remove TopicVersion test parameters from AdminApiHealthCheckTest
  • Update SLAMonitoringTest for 2-part SLA namespace format

Fixes #xyz

Main Issue: #xyz

PIP: #xyz

Motivation

Modifications

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

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

If the box was checked, please highlight the changes

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

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@merlimat merlimat added this to the 4.2.0 milestone Mar 9, 2026
@merlimat merlimat added type/cleanup Code or doc cleanups e.g. remove the outdated documentation or remove the code no longer in use release/important-notice The changes which are important should be mentioned in the release note ready-to-test labels Mar 9, 2026
@github-actions github-actions bot added the doc-required Your PR changes impact docs and you will update later. label Mar 9, 2026
…plementation)

This commit implements PIP-457 by removing all V1 topic name support
and V1 Admin API endpoints from Apache Pulsar.

Topic naming changes:
- Remove V1 topic name format (persistent://tenant/cluster/namespace/topic)
  Only V2 format is now supported (persistent://tenant/namespace/topic)
- Remove V1 namespace name format (tenant/cluster/namespace)
  Only V2 format is now supported (tenant/namespace)
- TopicName and NamespaceName constructors now reject V1 format names
- fromPersistenceNamingEncoding() still handles 5-part managed ledger
  names for backward compatibility with existing stored data

V1 Admin API removal:
- Delete entire org.apache.pulsar.broker.admin.v1 package
  (Namespaces, PersistentTopics, NonPersistentTopics, Properties,
  Brokers, BrokerStats, Clusters, Functions, ResourceQuotas,
  SchemasResource)
- Delete V1 topic lookup endpoint (broker.lookup.v1.TopicLookup)
- Delete V1 WebSocket stats endpoint (websocket.admin.v1)
- Remove V1 servlet registrations from PulsarWebResource,
  ProxyServiceStarter, WebSocketServiceStarter
- Remove /admin/v1/ path prefix handling from all client admin impls
  (BrokerStatsImpl, BrokersImpl, LookupImpl, NamespacesImpl,
  NonPersistentTopicsImpl, ResourceQuotasImpl, SchemasImpl,
  TopicPoliciesImpl, TopicsImpl)
- Remove V1 cluster-aware namespace handling from NamespacesBase

Deprecated Properties API removal:
- Delete Properties.java interface (V1 term for Tenants)
- Remove Properties compat bridge methods from TenantsImpl
- Remove properties() accessor from PulsarAdmin/PulsarAdminImpl

TopicVersion enum removal:
- Delete TopicVersion.java (V1/V2 enum)
- Remove TopicVersion parameter from healthcheck API
  (Brokers interface, BrokersImpl, BrokersBase, CmdBrokers)
- Remove topicVersion HTTP query parameter from healthcheck requests
- Simplify PulsarService.runHealthCheck() and BrokerService

V1 heartbeat and SLA namespace cleanup:
- Remove V1 heartbeat namespace format (pulsar/cluster/brokerId)
  Rename V2 format methods to be the standard (pulsar/brokerId)
- Update SLA namespace to V2 format (sla-monitor/brokerId)
- Simplify HealthChecker to use single heartbeat topic
- Remove V1 heartbeat registration from ServiceUnitStateTableViewBase

Property to tenant terminology rename:
- Rename parameter/variable names from "property" to "tenant"
  in AdminResource, TransactionsBase, and 7 V2 Namespaces endpoints
- Fix @PathParam("property") to @PathParam("tenant") in V2 Namespaces
- Rename in test utilities and test variables

Configuration cleanup:
- Remove allowAutoTopicCreationType config (V1 only)
- Remove V1 auto-topic-creation settings from broker.conf/standalone.conf

Test cleanup:
- Delete V1-specific test suites (V1AdminApiTest, V1AdminApi2Test,
  V1ProducerConsumerTest, V1ProducerConsumerBase,
  V1ProxyAuthenticationTest)
- Remove V1 test cases from TopicNameTest, NamespaceNameTest
- Update all remaining tests to use V2 format exclusively
- Remove TopicVersion test parameters from AdminApiHealthCheckTest
- Update SLAMonitoringTest for 2-part SLA namespace format
merlimat added 18 commits March 9, 2026 13:22
- Fix import order in AdminResource (HashSet before Map)
- Remove unused ArrayList and List imports from PulsarWebResource
Migrate all test files from V1 topic name format
(persistent://tenant/cluster/namespace/topic) to V2 format
(persistent://tenant/namespace/topic).

Key changes:
- Replace V1 topic names with V2 in 82 test files across
  broker, proxy, websocket, client, and compaction tests
- Update MockBrokerService HTTP handler to match V2 admin URLs
  (/admin/v2/persistent and /lookup/v2/topic/persistent)
- Fix test setup cluster references from "use" to "test" to
  match the broker's configured cluster name
- Add my-property/my-ns tenant+namespace creation in
  BrokerTestBase for tests that previously relied on V1
  implicit namespace resolution
- Add namespace creation in ManagedCursorMetricsTest and
  StrategicCompactionTest setups
- Fix ResendRequestTest and PerMessageUnAcknowledgedRedeliveryTest
  to call baseSetup() instead of internalSetup()
- Remove V1-specific test methods (namespacesCreateV1,
  namespacesCreateV1WithBundlesAndClusters)
- Remove V1-specific test assertions (non-local cluster topic
  rejection in ServerCnxTest, V1 managed ledger path listener
  in TopicResourcesTest)
- Update PulsarAdminToolTest createNamespace verifications to
  match V2 API call signature
…ckstyle

- Convert 4-part V1 topic names to 3-part V2 format in proxy tests,
  BrokerServiceLookupTest, and ConnectionPoolTest
- Fix V1 3-part namespace creation in ModularLoadManagerImplTest and
  AdminApiSchemaTest
- Remove V1-specific test methods from SchemaUpdateStrategyTest
- Remove duplicate tenant creation in ResendRequestTest
- Update V1 format references in comments and CLI parameter descriptions
- Fix checkstyle import order in StrategicCompactionTest and
  ManagedCursorMetricsTest
…pace

Use public/default namespace (created by setupDefaultTenantAndNamespace)
instead of sample/local which was never created by these tests.
- NamespaceIsolationPolicyImplTest: Change V1 3-part namespaces
  (pulsar/use/testns-1) to V2 format (pulsar/testns-1) in namespace
  regex patterns and NamespaceName.get() calls
- NamespaceIsolationPoliciesTest: Fix testBrokerAssignment to use a
  namespace that doesn't match the policy for the shared broker test,
  and fix case-sensitivity issue in testGetNamespaceIsolationPolicyByNamespace
Change /ws/consumer/ and /ws/producer/ (V1 4-part format with cluster)
to /ws/v2/consumer/ and /ws/v2/producer/ (V2 3-part format).
…Test

Replace getNamespaces("prop-xyz", "test") (V1 2-arg cluster-scoped API)
with getNamespaces("prop-xyz") (V2 tenant-scoped API).
- mockBundleName: change 3-part V1 format to 2-part V2 format
- testBrokerAffinity: remove cluster from namespace path
- testLoadSheddingWithNamespaceIsolationPolicies: remove cluster
  from namespace string
- testNamespaceIsolationPoliciesForPrimaryAndSecondaryBrokers: fix
  misaligned String.format args after template change from 3-part
  to 2-part namespace format
Remove V1 3-part namespace formats (tenant/cluster/namespace) and
V1 lookup URLs (/lookup/v2/destination/) from tests. Add missing
tenant/namespace creation and replication_clusters configuration
where V2 topic operations now require them.

Files fixed: AdminTest, NamespacesV2Test, PersistentTopicsTest,
TopicPoliciesTest, AntiAffinityNamespaceGroupExtensionTest,
HttpTopicLookupv2Test, PeerReplicatorTest, ReplicatorGlobalNSTest,
WebServiceTest.
@merlimat merlimat marked this pull request as draft March 10, 2026 05:50
merlimat added 13 commits March 10, 2026 12:23
Change topic names from V1 format (sample/local/*) to V2
(public/default/*) and add setupDefaultTenantAndNamespace() call.
…tem topic names

ProxyProtocolTest: Add internalSetUpForNamespace() call so the
my-property/my-ns namespace exists before producing.

CompactionRetentionTest: Use getLocalName() when constructing
system topic names to avoid concatenating full TopicName objects
with the topic prefix, which created malformed topic names.
Replace V1 topic namespace sample/local with public/default across
all proxy test classes and add setupDefaultTenantAndNamespace() to
ensure the namespace exists before tests run.
After V1 topic name removal, many tests used V1 3-part namespace
patterns (tenant/cluster/namespace) or referenced namespaces that
no longer exist. This fixes all remaining V1 namespace issues found
in CI test failures:

- BrokerBookieIsolationTest: Convert V1 namespace format to V2
- AntiAffinityNamespaceGroupTest: Remove cluster from namespace
- ModularLoadManagerImplTest: Fix cluster name for testBrokerAffinity
- HttpTopicLookupv2Test: Add cross-colo policies and peer clusters
- AdminTest: Remove pre-policy-creation assertions in resourceQuotas
- AdminApi2Test: Include "global" cluster in getClusters results
- NamespacesTest: Fix replication cluster expectations and redirects
- PrometheusMetricsTest: Sort metrics by topic for stable ordering
- WebServiceTest: Adjust rate limit counters for tenant/ns creation
- TlsProducerConsumerTest/TlsSniTest: Add namespace setup
- BrokerClientIntegrationTest: Fix namespace setup after broker restart
- TopicsConsumerImplTest: Add namespace creation for prop/ns-abc
- PerMessageUnAcknowledgedRedeliveryTest: Remove redundant tenant creation
- ZeroQueueSizeTest: Use prop/ns-abc (created by baseSetup)
- PulsarClientToolTest/WsTest: Fix V1 topic names and setup
- NamespacesImpl: Rename query param "property" to "tenant"
The subclass overrides setup() but was missing the
setupDefaultTenantAndNamespace() call that the parent class has.
TopicsConsumerImplTest: Remove redundant createCluster("test") calls
in testDefaultBacklogTTL and multiTopicsInDifferentNameSpace since the
cluster is already created by producerBaseSetup() in @BeforeMethod.

CompactionRetentionTest: Remove checks for TRANSACTION_COORDINATOR_ASSIGN
and TRANSACTION_COORDINATOR_LOG in testRetentionPolicesForSystemTopic.
These topics are only recognized as system topics in the pulsar/system
namespace (via startsWith check), not in user namespaces.
The setup() overrides added to call internalSetUpForNamespace()
were missing @BeforeMethod annotations. TestNG does not inherit
configuration annotations on overridden methods, so setup() was
never being called, leaving this.pulsar as null.
…ertion

The failover active consumer is selected via consistent hashing of the
topic name. With V1 removal, topic names changed from 4-part to 3-part
format, altering the hash and changing which consumer is selected as
active. Make the test dynamically detect the active vs standby consumer
instead of hardcoding the expectation.
The broker's internal PulsarClient (created lazily by
SystemTopicBasedTopicPoliciesService during namespace bundle ownership)
adds extra binary connections during test setup. Use >= assertions
for cumulative connection counts that include setup connections,
while keeping exact assertions for failure count and zero-value checks.
- Remove "global" from mocked clusters set (V1-specific)
- Remove test block for V1-specific "global not allowed in replication
  clusters" behavior
- Add peer cluster configuration for "usc" since NamespaceName.isGlobal()
  now always returns true, causing all namespaces to go through the
  peer-cluster redirect path in checkLocalOrGetPeerReplicationCluster
- Update deleteNamespace redirect URL expectation to include
  ?authoritative=false query param added by validateNamespacePoliciesAsync
After V1 removal, managed ledger names use the format
tenant/namespace/domain/topic. The parseNamespaceFromLedgerName
method captured the first 3 path components (tenant/namespace/domain)
as the namespace, which was correct for V1 format
(tenant/cluster/namespace/domain/topic) but incorrect for V2.

Fix by extracting only groups 2 and 3 (tenant/namespace) from the
regex, excluding the domain component.
@merlimat merlimat marked this pull request as ready for review March 10, 2026 19:55
After V1 removal, NamespaceName.isGlobal() always returns true, causing
checkLocalOrGetPeerReplicationCluster to run for all namespaces. The guard
at line 875 excluded heartbeat namespaces but not SLA namespaces, so SLA
namespace lookups failed with "Namespace not found" when no policies existed
in the metadata store.

Fix: use isSLAOrHeartbeatNamespace() to skip peer cluster validation for
both system namespace types.

Also fix DispatcherBlockConsumerTest.testBlockDispatcherStats which referenced
namespace prop/ns-abc that is not created by ProducerConsumerBase setup.
@codecov-commenter
Copy link

codecov-commenter commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 64.32432% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.69%. Comparing base (8798a46) to head (ed6315d).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...pache/pulsar/broker/admin/impl/NamespacesBase.java 34.21% 23 Missing and 2 partials ⚠️
...pache/pulsar/broker/resources/TenantResources.java 62.50% 11 Missing and 4 partials ⚠️
...g/apache/pulsar/broker/lookup/TopicLookupBase.java 66.66% 11 Missing and 2 partials ⚠️
.../org/apache/pulsar/broker/admin/AdminResource.java 75.00% 2 Missing ⚠️
...ache/pulsar/broker/namespace/ServiceUnitUtils.java 0.00% 2 Missing ⚠️
.../pulsar/client/admin/internal/BrokerStatsImpl.java 0.00% 2 Missing ⚠️
...ache/pulsar/client/admin/internal/BrokersImpl.java 33.33% 2 Missing ⚠️
...client/admin/internal/NonPersistentTopicsImpl.java 0.00% 2 Missing ⚠️
...che/pulsar/broker/admin/impl/TransactionsBase.java 50.00% 1 Missing ⚠️
...rg/apache/pulsar/broker/web/PulsarWebResource.java 50.00% 0 Missing and 1 partial ⚠️
... and 1 more
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##             master   #25304       +/-   ##
=============================================
+ Coverage     37.31%   72.69%   +35.37%     
- Complexity    13330    34204    +20874     
=============================================
  Files          1910     1954       +44     
  Lines        151980   154703     +2723     
  Branches      17303    17701      +398     
=============================================
+ Hits          56711   112454    +55743     
+ Misses        87546    33172    -54374     
- Partials       7723     9077     +1354     
Flag Coverage Δ
inttests 25.77% <28.64%> (+0.11%) ⬆️
systests 22.52% <20.54%> (+0.17%) ⬆️
unittests 73.67% <64.32%> (+39.61%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...org/apache/pulsar/broker/ServiceConfiguration.java 98.24% <ø> (+3.02%) ⬆️
...ker/authorization/PulsarAuthorizationProvider.java 68.81% <100.00%> (+60.37%) ⬆️
...he/pulsar/broker/resources/TopicResourcesTest.java 0.00% <ø> (ø)
.../org/apache/pulsar/PulsarClusterMetadataSetup.java 70.87% <ø> (+58.44%) ⬆️
...n/java/org/apache/pulsar/broker/PulsarService.java 82.60% <100.00%> (+15.35%) ⬆️
...g/apache/pulsar/broker/admin/impl/BrokersBase.java 88.03% <100.00%> (+52.63%) ⬆️
.../apache/pulsar/broker/admin/impl/ClustersBase.java 83.30% <100.00%> (+73.89%) ⬆️
...pulsar/broker/admin/impl/PersistentTopicsBase.java 68.86% <ø> (+57.38%) ⬆️
...e/pulsar/broker/admin/impl/ResourceQuotasBase.java 100.00% <ø> (+100.00%) ⬆️
...g/apache/pulsar/broker/admin/impl/TenantsBase.java 89.77% <100.00%> (+27.20%) ⬆️
... and 44 more

... and 1363 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

# Conflicts:
#	pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Namespaces.java
#	pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApi2Test.java
#	pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/NamespacesTest.java
#	pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/v1/V1AdminApi2Test.java
#	pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerTestBase.java
#	pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTestBase.java
#	pulsar-broker/src/test/java/org/apache/pulsar/client/api/NonPersistentTopicTest.java
#	pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/NamespacesImpl.java
#	pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java
#	pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java
#	tests/pulsar-client-admin-shade-test/src/test/java/org/apache/pulsar/tests/integration/SimpleProducerConsumerTest.java
#	tests/pulsar-client-all-shade-test/src/test/java/org/apache/pulsar/tests/integration/SimpleProducerConsumerTest.java
#	tests/pulsar-client-shade-test/src/test/java/org/apache/pulsar/tests/integration/SimpleProducerConsumerTest.java
Changed TopicName constructor to use limit(4) split and reject 4-part
paths (tenant/cluster/namespace/topic) instead of silently misinterpreting
them as V2 names. Also updated toFullTopicName() with the same check.

Removed support for slashes in V2 topic local names since V2 format
does not allow them. Updated websocket handler to no longer join
slash-separated URI path segments into topic names.
Restored the check that prevents removing clusters from a tenant's
allowed list when namespaces still reference those clusters. The
implementation is adapted for V2: instead of checking the V1 cluster
path hierarchy, it now lists all namespaces under the tenant and
checks their replication_clusters policy field.
Keep the existing namespace dimension format (tenant/namespace/domain)
to avoid breaking existing dashboards and alerts. The cleanup can be
done separately.
- AbstractWebSocketHandlerTest: remove slashes from test topic names
- BrokerBkEnsemblesTest: remove slashes from wildcard char topic name
- ResourceGroupUsageAggregationTest: fix topic name that was accidentally
  constructing a V1 4-part path (pulsar-test/test/test/topic)
- NamespacesTest: remove usw from namespace replication clusters before
  removing it from tenant allowed clusters, matching canUpdateCluster
  validation semantics
- AbstractWebSocketHandlerTest: remove slashes from test topic names
- BrokerBkEnsemblesTest: remove slashes from wildcard char topic name
- ResourceGroupUsageAggregationTest: fix topic name that was accidentally
  constructing a V1 4-part path (pulsar-test/test/test/topic)
- NamespacesTest: remove usw from namespace replication clusters before
  removing it from tenant allowed clusters, matching canUpdateCluster
  validation semantics
The V1 cluster-scoped namespace listing is no longer relevant.
Removed the method from Namespaces interface, NamespacesImpl,
the list-cluster CLI command, and the validatePropertyCluster helper.
Copy link
Member

@lhotari lhotari 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
Member

@shibd shibd left a comment

Choose a reason for hiding this comment

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

/LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-required Your PR changes impact docs and you will update later. ready-to-test release/important-notice The changes which are important should be mentioned in the release note type/cleanup Code or doc cleanups e.g. remove the outdated documentation or remove the code no longer in use

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants