mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
fix: refuse Docker node updates that recreate a running container
Updating any Docker node property destroys and recreates the container (the route calls DockerVM.update() as soon as the property diff is non-empty), so it discards everything written inside it. On a running node that happened silently, as a side effect of an unrelated edit: the user only saw the node restart. Refuse the update while the container is up and say what stopping it is for, like QEMU, IOU, Dynamips, VPCS, VirtualBox and VMware already do for their own restart-requiring settings. The check runs before anything is applied — a refused update leaves the node untouched — and only when the PUT really changes a property, since Web clients send the whole node back on every edit. is_running() is not reusable for the question: it reports a paused container as not running and stops crashed containers as a side effect, so DockerVM gains is_up() for "running or paused".
This commit is contained in:
3 files changed
+101
-7
No files matched your search
@@ -1395,6 +1395,21 @@ class DockerVM(DockerKernelDatapathMixin, BaseNode):
|
||||
await self.stop()
|
||||
return False
|
||||
|
||||
async def is_up(self):
|
||||
"""
|
||||
Checks if the container exists in a running or paused state.
|
||||
|
||||
Both mean the container holds live state that recreating it would
|
||||
discard. is_running() is not usable for that question: it reports a
|
||||
paused container as not running, and it stops a crashed container as
|
||||
a side effect.
|
||||
|
||||
:returns: True or False
|
||||
:rtype: bool
|
||||
"""
|
||||
|
||||
return await self._get_container_state() in ("running", "paused")
|
||||
|
||||
async def restart(self):
|
||||
"""
|
||||
Restart this Docker container.
|
||||
|
||||
Reference in new issue
Block a user