From ddfa1838374f8b23013950cf187a4bb2d41f473c Mon Sep 17 00:00:00 2001 From: Marcial Rosales Date: Wed, 12 Feb 2025 16:55:31 +0100 Subject: [PATCH 1/2] Add clear cache command (cherry picked from commit b0a9f145e139924b4c94777d50775797901191a3) (cherry picked from commit 3ab7a1abe0b54291d246f0860cd10aeca90155ba) --- deps/rabbitmq_auth_backend_cache/Makefile | 2 + ...CLI.Ctl.Commands.AuthClearCacheCommand.erl | 83 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 deps/rabbitmq_auth_backend_cache/src/Elixir.RabbitMQ.CLI.Ctl.Commands.AuthClearCacheCommand.erl diff --git a/deps/rabbitmq_auth_backend_cache/Makefile b/deps/rabbitmq_auth_backend_cache/Makefile index 4a91fb69bb56..6a16429ed53d 100644 --- a/deps/rabbitmq_auth_backend_cache/Makefile +++ b/deps/rabbitmq_auth_backend_cache/Makefile @@ -19,6 +19,8 @@ endef DEPS = rabbit_common rabbit TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers +PLT_APPS += rabbitmqctl + DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk diff --git a/deps/rabbitmq_auth_backend_cache/src/Elixir.RabbitMQ.CLI.Ctl.Commands.AuthClearCacheCommand.erl b/deps/rabbitmq_auth_backend_cache/src/Elixir.RabbitMQ.CLI.Ctl.Commands.AuthClearCacheCommand.erl new file mode 100644 index 000000000000..00888b848632 --- /dev/null +++ b/deps/rabbitmq_auth_backend_cache/src/Elixir.RabbitMQ.CLI.Ctl.Commands.AuthClearCacheCommand.erl @@ -0,0 +1,83 @@ +%% This Source Code Form is subject to the terms of the Mozilla Public +%% License, v. 2.0. If a copy of the MPL was not distributed with this +%% file, You can obtain one at https://mozilla.org/MPL/2.0/. +%% +%% Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved. +%% + +-module('Elixir.RabbitMQ.CLI.Ctl.Commands.AuthClearCacheCommand'). + +-behaviour('Elixir.RabbitMQ.CLI.CommandBehaviour'). + +-export([ + usage/0, + usage_additional/0, + usage_doc_guides/0, + flags/0, + validate/2, + merge_defaults/2, + banner/2, + run/2, + switches/0, + aliases/0, + output/2, + scopes/0, + formatter/0, + help_section/0, + description/0 + ]). + + +%%---------------------------------------------------------------------------- +%% Callbacks +%%---------------------------------------------------------------------------- +scopes() -> + [vmware, ctl]. + +switches() -> + []. + +usage() -> + <<"auth_clear_cache">>. + +usage_additional() -> + []. + +usage_doc_guides() -> + []. + +help_section() -> + {plugin, rabbitmq_auth_backend_cache}. + +description() -> + <<"Clear cache of authorization decisions">>. + +flags() -> + []. + +validate(_, _) -> + ok. + +formatter() -> + 'Elixir.RabbitMQ.CLI.Formatters.Table'. + +merge_defaults(A, O) -> + {A, O}. + +banner(_, _) -> + erlang:iolist_to_binary([<<"Will delete all cached authorization decisions">>]). + +run(_Args, #{node := Node}) -> + case rabbit_misc:rpc_call(Node, rabbit_auth_backend_cache, clear_cache_cluster_wide, []) of + {badrpc, _} = Error -> + Error; + Deleted -> + Deleted + end. + +aliases() -> + []. + +output(Value, _Opts) -> + 'Elixir.RabbitMQ.CLI.DefaultOutput':output(Value). + \ No newline at end of file From 95966b91f878bfcbef83aeec5df61b5c8a80a1f9 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Wed, 12 Feb 2025 14:26:30 -0500 Subject: [PATCH 2/2] 'ctl auth_clear_cache' => 'ctl clear_auth_backend_cache' (cherry picked from commit dae4967bf1e44a263c3534a5620d904e56831b61) (cherry picked from commit 96fed406c43338572fa20bb7003dd442bb5b0b3a) --- ...tMQ.CLI.Ctl.Commands.ClearAuthBackendCacheCommand.erl} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename deps/rabbitmq_auth_backend_cache/src/{Elixir.RabbitMQ.CLI.Ctl.Commands.AuthClearCacheCommand.erl => Elixir.RabbitMQ.CLI.Ctl.Commands.ClearAuthBackendCacheCommand.erl} (85%) diff --git a/deps/rabbitmq_auth_backend_cache/src/Elixir.RabbitMQ.CLI.Ctl.Commands.AuthClearCacheCommand.erl b/deps/rabbitmq_auth_backend_cache/src/Elixir.RabbitMQ.CLI.Ctl.Commands.ClearAuthBackendCacheCommand.erl similarity index 85% rename from deps/rabbitmq_auth_backend_cache/src/Elixir.RabbitMQ.CLI.Ctl.Commands.AuthClearCacheCommand.erl rename to deps/rabbitmq_auth_backend_cache/src/Elixir.RabbitMQ.CLI.Ctl.Commands.ClearAuthBackendCacheCommand.erl index 00888b848632..2cfe0106e26f 100644 --- a/deps/rabbitmq_auth_backend_cache/src/Elixir.RabbitMQ.CLI.Ctl.Commands.AuthClearCacheCommand.erl +++ b/deps/rabbitmq_auth_backend_cache/src/Elixir.RabbitMQ.CLI.Ctl.Commands.ClearAuthBackendCacheCommand.erl @@ -5,7 +5,7 @@ %% Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved. %% --module('Elixir.RabbitMQ.CLI.Ctl.Commands.AuthClearCacheCommand'). +-module('Elixir.RabbitMQ.CLI.Ctl.Commands.ClearAuthBackendCacheCommand'). -behaviour('Elixir.RabbitMQ.CLI.CommandBehaviour'). @@ -38,7 +38,7 @@ switches() -> []. usage() -> - <<"auth_clear_cache">>. + <<"clear_auth_backend_cache">>. usage_additional() -> []. @@ -50,7 +50,7 @@ help_section() -> {plugin, rabbitmq_auth_backend_cache}. description() -> - <<"Clear cache of authorization decisions">>. + <<"Clears rabbitmq_auth_backend_cache plugin's cache on the target node">>. flags() -> []. @@ -65,7 +65,7 @@ merge_defaults(A, O) -> {A, O}. banner(_, _) -> - erlang:iolist_to_binary([<<"Will delete all cached authorization decisions">>]). + <<"Will clear rabbitmq_auth_backend_cache plugin's cache on the target node...">>. run(_Args, #{node := Node}) -> case rabbit_misc:rpc_call(Node, rabbit_auth_backend_cache, clear_cache_cluster_wide, []) of