From 6067ea13bc81c39070516821e374d83c76b5f5a3 Mon Sep 17 00:00:00 2001 From: Dale Hille Date: Thu, 4 Mar 2021 18:09:40 -0500 Subject: [PATCH] =?UTF-8?q?perf:=20use=20findOne=20in=20the=20orgs=20colle?= =?UTF-8?q?ction=20rather=20than=20find=20all=20from=20Cl=E2=80=A6=20(#803?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * perf: use findOne in the orgs collection rather than find all from Clusters * Update app/routes/kube/kube.js Co-authored-by: Adam King * Update kube.js Co-authored-by: Adam King --- app/routes/kube/kube.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/routes/kube/kube.js b/app/routes/kube/kube.js index 42a759ba9..7b5998862 100644 --- a/app/routes/kube/kube.js +++ b/app/routes/kube/kube.js @@ -26,7 +26,12 @@ const timeInterval = 300000; //5 mintues // /kube/liveness const kube = router.get('/liveness', asyncHandler(async(req, res) => { // does a db call to make sure we didnt disconnect - await require('../../apollo/models').models.Cluster.find({}, { _id:1 }, { limit:1 }); + try { + await require('../../apollo/models').models.Organization.findOne({}); + } catch (err) { + logger.error(err, 'razeedash-api liveness probe failed due to a mongo connection issue'); + return res.sendStatus(503); + } // TODO: not real pub-sub liveness test yet, will add later if (pubSub.initRetries > 5) {