Skip to content

Add namespace-level inactive topic policies commands#2004

Open
nlu90 wants to merge 1 commit intomasterfrom
neng/namespace-inactive-topic-policies
Open

Add namespace-level inactive topic policies commands#2004
nlu90 wants to merge 1 commit intomasterfrom
neng/namespace-inactive-topic-policies

Conversation

@nlu90
Copy link
Contributor

@nlu90 nlu90 commented Feb 11, 2026

(If this PR fixes a github issue, please add Fixes #<xyz>.)

Fixes #

(or if this PR is one task of a github issue, please add Master Issue: #<xyz> to link to the master issue.)

Master Issue: #

Motivation

Pulsarctl currently supports inactive topic policies management only at the topic level (pkg/ctl/topic/), but not at the namespace level. This creates an inconsistency since the underlying pulsar-client-go admin SDK already provides full support for namespace-level inactive topic policies via the Namespaces interface. These commands are needed to expose that existing API functionality through the CLI.

Modifications

Add three new namespace commands mirroring the topic-level implementation:

  • get-inactive-topic-policies: Get inactive topic policies for a namespace
  • set-inactive-topic-policies: Set policies with --enable-delete-while-inactive,
    --max-inactive-duration (required), and --delete-mode (required) flags
  • remove-inactive-topic-policies: Remove policies from a namespace

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

Documentation

Check the box below.

Need to update docs?

  • doc-required

    (If you need help on updating docs, create a doc issue)

  • no-need-doc

    (Please explain why)

  • doc

    (If this PR contains doc changes)

@github-actions
Copy link

@nlu90:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@github-actions github-actions bot added the doc-info-missing This pr needs to mark a document option in description label Feb 11, 2026
@nlu90
Copy link
Contributor Author

nlu90 commented Feb 11, 2026

Tested with local cluster:

➜  pulsarctl git:(master) ✗ ./bin/pulsarctl context set local \
    --admin-service-url http://localhost:8080
Context "local" created.

➜  pulsarctl git:(master) ✗ ./bin/pulsarctl namespaces create public/test-ns
Created public/test-ns successfully

➜  pulsarctl git:(master) ✗ ./bin/pulsarctl namespaces get-inactive-topic-policies public/test-ns
{
  "inactiveTopicDeleteMode": null,
  "maxInactiveDurationSeconds": 0,
  "deleteWhileInactive": false
}

➜  pulsarctl git:(master) ✗ ./bin/pulsarctl namespaces set-inactive-topic-policies public/test-ns \
    --enable-delete-while-inactive \
    --max-inactive-duration 2h \
    --delete-mode delete_when_subscriptions_caught_up
Set inactive topic policies successfully for [public/test-ns]%          
                                                                                                                                                                                                                                           
➜  pulsarctl git:(master) ✗ ./bin/pulsarctl namespaces get-inactive-topic-policies public/test-ns
{
  "inactiveTopicDeleteMode": "delete_when_subscriptions_caught_up",
  "maxInactiveDurationSeconds": 7200,
  "deleteWhileInactive": true
}

➜  pulsarctl git:(master) ✗ ./bin/pulsarctl namespaces remove-inactive-topic-policies public/test-ns
Remove inactive topic policies successfully from [public/test-ns]%     
                                                                                                                                                                                                                                            
➜  pulsarctl git:(master) ✗ ./bin/pulsarctl namespaces get-inactive-topic-policies public/test-ns   
{
  "inactiveTopicDeleteMode": null,
  "maxInactiveDurationSeconds": 0,
  "deleteWhileInactive": false
}

Pulsar Broker Side log:

2026-02-11T10:44:28,586-0800 [pulsar-web-49-14] INFO  org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [11/Feb/2026:10:44:28 -0800] "GET /admin/v2/persistent/public/functions/coordinate/stats?getPreciseBacklog=false&subscriptionBacklogSize=false&getEarliestTimeInBacklog=false&excludePublishers=false&excludeConsumers=false HTTP/1.1" 200 1036 "-" "Pulsar-Java-v4.0.4" 17
2026-02-11T10:44:28,594-0800 [pulsar-web-49-12] INFO  org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [11/Feb/2026:10:44:28 -0800] "GET /admin/v2/persistent/public/functions/coordinate/stats?getPreciseBacklog=false&subscriptionBacklogSize=false&getEarliestTimeInBacklog=false&excludePublishers=false&excludeConsumers=false HTTP/1.1" 200 1036 "-" "Pulsar-Java-v4.0.4" 4
2026-02-11T10:44:47,083-0800 [metadata-store-1-1] INFO  org.apache.pulsar.broker.resourcegroup.ResourceGroupNamespaceConfigListener - Metadata store notification: Path /admin/policies/public/test-ns, Type Created
2026-02-11T10:44:47,084-0800 [pulsar-web-49-12] INFO  org.apache.pulsar.broker.admin.impl.NamespacesBase - [null] Created namespace public/test-ns
2026-02-11T10:44:47,085-0800 [pulsar-web-49-12] INFO  org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [11/Feb/2026:10:44:47 -0800] "PUT /admin/v2/namespaces/public/test-ns HTTP/1.1" 204 0 "-" "None" 30
2026-02-11T10:44:58,574-0800 [pulsar-web-49-12] INFO  org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [11/Feb/2026:10:44:58 -0800] "GET /admin/v2/persistent/public/functions/coordinate/stats?getPreciseBacklog=false&subscriptionBacklogSize=false&getEarliestTimeInBacklog=false&excludePublishers=false&excludeConsumers=false HTTP/1.1" 200 1036 "-" "Pulsar-Java-v4.0.4" 5
2026-02-11T10:44:58,580-0800 [pulsar-web-49-14] INFO  org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [11/Feb/2026:10:44:58 -0800] "GET /admin/v2/persistent/public/functions/coordinate/stats?getPreciseBacklog=false&subscriptionBacklogSize=false&getEarliestTimeInBacklog=false&excludePublishers=false&excludeConsumers=false HTTP/1.1" 200 1036 "-" "Pulsar-Java-v4.0.4" 3
2026-02-11T10:44:58,584-0800 [pulsar-web-49-12] INFO  org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [11/Feb/2026:10:44:58 -0800] "GET /admin/v2/persistent/public/functions/coordinate/stats?getPreciseBacklog=false&subscriptionBacklogSize=false&getEarliestTimeInBacklog=false&excludePublishers=false&excludeConsumers=false HTTP/1.1" 200 1036 "-" "Pulsar-Java-v4.0.4" 2
2026-02-11T10:45:28,576-0800 [pulsar-web-49-14] INFO  org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [11/Feb/2026:10:45:28 -0800] "GET /admin/v2/persistent/public/functions/coordinate/stats?getPreciseBacklog=false&subscriptionBacklogSize=false&getEarliestTimeInBacklog=false&excludePublishers=false&excludeConsumers=false HTTP/1.1" 200 1036 "-" "Pulsar-Java-v4.0.4" 10
2026-02-11T10:45:28,588-0800 [pulsar-web-49-12] INFO  org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [11/Feb/2026:10:45:28 -0800] "GET /admin/v2/persistent/public/functions/coordinate/stats?getPreciseBacklog=false&subscriptionBacklogSize=false&getEarliestTimeInBacklog=false&excludePublishers=false&excludeConsumers=false HTTP/1.1" 200 1036 "-" "Pulsar-Java-v4.0.4" 5
2026-02-11T10:45:31,449-0800 [pulsar-web-49-14] INFO  org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [11/Feb/2026:10:45:31 -0800] "GET /admin/v2/namespaces/public/test-ns/inactiveTopicPolicies HTTP/1.1" 200 0 "-" "None" 9
2026-02-11T10:45:44,966-0800 [metadata-store-1-1] INFO  org.apache.pulsar.broker.resourcegroup.ResourceGroupNamespaceConfigListener - Metadata store notification: Path /admin/policies/public/test-ns, Type Modified
2026-02-11T10:45:44,967-0800 [pulsar-17-1] INFO  org.apache.pulsar.broker.service.BrokerService - [public/test-ns] updating with Policies(auth_policies=AuthPoliciesImpl(namespaceAuthentication={}, topicAuthentication={}, subscriptionAuthentication={}), replication_clusters=[standalone], allowed_clusters=[], bundles=BundlesDataImpl(boundaries=[0x00000000, 0x40000000, 0x80000000, 0xc0000000, 0xffffffff], numBundles=4), backlog_quota_map={}, clusterDispatchRate={}, topicDispatchRate={}, subscriptionDispatchRate={}, replicatorDispatchRate={}, clusterSubscribeRate={}, persistence=null, deduplicationEnabled=null, autoTopicCreationOverride=null, autoSubscriptionCreationOverride=null, publishMaxMessageRate={}, latency_stats_sample_rate={}, message_ttl_in_seconds=null, subscription_expiration_time_minutes=null, retention_policies=null, deleted=false, encryption_required=false, delayed_delivery_policies=null, inactive_topic_policies=InactiveTopicPolicies(inactiveTopicDeleteMode=delete_when_subscriptions_caught_up, maxInactiveDurationSeconds=7200, deleteWhileInactive=true), subscription_auth_mode=None, max_producers_per_topic=null, max_consumers_per_topic=null, max_consumers_per_subscription=null, max_unacked_messages_per_consumer=null, max_unacked_messages_per_subscription=null, max_subscriptions_per_topic=null, compaction_threshold=null, offload_threshold=-1, offload_threshold_in_seconds=-1, offload_deletion_lag_ms=null, max_topics_per_namespace=null, schema_auto_update_compatibility_strategy=Full, schema_compatibility_strategy=UNDEFINED, is_allow_auto_update_schema=true, schema_validation_enforced=false, offload_policies=null, deduplicationSnapshotIntervalSeconds=null, subscription_types_enabled=[], properties={}, resource_group_name=null, migrated=false, dispatcherPauseOnAckStatePersistentEnabled=null, entryFilters=null)
2026-02-11T10:45:44,967-0800 [pulsar-web-49-12] INFO  org.apache.pulsar.broker.admin.impl.NamespacesBase - [null] Successfully updated inactive_topic_policies configuration: namespace=public/test-ns, value={"inactiveTopicDeleteMode":"delete_when_subscriptions_caught_up","maxInactiveDurationSeconds":7200,"deleteWhileInactive":true}
2026-02-11T10:45:44,971-0800 [pulsar-web-49-12] INFO  org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [11/Feb/2026:10:45:44 -0800] "POST /admin/v2/namespaces/public/test-ns/inactiveTopicPolicies HTTP/1.1" 204 0 "-" "None" 20
2026-02-11T10:45:56,619-0800 [pulsar-web-49-14] INFO  org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [11/Feb/2026:10:45:56 -0800] "GET /admin/v2/namespaces/public/test-ns/inactiveTopicPolicies HTTP/1.1" 200 125 "-" "None" 7
2026-02-11T10:45:58,563-0800 [pulsar-web-49-12] INFO  org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [11/Feb/2026:10:45:58 -0800] "GET /admin/v2/persistent/public/functions/coordinate/stats?getPreciseBacklog=false&subscriptionBacklogSize=false&getEarliestTimeInBacklog=false&excludePublishers=false&excludeConsumers=false HTTP/1.1" 200 1036 "-" "Pulsar-Java-v4.0.4" 3
2026-02-11T10:45:58,568-0800 [pulsar-web-49-14] INFO  org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [11/Feb/2026:10:45:58 -0800] "GET /admin/v2/persistent/public/functions/coordinate/stats?getPreciseBacklog=false&subscriptionBacklogSize=false&getEarliestTimeInBacklog=false&excludePublishers=false&excludeConsumers=false HTTP/1.1" 200 1036 "-" "Pulsar-Java-v4.0.4" 3
2026-02-11T10:45:58,571-0800 [pulsar-web-49-12] INFO  org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [11/Feb/2026:10:45:58 -0800] "GET /admin/v2/persistent/public/functions/coordinate/stats?getPreciseBacklog=false&subscriptionBacklogSize=false&getEarliestTimeInBacklog=false&excludePublishers=false&excludeConsumers=false HTTP/1.1" 200 1036 "-" "Pulsar-Java-v4.0.4" 1
2026-02-11T10:46:09,231-0800 [metadata-store-1-1] INFO  org.apache.pulsar.broker.resourcegroup.ResourceGroupNamespaceConfigListener - Metadata store notification: Path /admin/policies/public/test-ns, Type Modified
2026-02-11T10:46:09,232-0800 [pulsar-web-49-11] INFO  org.apache.pulsar.broker.admin.impl.NamespacesBase - [null] Successfully updated inactive_topic_policies configuration: namespace=public/test-ns, value=null
2026-02-11T10:46:09,233-0800 [pulsar-web-49-11] INFO  org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [11/Feb/2026:10:46:09 -0800] "DELETE /admin/v2/namespaces/public/test-ns/inactiveTopicPolicies HTTP/1.1" 204 0 "-" "None" 16
2026-02-11T10:46:09,232-0800 [pulsar-17-10] INFO  org.apache.pulsar.broker.service.BrokerService - [public/test-ns] updating with Policies(auth_policies=AuthPoliciesImpl(namespaceAuthentication={}, topicAuthentication={}, subscriptionAuthentication={}), replication_clusters=[standalone], allowed_clusters=[], bundles=BundlesDataImpl(boundaries=[0x00000000, 0x40000000, 0x80000000, 0xc0000000, 0xffffffff], numBundles=4), backlog_quota_map={}, clusterDispatchRate={}, topicDispatchRate={}, subscriptionDispatchRate={}, replicatorDispatchRate={}, clusterSubscribeRate={}, persistence=null, deduplicationEnabled=null, autoTopicCreationOverride=null, autoSubscriptionCreationOverride=null, publishMaxMessageRate={}, latency_stats_sample_rate={}, message_ttl_in_seconds=null, subscription_expiration_time_minutes=null, retention_policies=null, deleted=false, encryption_required=false, delayed_delivery_policies=null, inactive_topic_policies=null, subscription_auth_mode=None, max_producers_per_topic=null, max_consumers_per_topic=null, max_consumers_per_subscription=null, max_unacked_messages_per_consumer=null, max_unacked_messages_per_subscription=null, max_subscriptions_per_topic=null, compaction_threshold=null, offload_threshold=-1, offload_threshold_in_seconds=-1, offload_deletion_lag_ms=null, max_topics_per_namespace=null, schema_auto_update_compatibility_strategy=Full, schema_compatibility_strategy=UNDEFINED, is_allow_auto_update_schema=true, schema_validation_enforced=false, offload_policies=null, deduplicationSnapshotIntervalSeconds=null, subscription_types_enabled=[], properties={}, resource_group_name=null, migrated=false, dispatcherPauseOnAckStatePersistentEnabled=null, entryFilters=null)
2026-02-11T10:46:13,289-0800 [pulsar-web-49-14] INFO  org.eclipse.jetty.server.RequestLog - 127.0.0.1 - - [11/Feb/2026:10:46:13 -0800] "GET /admin/v2/namespaces/public/test-ns/inactiveTopicPolicies HTTP/1.1" 200 0 "-" "None" 3

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

Labels

doc-info-missing This pr needs to mark a document option in description

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant