Skip to content

Commit d57a1c2

Browse files
committed
rabbit.schema: Add config options for per-queue-type disk limits
1 parent 3da73a7 commit d57a1c2

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

deps/rabbit/priv/schema/rabbit.schema

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,69 @@ fun(Conf) ->
12381238
end
12391239
end}.
12401240

1241+
%% Per-queue-type / per-mount-point disk alarms
1242+
{mapping, "disk_free_limits.$id.mount_point", "rabbit.disk_free_limits", [
1243+
{datatype, [string]}
1244+
]}.
1245+
{mapping, "disk_free_limits.$id.absolute", "rabbit.disk_free_limits", [
1246+
{datatype, [integer, string]},
1247+
{validators, ["is_supported_information_unit"]}
1248+
]}.
1249+
{mapping, "disk_free_limits.$id.queue_types", "rabbit.disk_free_limits", [
1250+
{datatype, [binary]}
1251+
]}.
1252+
1253+
{translation, "rabbit.disk_free_limits",
1254+
fun(Conf) ->
1255+
case cuttlefish_variable:filter_by_prefix("disk_free_limits", Conf) of
1256+
[] ->
1257+
cuttlefish:unset();
1258+
Settings ->
1259+
lists:foldl(
1260+
fun ({["disk_free_limits", Id, "mount_point"], Path}, Acc) ->
1261+
maps:update_with(
1262+
list_to_binary(Id),
1263+
fun ({undefined, Limit, QTs}) ->
1264+
{Path, Limit, QTs};
1265+
({ExistingPath, Limit, QTs}) ->
1266+
cuttlefish:warn(
1267+
"Duplicate mount point set for ~ts, using "
1268+
"'~ts' instead of '~ts'",
1269+
[Id, Path, ExistingPath]),
1270+
{Path, Limit, QTs}
1271+
end, {Path, undefined, []}, Acc);
1272+
({["disk_free_limits", Id, "absolute"], Limit}, Acc) ->
1273+
maps:update_with(
1274+
list_to_binary(Id),
1275+
fun ({Path, undefined, QTypes}) ->
1276+
{Path, Limit, QTypes};
1277+
({Path, ExistingLimit, QTypes}) ->
1278+
cuttlefish:warn(
1279+
"Duplicate disk free limits set for ~ts, "
1280+
"using ~tp instead of ~tp",
1281+
[Id, Limit, ExistingLimit]),
1282+
{Path, Limit, QTypes}
1283+
end, {undefined, Limit, []}, Acc);
1284+
({["disk_free_limits", Id, "queue_types"], QTs0}, Acc) ->
1285+
QTs = string:split(QTs0, ","),
1286+
maps:update_with(
1287+
list_to_binary(Id),
1288+
fun ({Path, Limit, []}) ->
1289+
{Path, Limit, QTs};
1290+
({Path, Limit, ExistingQTs}) ->
1291+
cuttlefish:warn("Duplicate queue types set "
1292+
"for disk free limit of ~ts, "
1293+
"using ~tp instead of ~tp",
1294+
[Id, QTs, ExistingQTs]),
1295+
{Path, Limit, QTs}
1296+
end, {undefined, undefined, QTs}, Acc);
1297+
(Other, _Acc) ->
1298+
cuttlefish:invalid(
1299+
io_lib:format("~p is invalid", [Other]))
1300+
end, #{}, Settings)
1301+
end
1302+
end}.
1303+
12411304
%%
12421305
%% Clustering
12431306
%% =====================

deps/rabbit/test/config_schema_SUITE_data/rabbit.snippets

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,14 @@ tcp_listen_options.exit_on_close = false",
467467
"total_memory_available_override_value = 1024MB",
468468
[{rabbit,[{total_memory_available_override_value, "1024MB"}]}],
469469
[]},
470+
{disk_free_limits_per_mount_point,
471+
"disk_free_limits.replicated.mount_point = /data/replicated
472+
disk_free_limits.replicated.absolute = 2GB
473+
disk_free_limits.replicated.queue_types = stream,quorum",
474+
[{rabbit,[{disk_free_limits,
475+
#{<<"replicated">> => {"/data/replicated", "2GB",
476+
[<<"stream">>, <<"quorum">>]}}}]}],
477+
[]},
470478
{ranch_connection_max,
471479
"ranch_connection_max = 999",
472480
[{rabbit,[{ranch_connection_max, 999}]}],

0 commit comments

Comments
 (0)