fix: router setup hangs on race condition with Docker.
Release / release (push) Successful in 18s

This commit is contained in:
slawek committed 2026-10-23 20:03:17 +02:00
1 parent 7163f167e0
commit a6b25b8bb4
5 files changed
+27 -6

No files matched your search

+3 -1
View File
@@ -217,7 +217,9 @@ external interface, in this order:
Traffic from every other interface, including the internal one and the Docker bridges, is
not affected. The rules cover IPv4 only.
The `vpn-router-docker` service applies the rules after `docker.service` starts and removes
`vpn-router-setup` starts after `docker.service`, so Docker is up when it looks for it; the
ordering has no effect on a host without Docker. The `vpn-router-docker` service applies the
rules after `docker.service` starts and removes
them when Docker stops, so restarting Docker restores them. `systemctl restart
vpn-router-setup` applies a changed configuration while Docker runs. With `docker.mode` set to
`on`, the service fails when Docker is not installed or its daemon is not running; with
+16
View File
@@ -1,3 +1,19 @@
vpn-router (0.4.1-1) unstable; urgency=medium
* Fix the start of vpn-router-setup hanging on a host that runs Docker.
vpn-router-setup restarted vpn-router-docker and waited for it, but that
unit was ordered after vpn-router-setup, so each waited for the other,
the installation of the package never finished and vpn-router-web was
never enabled or started. vpn-router-docker is no longer ordered after
vpn-router-setup, so vpn-router-setup still waits for it and the Docker
rules are in place when it ends. The restart of vpn-router-web is queued
without waiting.
* Start vpn-router-setup after docker.service, so that Docker is up when
the setup looks for it and does not start in parallel with it. The
ordering applies only when Docker is installed.
-- Slawomir Koszewski <slawek@koszewscy.waw.pl> Fri, 23 Oct 2026 20:10:00 +0200
vpn-router (0.4.0-1) unstable; urgency=medium
* Add the vpn-router-web service, a small status web service that uses only
@@ -1,7 +1,7 @@
[Unit]
Description=VPN Router rules for Docker published ports
Documentation=file:/usr/share/doc/vpn-router/README.md
After=docker.service vpn-router-setup.service
After=docker.service
PartOf=docker.service
[Service]
@@ -2,7 +2,7 @@
Description=VPN Router Setup
Documentation=file:/usr/share/doc/vpn-router/README.md
Wants=network-online.target
After=network-online.target
After=network-online.target docker.service
[Service]
Type=oneshot
+6 -3
View File
@@ -318,7 +318,9 @@ def refresh_docker_rules():
"""Apply the new settings to the Docker rules while Docker is running.
When Docker is not running, vpn-router-docker applies them after
docker.service starts.
docker.service starts. The restart is waited for, so the rules are in place
when this setup ends; vpn-router-docker is therefore not ordered after
vpn-router-setup.
"""
if unit_is_active('docker.service'):
run(['systemctl', 'restart', 'vpn-router-docker.service'], check=False)
@@ -332,7 +334,8 @@ def refresh_web(cfg, ctx):
secrets masked and the facts resolved from the system from a file here, so
that it needs nothing but the standard library and the configuration code.
The file is readable by root only. The service ends quietly when
web.enabled is false.
web.enabled is false. The restart is queued, not waited for, because the
unit is ordered after vpn-router-setup.
"""
masked = {
section: {option: '********' if SECRET_OPTION.search(option) and value else value
@@ -363,7 +366,7 @@ def refresh_web(cfg, ctx):
'remote_cidrs': ctx['remote_cidr_list'],
},
}) + '\n', encoding='utf-8')
run(['systemctl', 'restart', 'vpn-router-web.service'], check=False)
run(['systemctl', 'restart', '--no-block', 'vpn-router-web.service'], check=False)
def main():