modules/microvm: add stopTuntap to nomad jobs

This commit is contained in:
Astro 2022-07-13 22:44:28 +02:00
parent 6abb188be6
commit 92f8103c6a
1 changed files with 17 additions and 0 deletions

View File

@ -96,6 +96,13 @@ in
ip tuntap add ${id} mode tap user microvm
fi
'';
stopTuntap = { id, ... }:
pkgs.writeScript "tuntap-${hostName}-${id}" ''
#!${pkgs.runtimeShell} -e
if [ -d /sys/class/net/${id} ]; then
ip tuntap del ${id} mode tap
fi
'';
# change working directory before starting virtiofsd
runVirtiofsd = { tag, socket, source, ... }:
pkgs.writeScript "virtiofsd-${hostName}-${tag}" ''
@ -137,6 +144,16 @@ in
command = "${runTuntap interface}"
}
}
task "interface-${id}-stop" {
lifecycle {
hook = "poststop"
}
driver = "raw_exec"
user = "root"
config {
command = "${stopTuntap interface}"
}
}
'') config.microvm.interfaces}
${lib.concatMapStrings (share@{ tag, ... }: ''