Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Management UI: Fix internal_server_error args for put vhost failures #11585

Merged

Conversation

the-mikedavis
Copy link
Member

rabbit_mgmt_util:internal_server_error/4 expects an atom or binary and a string formattable term (~ts) as arguments but rabbit_mgmt_wm_vhost passes charlists and any term. This can cause a log formatter crash and an unexpected message in the management UI when attempting to add a vhost while a cluster is in a minority with Khepri enabled for example.

We can pass atoms for the Error parameter and binaries or strings for the Reason parameter to fix both issues.

`rabbit_mgmt_util:internal_server_error/4` expects an atom or binary
and a string formattable term (`~ts`) as arguments but
`rabbit_mgmt_wm_vhost` passes charlists and any term. This can cause
a log formatter crash and an unexpected message in the management UI
when attempting to add a vhost while a cluster is in a minority with
Khepri enabled for example.

We can pass atoms for the `Error` parameter and binaries or strings for
the `Reason` parameter to fix both issues.
@the-mikedavis
Copy link
Member Author

Steps to reproduce on main:

  • make start-cluster
  • rabbitmqctl enable_feature_flag -n rabbit-3 khepri_db
  • make stop-cluster NODES=2
  • Try to add a new vhost from /#/vhosts in the management UI
There is a log formatter crash...
2024-06-28T15:27:31.406820+00:00 error: FORMATTER CRASH: {"~ts~n~ts",["Timed out while waiting for the vhost to initialise",{error,timeout}]}
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>     formatter_crashed: rabbit_logger_text_fmt
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>     config: #{single_line => false,use_colors => false}
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>     log_event: #{meta =>
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>                      #{pid => <0.1292.0>,time => 1719588451406820,
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>                        gl => <0.688.0>,
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>                        domain => [rabbitmq]},
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>                  msg =>
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>                      {"~ts~n~ts",
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>                       ["Timed out while waiting for the vhost to initialise",
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>                        {error,timeout}]},
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>                  level => error}
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>     reason: {error,badarg,
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>                 [{io_lib,format,
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>                      ["~ts~n~ts",
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>                       ["Timed out while waiting for the vhost to initialise",
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>                        {error,timeout}]],
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>                      [{file,"io_lib.erl"},{line,189}]},
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>                  {rabbit_logger_text_fmt,format,2,
2024-06-28 15:27:31.408992+00:00 [debug] <0.1292.0>                      [{file,"rabbit_logger_text_fmt.erl"},{line,15}]}]}

and the UI shows Management API returned status code 500 - {"error":[84,105,109,101,100,32,111,117,116,32,119,104,105,108,101,32,119,97,105,116,105,110,103,32,102,111,114,32,116,104,101,32,118,104,111,115,116,32,116,111,32,105,110,105,116,105,97,108,105,115,101],"reason":["error","timeout"]} in the error display.

@the-mikedavis the-mikedavis marked this pull request as ready for review June 28, 2024 18:17
@michaelklishin michaelklishin merged commit e25e927 into main Jul 1, 2024
251 checks passed
@michaelklishin michaelklishin deleted the md/management/fix-error-message-from-vhost-timeout branch July 1, 2024 04:23
michaelklishin added a commit that referenced this pull request Jul 1, 2024
Management UI: Fix internal_server_error args for put vhost failures (backport #11585)
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