Module: check_mk
Branch: master
Commit: 8f7e37b8e8f959718774ac3d178cc3e9bfd866cf
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8f7e37b8e8f959…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Sep 13 15:54:23 2017 +0200
5207 FIX Bulk discovery: Fixed "Maximum number of retries reached" error during
bulk discovery
When performing a bulk discovery on more than 40 hosts an error with
this message could occur:
"Error during discovery: Maximum number of retries reached. You need to restart the
bulk service discovery"
After this fix you should be able to perform bulk discoveries with a lot
larger number of hosts. The limitating factor (limited number of transaction ids)
has been removed.
Change-Id: I1788e48fa30eb9f4ff9f00d0a7c24b064d8f0922
---
.werks/5207 | 18 ++++++++++++++++++
web/htdocs/js/wato.js | 10 ++++------
web/htdocs/wato.py | 29 +++++++++++++----------------
3 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/.werks/5207 b/.werks/5207
new file mode 100644
index 0000000..61378f1
--- /dev/null
+++ b/.werks/5207
@@ -0,0 +1,18 @@
+Title: Bulk discovery: Fixed "Maximum number of retries reached" error during
bulk discovery
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1505307556
+
+When performing a bulk discovery on more than 40 hosts an error with
+this message could occur:
+
+"Error during discovery: Maximum number of retries reached. You need to restart the
bulk service discovery"
+
+After this fix you should be able to perform bulk discoveries with a lot
+larger number of hosts. The limitating factor (limited number of transaction ids)
+has been removed.
diff --git a/web/htdocs/js/wato.js b/web/htdocs/js/wato.js
index 45ee9e2..44e47fb 100644
--- a/web/htdocs/js/wato.js
+++ b/web/htdocs/js/wato.js
@@ -371,7 +371,7 @@ function progress_retry() {
// Note: no bulksize limit is applied here
progress_items = failed_items;
failed_items = Array();
- progress_scheduler(progress_mode, progress_url, progress_timeout, [], "",
"");
+ progress_scheduler(progress_mode, progress_url, progress_timeout, [], "");
}
@@ -453,13 +453,12 @@ function progress_clean_log() {
log.scrollTop = 0;
}
-function progress_scheduler(mode, url_prefix, timeout, items, transids, end_url,
success_stats, fail_stats, term_url, finished_txt) {
+function progress_scheduler(mode, url_prefix, timeout, items, end_url, success_stats,
fail_stats, term_url, finished_txt) {
// Initialize
if (progress_items === null) {
total_num_items = items.length;
progress_items = items;
failed_items = Array();
- progress_transids = transids;
progress_total_num = items.length;
progress_end_url = end_url;
progress_term_url = term_url;
@@ -487,8 +486,7 @@ function progress_scheduler(mode, url_prefix, timeout, items,
transids, end_url,
// Remove leading pipe signs (when having no folder set)
// update_progress_title(percentage + "%");
update_progress_title(title);
- use_transid = progress_transids.shift();
- get_url(url_prefix + '&_transid=' + use_transid +
'&_item=' + encodeURIComponent(progress_items[0]),
+ get_url(url_prefix + '&_transid=-1&_item=' +
encodeURIComponent(progress_items[0]),
progress_handle_response, // regular handler (http code 200)
[ mode, progress_items[0] ], // data to hand over to handlers
progress_handle_error // error handler
@@ -499,7 +497,7 @@ function progress_scheduler(mode, url_prefix, timeout, items,
transids, end_url,
}
}
- setTimeout(function() { progress_scheduler(mode, url_prefix, timeout, [],
"", ""); }, timeout);
+ setTimeout(function() { progress_scheduler(mode, url_prefix, timeout, [],
""); }, timeout);
}
function update_bulk_moveto(val) {
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index b2c8d91..ce93230 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -3905,15 +3905,10 @@ class ModeBulkDiscovery(WatoMode):
def action(self):
+ config.user.need_permission("wato.services")
if not self._item:
return
- if not html.check_transaction():
- html.write(json.dumps([ 'failed', 0, 0, 0, 0, 0, 0, ]) +
"\n")
- html.write_text(_("Error during discovery: Maximum number of retries
reached. "
- "You need to restart the bulk service
discovery"))
- return ""
-
try:
site_id, folderpath, hostnamesstring = self._item.split("|")
hostnames = hostnamesstring.split(";")
@@ -3921,6 +3916,16 @@ class ModeBulkDiscovery(WatoMode):
num_skipped_hosts = 0
num_failed_hosts = 0
folder = Folder.folder(folderpath)
+
+ if site_id not in config.sitenames():
+ raise MKGeneralException(_("The requested site does not
exist"))
+
+ for host_name in hostnames:
+ host = folder.host(host_name)
+ if host is None:
+ raise MKGeneralException(_("The requested host does not
exist"))
+ host.need_permission("write")
+
arguments = [self._mode,] + hostnames
if self._use_cache:
@@ -5698,16 +5703,8 @@ def interactive_progress(items, title, stats, finishvars,
timewait,
finish_url = folder_preserving_link([("mode", "folder")] +
finishvars)
term_url = folder_preserving_link([("mode", "folder")] +
termvars)
- # Reserve a certain amount of transids for the progress scheduler
- # Each json item requires one transid. Additionally, each "Retry failed
hosts" eats
- # up another one. We reserve 20 additional transids for the retry function
- # Note: The "retry option" ignores the bulk size
- transids = []
- for i in range(len(items) + 20):
- transids.append(html.fresh_transid())
-
- html.javascript(('progress_scheduler("%s", "%s", 50, %s, %s,
"%s", %s, %s, "%s", "' + _("FINISHED.") +
'");') %
- (html.var('mode'), base_url, json.dumps(items),
json.dumps(transids), finish_url,
+ html.javascript(('progress_scheduler("%s", "%s", 50, %s,
"%s", %s, %s, "%s", "' + _("FINISHED.") +
'");') %
+ (html.var('mode'), base_url, json.dumps(items), finish_url,
json.dumps(success_stats), json.dumps(fail_stats), term_url))