Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container: Match container disconnection with VMs #14075

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lxd/instance/drivers/driver_lxc_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func (c *lxcCmd) Wait() (int, error) {
err = ErrExecCommandNotFound
case 126:
err = ErrExecCommandNotExecutable
case 129, 137, 143:
// Container disconnections can result in different exit codes depending
// on what signal was used internally.
// 129 for SIGHUP, 137 for SIGKILL and 143 for SIGTERM are all possible.
err = ErrExecDisconnected
}

return exitStatus, err
Expand Down
10 changes: 10 additions & 0 deletions test/suites/exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,15 @@ test_exec_exit_code() {
lxc exec x1 -- invalid-command || exitCode=$?
[ "${exitCode:-0}" -eq 127 ]

# Try disconnecting a container stopping forcefully and gracefully to make sure they match.
(sleep 1 && lxc restart -f x1) &
lxc exec x1 -- sleep 10 || exitCode=$?
[ "${exitCode:-0}" -eq 129 ]

wait $!
(sleep 1 && lxc stop x1) &
lxc exec x1 -- sleep 10 || exitCode=$?
[ "${exitCode:-0}" -eq 129 ]

lxc delete --force x1
}
Loading