@cryptotaxi247 / netdata-1 / commits / 931eb66b3

allow dashboards to retry fetching chart data on failures; fixes #1402

Costa Tsaousis (ktsaou) committed Dec 20, 2016 at 00:20 UTC 931eb66b3f9da273988f9a5961d6134fa4500af1
3 files changed +26 -4
web/dashboard.js
+18 -2
@@ -332,6 +332,8 @@
332 async_on_scroll: false, // sync/async onscroll handler
333 onscroll_worker_duration_threshold: 30, // time in ms, to consider slow the onscroll handler
334
335 + retries_on_data_failures: 3, // how many retries to make if we can't fetch chart data from the server
336 +
337 setOptionCallback: function() { ; }
338 },
339
@@ -1231,6 +1233,9 @@
1233 // the chart library requested by the user
1234 this.library_name = self.data('chart-library') || NETDATA.chartDefaults.library;
1235
1236 + // how many retries we have made to load chart data from the server
1237 + this.retries_on_data_failures = 0;
1238 +
1239 // object - the chart library used
1240 this.library = null;
1241
@@ -3077,6 +3082,7 @@
3082 })
3083 .done(function(data) {
3084 that.xhr = undefined;
3085 + that.retries_on_data_failures = 0;
3086
3087 if(that.debug === true)
3088 that.log('data received. updating chart.');
@@ -3086,8 +3092,18 @@
3092 .fail(function(msg) {
3093 that.xhr = undefined;
3094
3089 - if(msg.statusText !== 'abort')
3090 - error('data download failed for url: ' + that.data_url);
3095 + if(msg.statusText !== 'abort') {
3096 + that.retries_on_data_failures++;
3097 + if(that.retries_on_data_failures > NETDATA.options.current.retries_on_data_failures) {
3098 + // that.log('failed ' + that.retries_on_data_failures.toString() + ' times - giving up');
3099 + that.retries_on_data_failures = 0;
3100 + error('data download failed for url: ' + that.data_url);
3101 + }
3102 + else {
3103 + that.tm.last_autorefreshed = Date.now();
3104 + // that.log('failed ' + that.retries_on_data_failures.toString() + ' times, but I will retry');
3105 + }
3106 + }
3107 })
3108 .always(function() {
3109 that.xhr = undefined;
web/demosites.html
+4 -1
@@ -505,7 +505,7 @@ p {
505 and that you have chown it to be owned by netdata:netdata
506 -->
507 <!-- <script type="text/javascript" src="http://my.server:19999/dashboard.js"></script> -->
508 -<script type="text/javascript" src="dashboard.js?v20161218-1"></script>
508 +<script type="text/javascript" src="dashboard.js?v20161219-1"></script>
509
510 <script>
511 // --- OPTIONS FOR THE CHARTS --
@@ -529,6 +529,9 @@ p {
529 // since we have many servers and limited sockets,
530 // abort ajax calls when we scroll
531 NETDATA.options.current.abort_ajax_on_scroll = true;
532 +
533 + // do not to give errors on netdata demo servers for 60 seconds
534 + NETDATA.options.current.retries_on_data_failures = 60;
535 </script>
536
537 <style>
web/index.html
+4 -1
@@ -2511,6 +2511,9 @@
2511 });
2512
2513 if(isdemo()) {
2514 + // do not to give errors on netdata demo servers for 60 seconds
2515 + NETDATA.options.current.retries_on_data_failures = 60;
2516 +
2517 if(urlOptions.nowelcome !== true) {
2518 setTimeout(function() {
2519 $('#welcomeModal').modal();
@@ -3185,4 +3188,4 @@
3188 </div>
3189 </body>
3190 </html>
3188 -<script type="text/javascript" src="dashboard.js?v20161218-5"></script>
3191 +<script type="text/javascript" src="dashboard.js?v20161219-1"></script>