summaryrefslogtreecommitdiffstats
path: root/healthcheck-container/get-status.js
diff options
context:
space:
mode:
authorJack Lucas <jflucas@research.att.com>2018-05-09 22:44:31 +0000
committerJack Lucas <jflucas@research.att.com>2018-05-10 15:02:34 +0000
commite6d18573f4a45b144e0b56dd1e59715a1bdd2c58 (patch)
tree9fad26f021e06f14ba3b95a7851f3b4714dc97e1 /healthcheck-container/get-status.js
parentcb9d614fdc78480584466b8e84f3535d946424a0 (diff)
Fix healthcheck to check specific deployments
Change-Id: Idc6a3eece4e3aaba83a0b2388f2ae6c2407471a5 Issue-ID: DCAEGEN2-493 Signed-off-by: Jack Lucas <jflucas@research.att.com>
Diffstat (limited to 'healthcheck-container/get-status.js')
-rw-r--r--healthcheck-container/get-status.js34
1 files changed, 33 insertions, 1 deletions
diff --git a/healthcheck-container/get-status.js b/healthcheck-container/get-status.js
index 2ed1d3d..034ff9d 100644
--- a/healthcheck-container/get-status.js
+++ b/healthcheck-container/get-status.js
@@ -96,6 +96,30 @@ const getStatus = function(path, extract, callback) {
});
};
+const getStatusSinglePromise = function (item) {
+ // Expect item to be of the form {namespace: "namespace", deployment: "deployment_name"}
+ return new Promise(function(resolve, reject){
+ const path = K8S_PATH + item.namespace + '/deployments/' + item.deployment;
+ queryKubernetes(path, function(error, res, body){
+ if (error) {
+ reject(error);
+ }
+ else if (res.statusCode === 404) {
+ // Treat absent deployment as if it's an unhealthy deployment
+ resolve ({
+ metadata: {name: item.deployment},
+ status: {unavailableReplicas: 1}
+ });
+ }
+ else if (res.statusCode != 200) {
+ reject(body);
+ }
+ else {
+ resolve(body);
+ }
+ });
+ });
+}
exports.getStatusNamespace = function (namespace, callback) {
// Get readiness information for all deployments in namespace
const path = K8S_PATH + namespace + '/deployments';
@@ -106,4 +130,12 @@ exports.getStatusSingle = function (namespace, deployment, callback) {
// Get readiness information for a single deployment
const path = K8S_PATH + namespace + '/deployments/' + deployment;
getStatus(path, summarizeDeployment, callback);
-}; \ No newline at end of file
+};
+
+exports.getStatusListPromise = function (list) {
+ // List is of the form [{namespace: "namespace", deployment: "deployment_name"}, ... ]
+ const p = Promise.all(list.map(getStatusSinglePromise))
+ return p.then(function(results) {
+ return summarizeDeploymentList({items: results});
+ });
+} \ No newline at end of file