Merge lp:~pconnell/endroid/pinger into lp:endroid

Proposed by Phil Connell
Status: Merged
Approved by: Paul Stanley
Approved revision: 102
Merged at revision: 98
Proposed branch: lp:~pconnell/endroid/pinger
Merge into: lp:endroid
Diff against target: 88 lines (+28/-11)
4 files modified
debian/changelog (+8/-0)
etc/init/endroid.conf (+1/-1)
setup.py (+1/-1)
src/endroid/plugins/periodicpinger.py (+18/-9)
To merge this branch: bzr merge lp:~pconnell/endroid/pinger
Reviewer Review Type Date Requested Status
Phil Connell Approve
Review via email: mp+238291@code.launchpad.net

This proposal supersedes a proposal from 2014-10-14.

Commit message

Improve reliability of periodic pinger

- Handle failures in wokkel/twisted (endroid bug 1380972)
- Log unexpected async errors for triageability
- Use addCallbacks so that errback is actually called!

Also tweak debian service file to log messages from twisted using the logging infra (rather than stderr).

Description of the change

Edit:
  - Tweak debian service config file, so that messages from twisted (e.g. unhandled deferred failure) are logged.
  - Fix bug in ping error handling.
  - Log StanzaErrors as debug rather than errors.

Improve reliability of periodic pinger

- Handle failures in wokkel/twisted (endroid bug 1380972)
- Log async errors for triageability
- Use addCallbacks so that errback is actually called!

To post a comment you must log in.
Revision history for this message
Phil Connell (pconnell) wrote : Posted in a previous version of this proposal

Ping to webex conference server *always* fails, so unconditional move to error logging in errback is no good.

root DEBUG Failed to ping conference.isj3.webex.com: StanzaError with condition u'bad-request'"

review: Needs Fixing
Revision history for this message
Paul Stanley (paul-stanley) : Posted in a previous version of this proposal
Revision history for this message
Phil Connell (pconnell) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2014-10-10 11:19:50 +0000
3+++ debian/changelog 2014-10-14 12:34:13 +0000
4@@ -1,3 +1,11 @@
5+endroid (1.4.6) trusty; urgency=medium
6+
7+ * Bugfixes and robustness improvements for periodic pinger.
8+ * When started as a debian service, log twisted messages to the endroid
9+ logfile.
10+
11+ -- Phil Connell <phil.connell@ensoft.co.uk> Tue, 14 Oct 2014 13:33:00 +0100
12+
13 endroid (1.4.5) trusty; urgency=medium
14
15 * Fix endroid_remote watch.
16
17=== modified file 'etc/init/endroid.conf'
18--- etc/init/endroid.conf 2014-09-15 16:45:29 +0000
19+++ etc/init/endroid.conf 2014-10-14 12:34:13 +0000
20@@ -1,7 +1,7 @@
21 description "EnDroid XMPP bot"
22 author "Ensoft Limited"
23
24-exec /usr/bin/endroid -L /var/log/endroid.log --config /etc/endroid/endroid.conf
25+exec /usr/bin/endroid --logtwisted -L /var/log/endroid.log --config /etc/endroid/endroid.conf
26 start on net-device-up
27 stop on stopping network
28 stop on starting shutdown
29
30=== modified file 'setup.py'
31--- setup.py 2014-10-10 11:19:50 +0000
32+++ setup.py 2014-10-14 12:34:13 +0000
33@@ -24,7 +24,7 @@
34
35
36 setup(name='endroid',
37- version="1.4.5",
38+ version="1.4.6",
39 description='EnDroid: a modular XMPP bot',
40 url='http://open.ensoft.co.uk/EnDroid',
41 packages=[
42
43=== modified file 'src/endroid/plugins/periodicpinger.py'
44--- src/endroid/plugins/periodicpinger.py 2014-10-02 12:51:59 +0000
45+++ src/endroid/plugins/periodicpinger.py 2014-10-14 12:34:13 +0000
46@@ -12,9 +12,11 @@
47
48
49 import logging
50+import functools
51 import itertools
52
53 import twisted.internet.task
54+from twisted.words.protocols.jabber.error import StanzaError
55
56 from endroid.pluginmanager import Plugin
57
58@@ -64,16 +66,23 @@
59
60 for server in self.servers:
61 def _fail(fail, server):
62- # If the server returns an error then we don't really care,
63- # since all we want to do is ensure server-to-server
64- # connections are kept open by sending ping traffic and we have
65- # achieved this. So just log for debugging purposes.
66- logging.debug("Failed to ping {}: {}"
67- .format(server, str(fail.value)))
68+ if fail.check(StanzaError):
69+ # Some servers that don't support c2s pings return 'bad
70+ # request' rather than 'not supported'. This still serves
71+ # the keep-the-connection alive purpose, so don't log as an
72+ # error.
73+ logger = self.log.debug
74+ else:
75+ logger = self.log.error
76+ logger("Failed to ping {}: {}".format(server, fail.value))
77 def _success(response):
78 pass
79- d = self.usermanagement.ping(server)
80- d.addCallback(_success)
81- d.addErrback(_fail, server)
82+ try:
83+ d = self.usermanagement.ping(server)
84+ except Exception:
85+ self.log.exception("Failed to send ping to {}:".format(server))
86+ else:
87+ d.addCallbacks(_success,
88+ functools.partial(_fail, server=server))
89
90

Subscribers

People subscribed via source and target branches