Skip to content

Commit e7edae3

Browse files
the-mikedavismergify[bot]
authored andcommitted
rabbit_definitions: Handle vhost creation failure
`rabbit_definitions:concurrent_for_all/4` doesn't pay any attention to the return value of the `Fun`, only counting an error when it catches `{error, E}`. So we need to `throw/1` the error from `rabbit_vhost:put_vhost/6`. The other callers of `rabbit_vhost:put_vhost/6` - the management UI and the CLI (indirectly through `rabbit_vhost:add/2,3`) already handle this error return. (cherry picked from commit 63b5100)
1 parent af50d63 commit e7edae3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

deps/rabbit/src/rabbit_definitions.erl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ add_policy(VHost, Param, Username) ->
773773
exit(rabbit_data_coercion:to_binary(rabbit_misc:escape_html_tags(E ++ S)))
774774
end.
775775

776-
-spec add_vhost(map(), rabbit_types:username()) -> ok.
776+
-spec add_vhost(map(), rabbit_types:username()) -> ok | no_return().
777777

778778
add_vhost(VHost, ActingUser) ->
779779
Name = maps:get(name, VHost, undefined),
@@ -783,7 +783,12 @@ add_vhost(VHost, ActingUser) ->
783783
Tags = maps:get(tags, VHost, maps:get(tags, Metadata, [])),
784784
DefaultQueueType = maps:get(default_queue_type, Metadata, undefined),
785785

786-
rabbit_vhost:put_vhost(Name, Description, Tags, DefaultQueueType, IsTracingEnabled, ActingUser).
786+
case rabbit_vhost:put_vhost(Name, Description, Tags, DefaultQueueType, IsTracingEnabled, ActingUser) of
787+
ok ->
788+
ok;
789+
{error, _} = Err ->
790+
throw(Err)
791+
end.
787792

788793
add_permission(Permission, ActingUser) ->
789794
rabbit_auth_backend_internal:set_permissions(maps:get(user, Permission, undefined),

0 commit comments

Comments
 (0)