Skip to content

Commit 7335aaa

Browse files
Merge pull request #11528 from rabbitmq/mk-fix-virtual-host-creation-post-11457
Follow-up to #11457
2 parents 4b4c0fe + 1e577a8 commit 7335aaa

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

deps/rabbit/src/rabbit_amqqueue.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,8 @@ check_queue_type(Val, _Args) when is_binary(Val) ->
11001100
true -> ok;
11011101
false -> {error, rabbit_misc:format("unsupported queue type '~ts'", [Val])}
11021102
end;
1103+
check_queue_type(Val, Args) when is_atom(Val) ->
1104+
check_queue_type(rabbit_data_coercion:to_binary(Val), Args);
11031105
check_queue_type(_Val, _Args) ->
11041106
{error, invalid_queue_type}.
11051107

deps/rabbit/src/rabbit_queue_type.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ discover(<<"classic">>) ->
260260
rabbit_classic_queue;
261261
discover(<<"stream">>) ->
262262
rabbit_stream_queue;
263+
discover(Other) when is_atom(Other) ->
264+
discover(rabbit_data_coercion:to_binary(Other));
263265
discover(Other) when is_binary(Other) ->
264266
T = rabbit_registry:binary_to_type(Other),
265267
{ok, Mod} = rabbit_registry:lookup_module(queue, T),

deps/rabbit/src/rabbit_vhost.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ do_add(Name, Metadata, ActingUser) ->
167167
case Metadata of
168168
#{default_queue_type := DQT} ->
169169
%% check that the queue type is known
170+
rabbit_log:debug("Default queue type of virtual host '~ts' is ~tp", [Name, DQT]),
170171
try rabbit_queue_type:discover(DQT) of
171172
_ ->
172173
case rabbit_queue_type:feature_flag_name(DQT) of
@@ -178,7 +179,7 @@ do_add(Name, Metadata, ActingUser) ->
178179
end
179180
end
180181
catch _:_ ->
181-
throw({error, invalid_queue_type})
182+
throw({error, invalid_queue_type, DQT})
182183
end;
183184
_ ->
184185
ok
@@ -301,17 +302,16 @@ delete(VHost, ActingUser) ->
301302
boolean(),
302303
rabbit_types:username()) ->
303304
'ok' | {'error', any()} | {'EXIT', any()}.
304-
put_vhost(Name, Description, Tags0, DefaultQueueType0, Trace, Username) ->
305+
put_vhost(Name, Description, Tags0, DefaultQueueType, Trace, Username) ->
305306
Tags = case Tags0 of
306307
undefined -> <<"">>;
307308
null -> <<"">>;
308309
"undefined" -> <<"">>;
309310
"null" -> <<"">>;
310311
Other -> Other
311312
end,
312-
DefaultQueueType = rabbit_data_coercion:to_atom(DefaultQueueType0),
313313
ParsedTags = parse_tags(Tags),
314-
rabbit_log:debug("Parsed tags ~tp to ~tp", [Tags, ParsedTags]),
314+
rabbit_log:debug("Parsed virtual host tags ~tp to ~tp", [Tags, ParsedTags]),
315315
Result = case exists(Name) of
316316
true ->
317317
update(Name, Description, ParsedTags, DefaultQueueType, Username);

deps/rabbit/test/definition_import_SUITE.erl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,9 @@ import_case11(Config) -> import_file_case(Config, "case11").
210210
import_case12(Config) -> import_invalid_file_case(Config, "failing_case12").
211211

212212
import_case13(Config) ->
213-
import_file_case(Config, "case13"),
214213
VHost = <<"/">>,
214+
delete_vhost(Config, VHost),
215+
import_file_case(Config, "case13"),
215216
QueueName = <<"definitions.import.case13.qq.1">>,
216217
QueueIsImported =
217218
fun () ->
@@ -230,8 +231,9 @@ import_case13(Config) ->
230231
amqqueue:get_arguments(Q)).
231232

232233
import_case13a(Config) ->
233-
import_file_case(Config, "case13"),
234234
VHost = <<"/">>,
235+
delete_vhost(Config, VHost),
236+
import_file_case(Config, "case13"),
235237
QueueName = <<"definitions.import.case13.qq.1">>,
236238
QueueIsImported =
237239
fun () ->
@@ -253,8 +255,9 @@ import_case14(Config) -> import_file_case(Config, "case14").
253255
import_case15(Config) -> import_file_case(Config, "case15").
254256
%% contains a virtual host with tags
255257
import_case16(Config) ->
256-
import_file_case(Config, "case16"),
257258
VHost = <<"tagged">>,
259+
delete_vhost(Config, VHost),
260+
import_file_case(Config, "case16"),
258261
VHostIsImported =
259262
fun () ->
260263
case vhost_lookup(Config, VHost) of
@@ -493,3 +496,6 @@ vhost_lookup(Config, VHost) ->
493496

494497
user_lookup(Config, User) ->
495498
rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_auth_backend_internal, lookup_user, [User]).
499+
500+
delete_vhost(Config, VHost) ->
501+
rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_vhost, delete, [VHost, <<"CT tests">>]).

0 commit comments

Comments
 (0)