Skip to content

Commit be7dd0e

Browse files
committed
MB-47585 Require minimum 256 MiB for magma buckets
Change-Id: I80abc92c4968a08dd6e8c121187289bdb419564c Reviewed-on: http://review.couchbase.org/c/ns_server/+/158747 Well-Formed: Build Bot <[email protected]> Reviewed-by: Artem Stemkovski <[email protected]> Tested-by: Build Bot <[email protected]> Tested-by: Steve Watanabe <[email protected]>
1 parent 8d98f72 commit be7dd0e

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

src/menelaus_web_buckets.erl

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
-include("ns_stats.hrl").
2020
-include("cut.hrl").
2121

22+
-define(MAGMA_MIN_RAMQUOTA, 256).
23+
2224
-ifdef(TEST).
2325
-include_lib("eunit/include/eunit.hrl").
2426
-endif.
@@ -771,13 +773,29 @@ additional_bucket_params_validation(Params, Ctx) ->
771773
NumReplicas = get_value_from_parms_or_bucket(num_replicas, Params, Ctx),
772774
DurabilityLevel = get_value_from_parms_or_bucket(durability_min_level,
773775
Params, Ctx),
774-
case {NumReplicas, DurabilityLevel} of
775-
{3, none} -> [];
776-
{3, _} -> [{durability_min_level,
777-
<<"Durability minimum level cannot be specified with "
778-
"3 replicas">>}];
779-
{_, _} -> []
780-
end.
776+
Err1 = case {NumReplicas, DurabilityLevel} of
777+
{3, none} -> [];
778+
{3, _} -> [{durability_min_level,
779+
<<"Durability minimum level cannot be specified with "
780+
"3 replicas">>}];
781+
{_, _} -> []
782+
end,
783+
784+
StorageMode = get_value_from_parms_or_bucket(storage_mode, Params, Ctx),
785+
RamQuota = get_value_from_parms_or_bucket(ram_quota, Params, Ctx),
786+
787+
Err2 = case {StorageMode, RamQuota} of
788+
{magma, RamQuota}
789+
when RamQuota < ?MAGMA_MIN_RAMQUOTA * 1024 * 1024 ->
790+
RamQ = list_to_binary(integer_to_list(?MAGMA_MIN_RAMQUOTA)),
791+
[{ramQuota,
792+
<<"Ram quota for magma must be at least ", RamQ/binary,
793+
" MiB">>}];
794+
{_, _} ->
795+
[]
796+
end,
797+
798+
Err1 ++ Err2.
781799

782800
%% Get the value from the params. If it wasn't specified and this isn't
783801
%% a bucket creation then get the existing value from the bucket config.

0 commit comments

Comments
 (0)