Skip to content

Commit

Permalink
Fixes nomad bridge lo down issue
Browse files Browse the repository at this point in the history
  • Loading branch information
johnalotoski committed Oct 14, 2021
1 parent e4366c6 commit e4324fb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions profiles/client.nix
Expand Up @@ -4,6 +4,7 @@
./consul/client.nix
./docker.nix
./nomad/client.nix
./nomad/bridge-lo-fixup.nix
./telegraf.nix
./vault/client.nix
./secrets.nix
Expand Down
36 changes: 36 additions & 0 deletions profiles/nomad/bridge-lo-fixup.nix
@@ -0,0 +1,36 @@
{ pkgs, config, lib, ... }:
{
# Workaround to address broken lo interface in Nomad created net namespaces
# https://github.com/hashicorp/nomad/issues/10014
systemd.services.monitor-exec-driver-lo = {
path = with pkgs; [ coreutils inotify-tools iproute2 gnugrep ];
wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" ];
serviceConfig = {
Type = "simple";
Restart = "on-failure";
RestartSec = "5s";
ExecStart = pkgs.writeBashChecked "monitor-exec-driver-lo" ''
set -euo pipefail
mkdir -p /var/run/netns
# Run upon detection of any create or modify network namespace changes
inotifywait -m -e create -e modify --format '%w%f' /var/run/netns | \
while read -r NS_CHANGED; do
NS="$(basename "$NS_CHANGED" /var/run/netns)"
echo "Namespace change detected: $NS_CHANGED"
echo "Namespace loopback state before fixup:"
ip netns exec "$NS" ip -br a | grep -E '^lo.*$' || :
# All Nomad namespaces should have an operational loopback interface
ip netns exec "$NS" ip link set lo up || :
echo "Namespace loopback state after fixup:"
ip netns exec "$NS" ip -br a | grep -E '^lo.*$' || :
done
'';
};
};
}

0 comments on commit e4324fb

Please sign in to comment.