Ema has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/334369 )

Change subject: etcd.py: log a warning on empty responses from etcd
......................................................................

etcd.py: log a warning on empty responses from etcd

Avoid trying to load empty etcd responses as JSON, spamming the logs.

In particular, this currently happens every time the connection to etcd
is lost. Our EtcdClient inherits from twisted.web.http.HTTPClient, which
handles lost connections by calling handleResponse. In case of lost
connections, the response buffer might be empty, thus logging a
confusing JSON error.

If the response is not emtpy and not valid JSON, log it together with
the exception.

Bug: T134893
Change-Id: I0adf7e77a3b62c2bdbbcc7cc23f7e3eca08daa9e
---
M pybal/etcd.py
1 file changed, 6 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/debs/pybal 
refs/changes/69/334369/1

diff --git a/pybal/etcd.py b/pybal/etcd.py
index c38b3f4..7eb81b1 100644
--- a/pybal/etcd.py
+++ b/pybal/etcd.py
@@ -67,12 +67,15 @@
         if self.status != '200':
             err = error.Error(self.status, self.message, response)
             self.factory.onFailure(failure.Failure(err))
-        else:
+        elif response:
             try:
                 config = json.loads(response)
                 self.factory.onUpdate(config, self.etcdIndex)
-            except Exception:
-                self.factory.onFailure(failure.Failure())
+            except Exception, err:
+                msg = "Error: %s Etcd response: %s" % (err, response)
+                self.factory.onFailure(msg)
+        else:
+            log.warn("etcd: empty response from server")
 
         self.transport.loseConnection()
 

-- 
To view, visit https://gerrit.wikimedia.org/r/334369
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0adf7e77a3b62c2bdbbcc7cc23f7e3eca08daa9e
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/pybal
Gerrit-Branch: 1.13
Gerrit-Owner: Ema <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to