Skip to content

Return policy and op-policy-related fields plus delivery_limit when management stats are disabled (backport #15651)#15652

Merged
michaelklishin merged 4 commits intov4.2.xfrom
mergify/bp/v4.2.x/pr-15651
Mar 6, 2026
Merged

Return policy and op-policy-related fields plus delivery_limit when management stats are disabled (backport #15651)#15652
michaelklishin merged 4 commits intov4.2.xfrom
mergify/bp/v4.2.x/pr-15651

Conversation

@mergify
Copy link
Copy Markdown

@mergify mergify bot commented Mar 6, 2026

This is #15183 by @lukebakken with a few follow-up changes from me.

Closes #15182.


This is an automatic backport of pull request #15651 done by Mergify.

lukebakken and others added 2 commits March 6, 2026 04:59
When `management_agent.disable_metrics_collector` and
`management.disable_stats` are both set to `true`, the HTTP API returns
minimal queue information that excludes policy-related fields and
`delivery_limit`. This causes `policy`, `operator_policy`,
`effective_policy_definition`, and `delivery_limit` to be `null` in API
responses, even though these are configuration metadata rather than
statistics.

This change adds these four fields to the `format/2` function in both
`rabbit_classic_queue` and `rabbit_quorum_queue` modules. The fields now
appear in the type-specific formatting that runs regardless of metrics
collection status. The three policy fields use existing `i/2` function
implementations that call `rabbit_policy` module functions. For
`delivery_limit`, this change adds an `i(delivery_limit, Q)` function to
`rabbit_quorum_queue` that extracts the delivery limit from the queue's
`x-delivery-limit` argument, returning `unlimited` when not set.

Fixes #15182

(cherry picked from commit 7f4334b)
The changes in #15182 missed streams.

`stats_disabled_via_config` (a test group) unintentionally
overridden `disable_management_stats` due to how
the parameter merging works.

On top of that, add more tests and refactor
the implementation to be a bit more defensive
and consistent.

(cherry picked from commit a8fb664)
@mergify
Copy link
Copy Markdown
Author

mergify bot commented Mar 6, 2026

Cherry-pick of fa753a1 has failed:

On branch mergify/bp/v4.2.x/pr-15651
Your branch is ahead of 'origin/v4.2.x' by 2 commits.
  (use "git push" to publish your local commits)

You are currently cherry-picking commit fa753a12f.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   deps/rabbit/src/rabbit_classic_queue.erl
	modified:   deps/rabbit/src/rabbit_quorum_queue.erl
	modified:   deps/rabbit/src/rabbit_stream_queue.erl
	modified:   deps/rabbit_common/src/rabbit_json.erl
	modified:   deps/rabbitmq_management/src/rabbit_mgmt_db.erl
	modified:   deps/rabbitmq_management/src/rabbit_mgmt_oauth_bootstrap.erl
	modified:   deps/rabbitmq_management/src/rabbit_mgmt_util.erl
	modified:   deps/rabbitmq_management/src/rabbit_mgmt_wm_queue.erl
	modified:   deps/rabbitmq_management/src/rabbit_mgmt_wm_queues.erl
	modified:   deps/rabbitmq_management_agent/src/rabbit_mgmt_format.erl

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	deleted by us:   deps/rabbitmq_management/src/rabbit_mgmt_wm_user_queues.erl

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

…re enabled

`rabbit_queue_type:format/2` now conditionally emits policy fields only
when management stats are disabled: the stats augmentation
code path provides them.

1. `format/2` now conditionally emits policy fields
   based on whether the management plugin stats are enabled
2. `combine/2` acts as the next layer of protection
   against duplicate keys: it drops the `format/2`-originating
   keys that are duplicates
3. `prepare_for_encoding/1` is the new name for `format_nulls/1`
   that reflects its expanded scope: another deduplication pass

References #15182.

(cherry picked from commit fa753a1)

# Conflicts:
#	deps/rabbitmq_management/src/rabbit_mgmt_wm_user_queues.erl
(cherry picked from commit 1824d3f)
@michaelklishin michaelklishin force-pushed the mergify/bp/v4.2.x/pr-15651 branch from 2f41015 to 0017600 Compare March 6, 2026 05:59
@michaelklishin michaelklishin added this to the 4.2.5 milestone Mar 6, 2026
@michaelklishin michaelklishin merged commit c33ddde into v4.2.x Mar 6, 2026
296 checks passed
@michaelklishin michaelklishin deleted the mergify/bp/v4.2.x/pr-15651 branch March 6, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants