Skip to content

Commit b0ce148

Browse files
committed
Fix sysctl rollback restart detection
Replace bare `incus start` with `_incus_soft` and add an explicit state check after rollback. The previous code relied on the exit code of `incus start`, which is unreliable when incus is in an inconsistent state. Now the function's return value reflects the actual container state by querying `incus list`.
1 parent 9cf26a7 commit b0ce148

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

incus/backend.func

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ _incus_restart_ct() {
5454
msg_warn "Container failed to start with current config — rolling back optional sysctls"
5555
_incus_soft incus config unset "${CT_NAME}" linux.sysctl.kernel.keys.maxkeys >>"$logf" 2>&1
5656
_incus_soft incus stop -f "${CT_NAME}" >>"$logf" 2>&1
57-
incus start "${CT_NAME}" >>"$logf" 2>&1
57+
_incus_soft incus start "${CT_NAME}" >>"$logf" 2>&1
58+
# A failed restart leaves incus disagreeing with itself - the same recovery
59+
# logged "already stopped" from stop and "already running" from start - so
60+
# the exit code proves nothing here. Ask what the state actually is.
61+
[[ "$(LC_ALL=C incus list "${CT_NAME}" -c s --format csv 2>/dev/null | head -1)" == "RUNNING" ]]
5862
}
5963

6064
_incus_resolve_launch_image() {

0 commit comments

Comments
 (0)