mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
fix: SIGKILL docker container on stop instead of 5s grace period
Docker node stop took ~5s every time. The stop API grace period
(params t=5, unchanged since 2015) was always exhausted: the business
process (often an interactive shell) ignores SIGTERM, and GNS3 doesn't
depend on graceful shutdown — _fix_permissions and /gns3volumes already
persist container state before stop() is called.
Use POST /containers/{id}/kill (SIGKILL, zero delay) instead of stop.
The 409 (container already stopped) replaces the previous 304 handling
for the race where the container exits between the state check and the call.
t=5 traced to commit 33edbefa3 (2015-10-14) "Docker cleanup and
improvements" — introduced with no recorded rationale.
This commit is contained in:
2 files changed
+9
-6
No files matched your search
@@ -1209,7 +1209,7 @@ async def test_stop(vm):
|
||||
with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query:
|
||||
vm._permissions_fixed = False
|
||||
await vm.stop()
|
||||
mock_query.assert_called_with("POST", "containers/e90e34656842/stop", params={"t": 5})
|
||||
mock_query.assert_called_with("POST", "containers/e90e34656842/kill")
|
||||
assert mock.stop.called
|
||||
assert vm._ubridge_hypervisor is None
|
||||
assert vm._fix_permissions.called
|
||||
@@ -1222,7 +1222,7 @@ async def test_stop_paused_container(vm):
|
||||
with asyncio_patch("gns3server.compute.docker.DockerVM.unpause") as mock_unpause:
|
||||
with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query:
|
||||
await vm.stop()
|
||||
mock_query.assert_called_with("POST", "containers/e90e34656842/stop", params={"t": 5})
|
||||
mock_query.assert_called_with("POST", "containers/e90e34656842/kill")
|
||||
assert mock_unpause.called
|
||||
|
||||
|
||||
@@ -1894,7 +1894,7 @@ async def test_stop_exited_container_no_stop_query(vm):
|
||||
vm._permissions_fixed = False
|
||||
await vm.stop()
|
||||
assert not any(
|
||||
call.args[:2] == ("POST", "containers/e90e34656842/stop")
|
||||
call.args[:2] == ("POST", "containers/e90e34656842/kill")
|
||||
for call in mock_query.mock_calls
|
||||
)
|
||||
assert vm.status == "stopped"
|
||||
Reference in new issue
Block a user