Merge #261: Fix netns restart
0972af55f1
netns: fix setup service restarts (Erik Arvstedt)63a464431b
netns: fail when netns already exists (Erik Arvstedt) Pull request description: ACKs for top commit: jonasnick: utACK0972af55f1
Tree-SHA512: 0923d26c144eb19a11ec4c1f0cd512bb7a70b12c9b73c787f4af476c95c91ea012ff593d2b59e1ccea34193c6995ba60783049c5086ab286b323460905ca62e7
This commit is contained in:
commit
75bbd4d4a6
@ -152,7 +152,6 @@ in {
|
||||
requiredBy = bindsTo;
|
||||
before = bindsTo;
|
||||
script = ''
|
||||
${ip} netns delete ${netnsName} 2> /dev/null || true
|
||||
${ip} netns add ${netnsName}
|
||||
${ipNetns} link set lo up
|
||||
${ip} link add ${veth} type veth peer name ${peer}
|
||||
@ -173,8 +172,13 @@ in {
|
||||
${netnsIptables} -w -A INPUT -s ${allowedAddresses} -j ACCEPT
|
||||
${netnsIptables} -w -A OUTPUT -d ${allowedAddresses} -j ACCEPT
|
||||
'';
|
||||
# Link deletion is implicit in netns deletion, but it sometimes only happens
|
||||
# after `netns delete` finishes. Add an extra `link del` to ensure that
|
||||
# the link is deleted before the service stops, which is needed for service
|
||||
# restart to succeed.
|
||||
preStop = ''
|
||||
${ip} netns delete ${netnsName}
|
||||
${ip} link del ${peer} 2> /dev/null || true
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
|
Loading…
Reference in New Issue
Block a user