mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-21 21:45:20 +02:00
docker: harden the shm/devices/extra_configs/masking work (code review)
Nine fixes from a review of the docker-shm-devices diff:
* GNS3_STOP_TIMEOUT >300 s aborted at the manager's default HTTP timeout
before Docker finished the stop — the stop query now gets a timeout
with a margin over the grace period.
* Overlapping bind targets (GNS3_MASK_UDEV + GNS3_MASK_SYSTEMD on the
same unit, a unit named twice, an extra_configs target equal to a
masked unit) made Docker reject the create with 'Duplicate mount
point' — Mounts are deduplicated by target.
* ExtraConfig.target now carries a pydantic validator (absolute file
path, no '..'), so bad targets 422 at template-save time instead of
failing at node-create time after a multi-GB image pull; directory
forms ('/', '/etc/') are also rejected by the runtime guard instead
of raising IsADirectoryError (raw 500).
* _check_host_readiness skipped every remaining check when one
/proc/sys key was unreadable (mid-loop return) — now continues.
* The base-class GNS3_* env parser strips trailing commas like the
vendor parser, so 'GNS3_MASK_UDEV=1,' composed from a list still
activates.
* Vendor env knobs are re-parsed on every create(), so a PUT to the
node's environment takes effect on the next (re)create.
* The graceful SIGTERM stop is now limited to the explicit user stop
route; delete/update/close/crash-cleanup keep the immediate kill
(those paths force-delete or recreate the container right after).
* An extra_configs target beneath a persisted volume is shadowed by the
volume bind — warn at create time.
This commit is contained in:
9 files changed
+297
-43
No files matched your search
@@ -415,3 +415,34 @@ async def test_check_host_readiness_silent_when_ok(caplog):
|
||||
docker._check_host_readiness()
|
||||
|
||||
assert not [r for r in caplog.records if r.levelno == logging.WARNING]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_check_host_readiness_continues_past_unreadable_key(caplog):
|
||||
"""
|
||||
One unreadable /proc/sys key must not discard the warnings already
|
||||
collected nor skip the FUSE check (that was a mid-loop return).
|
||||
"""
|
||||
|
||||
import logging
|
||||
from io import StringIO
|
||||
|
||||
docker = Docker()
|
||||
files = {
|
||||
"/proc/sys/fs/inotify/max_user_instances": "128", # low -> must warn
|
||||
# max_user_watches and fs.file-max: unreadable -> skipped
|
||||
"/proc/filesystems": "nodev ext4\n", # no fuse -> must warn
|
||||
}
|
||||
|
||||
def fake_open(path, *args, **kwargs):
|
||||
if path not in files:
|
||||
raise OSError("masked")
|
||||
return StringIO(files[path])
|
||||
|
||||
with patch("builtins.open", side_effect=fake_open):
|
||||
with caplog.at_level(logging.WARNING, logger="gns3server.compute.docker"):
|
||||
docker._check_host_readiness()
|
||||
|
||||
message = " ".join(r.message for r in caplog.records)
|
||||
assert "max_user_instances=128" in message # collected before the gap
|
||||
assert "modprobe fuse" in message # FUSE check still ran
|
||||
Reference in new issue
Block a user