modules/microvm: add stopTuntap to nomad jobs
This commit is contained in:
parent
6abb188be6
commit
92f8103c6a
|
@ -96,6 +96,13 @@ in
|
||||||
ip tuntap add ${id} mode tap user microvm
|
ip tuntap add ${id} mode tap user microvm
|
||||||
fi
|
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
|
# change working directory before starting virtiofsd
|
||||||
runVirtiofsd = { tag, socket, source, ... }:
|
runVirtiofsd = { tag, socket, source, ... }:
|
||||||
pkgs.writeScript "virtiofsd-${hostName}-${tag}" ''
|
pkgs.writeScript "virtiofsd-${hostName}-${tag}" ''
|
||||||
|
@ -137,6 +144,16 @@ in
|
||||||
command = "${runTuntap interface}"
|
command = "${runTuntap interface}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
task "interface-${id}-stop" {
|
||||||
|
lifecycle {
|
||||||
|
hook = "poststop"
|
||||||
|
}
|
||||||
|
driver = "raw_exec"
|
||||||
|
user = "root"
|
||||||
|
config {
|
||||||
|
command = "${stopTuntap interface}"
|
||||||
|
}
|
||||||
|
}
|
||||||
'') config.microvm.interfaces}
|
'') config.microvm.interfaces}
|
||||||
|
|
||||||
${lib.concatMapStrings (share@{ tag, ... }: ''
|
${lib.concatMapStrings (share@{ tag, ... }: ''
|
||||||
|
|
Loading…
Reference in New Issue
Block a user