Skip to content

Commit

Permalink
consul.passthru.tests: Refactor: Extract variable
Browse files Browse the repository at this point in the history
  • Loading branch information
nh2 committed Jun 18, 2020
1 parent 777d1c0 commit 25d6656
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nixos/tests/consul.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ let

server = index: { pkgs, ... }:
let
numConsensusServers = builtins.length allConsensusServerHosts;
thisConsensusServerHost = builtins.elemAt allConsensusServerHosts index;
ip = thisConsensusServerHost; # since we already use IPs to identify servers
in
Expand All @@ -71,12 +72,12 @@ let
inherit webUi;
extraConfig = defaultExtraConfig // {
server = true;
bootstrap_expect = builtins.length allConsensusServerHosts;
bootstrap_expect = numConsensusServers;
retry_join =
# If there's only 1 node in the network, we allow self-join;
# otherwise, the node must not try to join itself, and join only the other servers.
# See https://github.com/hashicorp/consul/issues/2868
if builtins.length allConsensusServerHosts == 1
if numConsensusServers == 1
then allConsensusServerHosts
else builtins.filter (h: h != thisConsensusServerHost) allConsensusServerHosts;
bind_addr = ip;
Expand Down

0 comments on commit 25d6656

Please sign in to comment.