Skip to content

Conversation

@zooo-code
Copy link

@zooo-code zooo-code commented Jan 17, 2026

Fixes #25128

Motivation

The logic for setting policies.bundles is different between getNamespacePolicies (sync) and getNamespacePoliciesAsync:

  • getNamespacePolicies (sync):

    • bundles source: NamespaceBundleFactory.getBundles().getBundlesData()
    • fallback: bundleData != null ? bundleData : policies.bundles
    • migrated fallback: false when LocalPolicies is absent
  • getNamespacePoliciesAsync:

    • bundles source: LocalPolicies.bundles
    • fallback: none (only sets if localPolicies.isPresent())
    • migrated fallback: none

This inconsistency can cause different results when calling sync vs async methods for the same namespace.

Modifications

Aligned getNamespacePoliciesAsync with the sync method by:

  • Using NamespaceBundleFactory.getBundlesAsync() instead of LocalPolicies.bundles
  • Applying the same fallback logic: bundleData != null ? bundleData : policies.bundles
  • Ensuring migrated field defaults to false when LocalPolicies is absent

Verifying this change

  • Make sure that the change passes the CI checks.

Added testGetNamespacePoliciesSyncAsyncBundlesConsistency test in AdminApiTest to verify that sync (getPolicies) and async (getPoliciesAsync) methods return consistent bundles data.

Existing tests only verify sync getPolicies().bundles behavior (e.g., AdminApiTest:816,822,3223, NamespacesTest:1266). There was no test that verifies async getPoliciesAsync returns the same bundles data as sync method. This new test explicitly validates the consistency between sync and async methods, which is the core fix of this PR.

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: https://github.com/zooo-code/pulsar

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jan 17, 2026
@zooo-code zooo-code force-pushed the fix-admin-namespace-policies-async branch from 6b586f1 to f4bd3f6 Compare January 17, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Logic for setting policies.bundle is different in AdminResource#getNamespacePolicies compared to AdminResource#getNamespacePoliciesAsync

1 participant