@@ -577,9 +577,17 @@ verify_oper({create_collection, ScopeName, Name, _}, Manifest) ->
577577 with_scope (
578578 fun (Scope ) ->
579579 Collections = get_collections (Scope ),
580+ Limit = get_limit (clusterManager , num_collections , Scope ),
580581 case find_collection (Name , Collections ) of
581582 undefined ->
582- ok ;
583+ case cluster_compat_mode :should_enforce_limits () andalso
584+ Limit =/= infinity andalso
585+ length (Collections ) > Limit of
586+ false ->
587+ ok ;
588+ true ->
589+ {max_number_exceeded , num_collections }
590+ end ;
583591 _ ->
584592 {collection_already_exists , ScopeName , Name }
585593 end
@@ -714,6 +722,13 @@ on_scopes(Fun, Manifest) ->
714722get_limits (Scope ) ->
715723 proplists :get_value (limits , Scope , []).
716724
725+ get_limit (Service , Limit , Scope ) ->
726+ functools :chain (
727+ Scope ,
728+ [proplists :get_value (limits , _ , []),
729+ proplists :get_value (Service , _ , []),
730+ proplists :get_value (Limit , _ , infinity )]).
731+
717732get_collections (Scope ) ->
718733 proplists :get_value (collections , Scope , []).
719734
0 commit comments