[BUG] swag-ondemand.py infinite loop on Docker daemon restart causes massive log spam and disk exhaustion
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- docker, python
- Domain
- devops, infrastructure
Research direction
Start in swag-ondemand.py at ContainerThread.run(self), especially the exception handler described in the issue. Review how Docker connection failures are logged, then verify during temporary Docker daemon unavailability that retries no longer flood ondemand.log or exhaust disk space.
Written by the indexing model from the issue text.
Description
Is there an existing issue for this?
- I have searched the existing issues
Name of mod
swag-ondemand
Name of base container
swag
Current Behavior
When the Docker daemon is upgraded (e.g., via unattended-upgrades), the service restart takes long enough for the /var/run/docker.sock to be removed and recreated. During this window, swag-ondemand.py enters an unthrottled infinite loop, flooding ondemand.log with 502 Bad Gateway / 503 Service Unavailable errors (hundreds per second). This quickly consumes all host disk space, leading to OSError: [Errno 28] No space left on device and triggering a cascading failure of all other containers on the host.
I've verified the code: the issue is located in the run(self) method of ContainerThread class, where the except block executes a logging.exception(e) without any time.sleep(), causing a tight loop that creates hundreds of log entries per second upon connection failure.
Expected Behavior
The script should handle the temporary Docker daemon unavailability gracefully. It should implement a backoff or a delay in the except block of the main loop to prevent log flooding and resource exhaustion during daemon maintenance.
Steps To Reproduce
The issue is specifically reproducible during an automated Docker package upgrade. It is difficult to reproduce with a simple systemctl restart docker as the socket is often replaced fast enough to avoid triggering the sustained 502/503 loop.
- Ensure swag-ondemand is running.
- Trigger an apt upgrade docker-ce (which performs a full package replacement/restart).
- Observe ondemand.log growing at high speed due to the lack of a delay in the exception handler.
Environment
- OS: Ubuntu 24.04.3
- How docker service was installed: Docker's apt repository
CPU architecture
x86-64
Docker creation
services:
nginx:
image: lscr.io/linuxserver/nginx:latest
container_name: redacted
networks:
- swag
environment:
PUID: ${PUID}
PGID: ${PGID}
TZ: ${TIMEZONE}
volumes:
- ./config:/config
- /media/library/archive/redacted:/config/www
restart: unless-stopped
labels:
- swag=enable
- swag_url=sub.${DOMAIN_NAME}
- swag_port=80
- swag_auth=authelia
- swag_ondemand=enable
- swag_server_custom_directive=include /config/nginx/ondemand.conf;
- swag_ondemand_urls=https://sub.
networks:
swag:
external: true
Container logs
.
- Dominant language
- No language data
- Stars
- 1.5k
- Forks
- 329
- Avg merge
- 5h 5m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from linuxserver/docker-mods
-
no-issue-activity
Difficulty 3/5 1-2 days Newbie friendliness 55/100
linuxserver/docker-mods#1164 · 2 comments ·
-
enhancement no-issue-activity
Difficulty 3/5 1-2 days Newbie friendliness 55/100
linuxserver/docker-mods#1163 · 1 comment ·
-
enhancement no-issue-activity
Difficulty 3/5 1-2 days Newbie friendliness 58/100
linuxserver/docker-mods#1142 · 3 comments ·
-
enhancement no-issue-activity
Difficulty 3/5 1-2 days Newbie friendliness 58/100
linuxserver/docker-mods#1128 · 4 comments ·
All issues in linuxserver/docker-mods
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·
-
repo:raw-data
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
hotosm/raw-data-api#316 · 1 comment ·
-
agentic-workflows cascade-suspected
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
willow
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
openedx/openedx-authz#460 ·