Module: check_mk
Branch: master
Commit: ecc366bb467e17cdd15dfb8d4071442b5a5bf008
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ecc366bb467e17…
Author: Roland Halbig <rh(a)mathias-kettner.de>
Date: Wed Feb 15 16:12:10 2017 +0100
4050 FIX Fixed snapin-refresh error handling.
Change-Id: I9e7164875d058e5580c9b26c5273e11540f8e6e2
---
.werks/4050 | 9 ++++++++
web/htdocs/sidebar.py | 63 ++++++++++++++++++++++++---------------------------
2 files changed, 39 insertions(+), 33 deletions(-)
diff --git a/.werks/4050 b/.werks/4050
new file mode 100644
index 0000000..f2c4d90
--- /dev/null
+++ b/.werks/4050
@@ -0,0 +1,9 @@
+Title: Fixed snapin-refresh error handling.
+Level: 1
+Component: multisite
+Compatible: compat
+Version: 1.4.0b2
+Date: 1487171383
+Class: fix
+
+
diff --git a/web/htdocs/sidebar.py b/web/htdocs/sidebar.py
index a81e33a..b42f078 100644
--- a/web/htdocs/sidebar.py
+++ b/web/htdocs/sidebar.py
@@ -433,44 +433,41 @@ def ajax_snapin():
else:
snapnames = html.var('names', '').split(',')
- html.plug()
snapin_code = []
- try:
- for snapname in snapnames:
- if not config.user.may("sidesnap." + snapname):
+ for snapname in snapnames:
+ if not config.user.may("sidesnap." + snapname):
+ continue
+ snapin = sidebar_snapins.get(snapname)
+
+ # When restart snapins are about to be refreshed, only render
+ # them, when the core has been restarted after their initial
+ # rendering
+ if not snapin.get('refresh') and snapin.get('restart'):
+ since = float(html.var('since', 0))
+ newest = since
+ for site in sites.states().values():
+ prog_start = site.get("program_start", 0)
+ if prog_start > newest:
+ newest = prog_start
+ if newest <= since:
+ # no restart
+ snapin_code.append('')
continue
- snapin = sidebar_snapins.get(snapname)
-
- # When restart snapins are about to be refreshed, only render
- # them, when the core has been restarted after their initial
- # rendering
- if not snapin.get('refresh') and snapin.get('restart'):
- since = float(html.var('since', 0))
- newest = since
- for site in sites.states().values():
- prog_start = site.get("program_start", 0)
- if prog_start > newest:
- newest = prog_start
- if newest <= since:
- # no restart
- snapin_code.append('')
- continue
- try:
- snapin["render"]()
- except Exception, e:
- if config.debug:
- raise
- snapin_exception(e)
+ html.plug()
+ try:
+ # For testing purposes only: raise Exception("Test")
+ snapin["render"]()
+ except Exception, e:
+ snapin_exception(e)
+ e_message = _("Exception during snapin refresh (snapin
\'%s\')") % snapname
+ logger.error("%s %s: %s" % (html.request_uri(), e_message,
traceback.format_exc()))
+ finally:
snapin_code.append(html.drain())
-
html.unplug()
- html.write('[%s]' % ','.join([ '"%s"' %
s.replace('"', '\\"').replace('\n', '') for s in
snapin_code]))
- except Exception, e:
- html.flush()
- html.unplug()
- logger.error('Exception during snapin refresh: %s' % e)
- raise
+
+ html.write('[%s]' % ','.join([ '"%s"' %
s.replace('"', '\\"').replace('\n', '') for s in
snapin_code]))
+
def move_snapin():
if not config.user.may("general.configure_sidebar"):