Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup for nomad bridge lo down issue #83

Merged
merged 1 commit into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions profiles/client.nix
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
'';
};
};
}