Skip to content

Commit 31306bf

Browse files
committed
Merge pull request #575 from cheld/fix-heapster-check
fix health check error handling
2 parents 6a9bb39 + ac861ea commit 31306bf

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

build/cluster.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const clusterHealthzUrl = `${conf.backend.apiServerHost}/healthz`;
2929
/**
3030
* The validate URL of the heapster to check that it is running.
3131
*/
32-
const heapsterValidateUrl = `${conf.backend.heapsterServerHost}/api/v1/model/stats/`;
32+
const heapsterValidateUrl = `${conf.backend.heapsterServerHost}/api/v1/model/metrics/uptime`;
3333

3434
/**
3535
* A Number, representing the ID value of the timer that is set for function which periodically
@@ -70,11 +70,12 @@ function heapsterHealthCheck(doneFn) {
7070
if (err) {
7171
return doneFn(new Error(err));
7272
}
73-
let statistics = JSON.parse(stdout.trim());
74-
let uptime = statistics.uptime;
75-
if (!isNaN(uptime)) {
76-
return doneFn();
73+
try {
74+
JSON.parse(stdout.trim());
75+
} catch (err) {
76+
return doneFn(err);
7777
}
78+
return doneFn('ok');
7879
});
7980
}
8081

@@ -121,11 +122,13 @@ gulp.task('wait-for-heapster', function(doneFn) {
121122
counter += 1;
122123

123124
// constantly query the heapster until it is properly running
124-
heapsterHealthCheck(function() {
125-
gulpUtil.log(gulpUtil.colors.magenta('Heapster is up and running.'));
126-
clearTimeout(isHeapsterRunningSetIntervalHandler);
127-
isHeapsterRunningSetIntervalHandler = null;
128-
doneFn();
125+
heapsterHealthCheck(function(result) {
126+
if (result === 'ok' && isHeapsterRunningSetIntervalHandler !== null) {
127+
gulpUtil.log(gulpUtil.colors.magenta('Heapster is up and running.'));
128+
clearTimeout(isHeapsterRunningSetIntervalHandler);
129+
isHeapsterRunningSetIntervalHandler = null;
130+
doneFn();
131+
}
129132
});
130133
}
131134
});

0 commit comments

Comments
 (0)