diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/enable_feature_flag_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/enable_feature_flag_command.ex
index d4405f322891..76bbfd466b39 100644
--- a/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/enable_feature_flag_command.ex
+++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/enable_feature_flag_command.ex
@@ -7,54 +7,68 @@
defmodule RabbitMQ.CLI.Ctl.Commands.EnableFeatureFlagCommand do
@behaviour RabbitMQ.CLI.CommandBehaviour
- def merge_defaults(args, opts), do: {args, opts}
+ def switches(), do: [experimental: :boolean]
+ def aliases(), do: [e: :experimental]
- def validate([], _), do: {:validation_failure, :not_enough_args}
- def validate([_ | _] = args, _) when length(args) > 1, do: {:validation_failure, :too_many_args}
+ def merge_defaults(args, opts), do: { args, Map.merge(%{experimental: false}, opts) }
- def validate([""], _),
+ def validate([], _opts), do: {:validation_failure, :not_enough_args}
+ def validate([_ | _] = args, _opts) when length(args) > 1, do: {:validation_failure, :too_many_args}
+
+ def validate([""], _opts),
do: {:validation_failure, {:bad_argument, "feature_flag cannot be an empty string."}}
- def validate([_], _), do: :ok
+ def validate([_], _opts), do: :ok
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
- def run(["all"], %{node: node_name}) do
- case :rabbit_misc.rpc_call(node_name, :rabbit_feature_flags, :enable_all, []) do
- # Server does not support feature flags, consider none are available.
- # See rabbitmq/rabbitmq-cli#344 for context. MK.
- {:badrpc, {:EXIT, {:undef, _}}} -> {:error, :unsupported}
- {:badrpc, _} = err -> err
- other -> other
+ def run(["all"], %{node: node_name, experimental: experimental}) do
+ case experimental do
+ true ->
+ {:error, RabbitMQ.CLI.Core.ExitCodes.exit_usage(), "`--experiemntal` flag is not allowed when enabling all feature flags.\nUse --experimental with a specific feature flag if you want to enable an experimental feature."}
+ false ->
+ case :rabbit_misc.rpc_call(node_name, :rabbit_feature_flags, :enable_all, []) do
+ {:badrpc, _} = err -> err
+ other -> other
+ end
end
end
- def run([feature_flag], %{node: node_name}) do
- case :rabbit_misc.rpc_call(node_name, :rabbit_feature_flags, :enable, [
- String.to_atom(feature_flag)
- ]) do
- # Server does not support feature flags, consider none are available.
- # See rabbitmq/rabbitmq-cli#344 for context. MK.
- {:badrpc, {:EXIT, {:undef, _}}} -> {:error, :unsupported}
- {:badrpc, _} = err -> err
- other -> other
+ def run([feature_flag], %{node: node_name, experimental: experimental}) do
+ case {experimental, :rabbit_misc.rpc_call(node_name, :rabbit_feature_flags, :get_stability, [
+ String.to_atom(feature_flag)
+ ])} do
+ {_, {:badrpc, _} = err} -> err
+ {false, :experimental} ->
+ IO.puts("Feature flag #{feature_flag} is experimental. If you understand the risk, use --experimental to enable it.")
+ _ ->
+ case :rabbit_misc.rpc_call(node_name, :rabbit_feature_flags, :enable, [
+ String.to_atom(feature_flag)
+ ]) do
+ {:badrpc, _} = err -> err
+ other -> other
+ end
end
end
def output({:error, :unsupported}, %{node: node_name}) do
{:error, RabbitMQ.CLI.Core.ExitCodes.exit_usage(),
- "This feature flag is not supported by node #{node_name}"}
+ "This feature flag is not supported by node #{node_name}"}
end
use RabbitMQ.CLI.DefaultOutput
- def usage, do: "enable_feature_flag
+ Feature flags listed below are experimental. They should not be enabled in a production deployment. +
+| <%= fmt_sort('Name', 'name') %> | +<%= fmt_sort('State', 'state') %> | +Description | +
|---|---|---|
| <%= fmt_string(feature_flag.name) %> | +
+ <% if (feature_flag.state == "disabled") { %>
+
+
+
+
+ <% } else { %>
+
+ <%= fmt_string(feature_flag.state) %>
+
+ <% } %>
+ + + |
+
+ <%= fmt_string(feature_flag.desc) %> + <% if (feature_flag.doc_url) { %> + + <% } %> + |
+
... no feature_flags ...
+<% } %> +