From ddc7889df19cc75eafb91651d94c3f24c5bfd681 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Wed, 17 Sep 2014 14:01:01 +0000 Subject: [PATCH] Run bandersnatch under file locking and a timeout * modules/openstack_project/manifests/pypi_mirror.pp: Bandersnatch occasionally seems to livelock in a select poll loop at teardown. https://bitbucket.org/pypa/bandersnatch/issue/52 As such this blocks subsequent runs of our wrapper script, filling the log with useless tracebacks every 5 minutes while leaving the mirror perpetually stale until someone comes along and notices. Work around this unfortunate situation by setting a half hour timeout on the process, and add a file lock to the invocation so that it will not try to run more instances of the wrapper script until the current one terminates. Change-Id: I055b623801af3063d22b081eb9c9ef3634e5e5b5 --- modules/openstack_project/manifests/pypi_mirror.pp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/openstack_project/manifests/pypi_mirror.pp b/modules/openstack_project/manifests/pypi_mirror.pp index a9f09db95a..6ef79daaef 100644 --- a/modules/openstack_project/manifests/pypi_mirror.pp +++ b/modules/openstack_project/manifests/pypi_mirror.pp @@ -55,9 +55,13 @@ class openstack_project::pypi_mirror ( ensure => directory, } + file { '/var/run/bandersnatch': + ensure => directory, + } + cron { 'bandersnatch': minute => '*/5', - command => 'run-bandersnatch >>/var/log/bandersnatch/mirror.log 2>&1', + command => 'flock -n /var/run/bandersnatch/mirror.lock timeout -k 2m 30m run-bandersnatch >>/var/log/bandersnatch/mirror.log 2>&1', environment => 'PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin', }