Skip to content

Commit

Permalink
Made graph data service robust to missing endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
jackgr committed May 27, 2015
1 parent 04aa46d commit 6bd4374
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion www/master/shared/config/production.json
@@ -1,7 +1,7 @@
{
"k8sApiServer": "/api/v1beta2",
"k8sApiv1beta3Server": "/api/v1beta3",
"k8sDataServer": "/cluster",
"k8sDataServer": "",
"k8sDataPollMinIntervalSec": 10,
"k8sDataPollMaxIntervalSec": 120,
"k8sDataPollErrorThreshold": 5,
Expand Down
38 changes: 20 additions & 18 deletions www/master/shared/js/modules/services/pollK8sData.js
Expand Up @@ -12,7 +12,7 @@
var sampleDataFiles = ["shared/assets/sampleData1.json"];
this.setSampleDataFiles = function(value) { sampleDataFiles = value; };

var dataServer = "http://localhost:5555/cluster";
var dataServer = "";
this.setDataServer = function(value) { dataServer = value; };

var pollMinIntervalSec = 10;
Expand Down Expand Up @@ -107,24 +107,26 @@

var pollOnce = function(scope, repeat) {
var dataSource = (k8sdatamodel.useSampleData) ? getSampleDataFile() : dataServer;
$.getJSON(dataSource)
.done(function(newModel, jqxhr, textStatus) {
if (newModel && newModel.success) {
delete newModel.success; // Remove success indicator.
delete newModel.timestamp; // Remove changing timestamp.
updateModel(newModel);
scope.$apply();
if (dataSource) {
$.getJSON(dataSource)
.done(function(newModel, jqxhr, textStatus) {
if (newModel && newModel.success) {
delete newModel.success; // Remove success indicator.
delete newModel.timestamp; // Remove changing timestamp.
updateModel(newModel);
scope.$apply();
promise = repeat ? $timeout(function() { pollOnce(scope, true); }, pollInterval * 1000) : undefined;
return;
}

bumpCounters();
promise = repeat ? $timeout(function() { pollOnce(scope, true); }, pollInterval * 1000) : undefined;
return;
}

bumpCounters();
promise = repeat ? $timeout(function() { pollOnce(scope, true); }, pollInterval * 1000) : undefined;
})
.fail(function(jqxhr, textStatus, error) {
bumpCounters();
promise = repeat ? $timeout(function() { pollOnce(scope, true); }, pollInterval * 1000) : undefined;
});
})
.fail(function(jqxhr, textStatus, error) {
bumpCounters();
promise = repeat ? $timeout(function() { pollOnce(scope, true); }, pollInterval * 1000) : undefined;
});
}
};

var isPolling = function() { return promise ? true : false; };
Expand Down

0 comments on commit 6bd4374

Please sign in to comment.