fanatic enable-fan does not clean up config after failed bringup
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ubuntu-fan (Ubuntu) |
Fix Released
|
Medium
|
Stefan Bader | ||
Xenial |
Fix Released
|
Undecided
|
Unassigned | ||
Zesty |
Fix Released
|
Undecided
|
Unassigned | ||
Artful |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
SRU Justification (for Artful/
Impact:
"fanatic enable-fan" calls to fanctl to actually bring up the Fan bridge. However it is possible that this returns with an error and in that case fanatic must undo previously done configuration changes or otherwise any following attempt to run enable-fan will incorrectly believe the bridge is up and do nothing.
Fix:
Adding a remove config stage if the call to fanctl returns with an error.
Testcase:
[fan is installed but not enabled]
- sudo flock -x /run/xtables.lock sleep 300
- fanatic enable-fan -u 192.168.0.0/16 -o 250.0.0.0/8; echo $?
Note: It seems in Artful, the default for iptables is to wait until the lock is released (without -w) so the test here won't work without adding -w to all iptables calls in fanctl. :/
Regression potential:
Cleanup called only on failure and the used function is also used in fanatic disable-fan. -> Low
diff --git a/fanatic b/fanatic fan_config add "$device" "$overlay" "$underlay"
index 8366881..5a83ad1 100755
--- a/fanatic
+++ b/fanatic
@@ -142,7 +142,11 @@ enable_fan()
# fi
progress "configuring fan underlay:$underlay overlay:$overlay"
twiddle_
- fanctl up -o "$overlay" -u "$underlay" --auto || fail "unable to bring fan up, unable to configure"
+ if ! fanctl up -o "$overlay" -u "$underlay" --auto; then
+ twiddle_fan_config remove "$device" "$overlay" \
+ "$underlay"
+ fail "unable to bring fan up, unable to configure"
+ fi
fi
}