-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4366c6
commit 1f6dcba
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
''; | ||
}; | ||
}; | ||
} |