Skip to content

Commit

Permalink
Do not expose map of different chain lengths to clients.
Browse files Browse the repository at this point in the history
Change-Id: I442bc24e8f4e1df2662e8ec00fda38fb84bac366
Reviewed-on: http://review.couchbase.org/106830
Reviewed-by: Aliaksey Artamonau <[email protected]>
Tested-by: Abhijeeth Nuthan <[email protected]>
  • Loading branch information
anuthan committed Apr 4, 2019
1 parent 3e79fa0 commit 5853f51
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/ns_bucket.erl
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,18 @@ json_map_from_config(LocalAddr, BucketConfig) ->
Config = ns_config:get(),
json_map_with_full_config(LocalAddr, BucketConfig, Config).

equal_len_chains([]) ->
[];
equal_len_chains(Map) ->
MaxChainLen = length(misc:min_by(fun (Chain, Max) ->
length(Chain) > length(Max)
end, Map)),
[Chain ++ lists:duplicate(MaxChainLen - length(Chain), undefined)
|| Chain <- Map].

json_map_with_full_config(LocalAddr, BucketConfig, Config) ->
NumReplicas = num_replicas(BucketConfig),
EMap = proplists:get_value(map, BucketConfig, []),
EMap = equal_len_chains(proplists:get_value(map, BucketConfig, [])),
BucketNodes = proplists:get_value(servers, BucketConfig, []),
ENodes = lists:delete(undefined, lists:usort(lists:append([BucketNodes |
EMap]))),
Expand Down

0 comments on commit 5853f51

Please sign in to comment.