Ema has submitted this change and it was merged. ( 
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 debian/changelog
M pybal/etcd.py
2 files changed, 8 insertions(+), 4 deletions(-)

Approvals:
  Ema: Verified; Looks good to me, approved
  Volans: Looks good to me, but someone else must approve



diff --git a/debian/changelog b/debian/changelog
index bf4db10..1cc0c0d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
 pybal (1.13.4) UNRELEASED; urgency=medium
 
-  * Allow to specify configuration file name on the CLI (-c).
+  * Allow to specify configuration file name on the CLI (-c)
+  * Log a warning on empty responses from etcd
 
  -- Emanuele Rocca <[email protected]>  Thu, 26 Jan 2017 09:48:27 +0100
 
diff --git a/pybal/etcd.py b/pybal/etcd.py
index c38b3f4..6128d79 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 is not None and len(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: merged
Gerrit-Change-Id: I0adf7e77a3b62c2bdbbcc7cc23f7e3eca08daa9e
Gerrit-PatchSet: 2
Gerrit-Project: operations/debs/pybal
Gerrit-Branch: 1.13
Gerrit-Owner: Ema <[email protected]>
Gerrit-Reviewer: BBlack <[email protected]>
Gerrit-Reviewer: Ema <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: Volans <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to