From 66c4d45cf3a44f063e27e57987ec277f6f14d8e4 Mon Sep 17 00:00:00 2001 From: Jeroen Willemsen Date: Wed, 3 May 2023 13:45:43 +0200 Subject: [PATCH] Fix for waiting for team : return in readiness check added --- wrongsecrets-balancer/src/kubernetes.js | 5 ++--- wrongsecrets-balancer/src/teams/teams.js | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/wrongsecrets-balancer/src/kubernetes.js b/wrongsecrets-balancer/src/kubernetes.js index 9a68d3bb3..5a9d0446f 100644 --- a/wrongsecrets-balancer/src/kubernetes.js +++ b/wrongsecrets-balancer/src/kubernetes.js @@ -1299,11 +1299,10 @@ const deleteDesktopPodForTeam = async (team) => { module.exports.deleteDesktopPodForTeam = deleteDesktopPodForTeam; const getJuiceShopInstanceForTeamname = (teamname) => { - logger.info('checking readiness'); - k8sAppsApi + logger.info(`checking readiness for ${teamname}`); + return k8sAppsApi .readNamespacedDeployment(`t-${teamname}-wrongsecrets`, `t-${teamname}`) .then((res) => { - logger.info(JSON.stringify(res)); if ( Object.prototype.hasOwnProperty.call(res.body, 'metadata') && Object.prototype.hasOwnProperty.call(res.body.metadata, 'annotations') diff --git a/wrongsecrets-balancer/src/teams/teams.js b/wrongsecrets-balancer/src/teams/teams.js index 2948a1b2a..7fee2c44d 100644 --- a/wrongsecrets-balancer/src/teams/teams.js +++ b/wrongsecrets-balancer/src/teams/teams.js @@ -514,7 +514,6 @@ async function resetPasscode(req, res) { error )}` ); - // logger.error(error.message); return res.status(500).send({ message: 'Unknown error while resetting passcode.' }); } } @@ -537,16 +536,16 @@ async function awaitReadiness(req, res) { return res.status(200).send(); } - await sleep(1000); + await sleep(4000); - logger.error(`Waiting for deployment of team '${team}' timed out`); - res.status(500).send({ message: 'Waiting for Deployment Readiness Timed Out' }); } catch (error) { logger.error(`Failed to wait for teams '${team}' deployment to get ready: ${error}`); logger.error(error); - res.status(500).send({ message: 'Failed to Wait For Deployment Readiness' }); + return res.status(500).send({ message: 'Failed to Wait For Deployment Readiness' }); } } + logger.error(`Waiting for deployment of team '${team}' timed out`); + return res.status(500).send({ message: 'Waiting for Deployment Readiness Timed Out' }); } /**