From d6388ca0e6687273a97ec4192a52a40111cbf0a0 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Thu, 12 Dec 2013 11:41:57 -0500 Subject: [PATCH] [WORKER] Fix for saving stats on initial UPDATE The HAProxy statistics socket file will not exist on a new device, so attempts to save the stats before a reload would fail. Change-Id: Ib31509bb7d68424d63f41b1c3032f15a1ca786e2 --- libra/worker/drivers/haproxy/ubuntu_services.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libra/worker/drivers/haproxy/ubuntu_services.py b/libra/worker/drivers/haproxy/ubuntu_services.py index a7386b93..6413a6c6 100644 --- a/libra/worker/drivers/haproxy/ubuntu_services.py +++ b/libra/worker/drivers/haproxy/ubuntu_services.py @@ -39,7 +39,13 @@ class UbuntuServices(services_base.ServicesBase): """ Save current HAProxy totals for an expected restart. """ - q = query.HAProxyQuery('/var/run/haproxy-stats.socket') + socket_file = '/var/run/haproxy-stats.socket' + + # On a new device, the socket file won't exist. + if not os.path.exists(socket_file): + return + + q = query.HAProxyQuery(socket_file) results = q.get_bytes_out() stats_file = cfg.CONF['worker:haproxy']['statsfile']