From 87a18ad92da1b6c9e9e8fe22cbc8cb1d016c32b4 Mon Sep 17 00:00:00 2001 From: Mykola Morhun Date: Wed, 9 Dec 2020 17:18:14 +0200 Subject: [PATCH] Handle dashboard pod on server start/stop commands (#1024) Signed-off-by: Mykola Morhun --- src/tasks/che.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/tasks/che.ts b/src/tasks/che.ts index 8ce4ba242..058bb5dce 100644 --- a/src/tasks/che.ts +++ b/src/tasks/che.ts @@ -35,6 +35,9 @@ export class CheTasks { cheSelector = 'app=che,component=che' cheDeploymentName: string + dashboardDeploymentName = 'che-dashboard' + dashboardSelector = 'app=che,component=che-dashboard' + keycloakDeploymentName = 'keycloak' keycloakSelector = 'app=che,component=keycloak' @@ -118,6 +121,14 @@ export class CheTasks { ctx.isCheStopped = await this.kube.deploymentStopped(this.cheDeploymentName, this.cheNamespace) } + ctx.isDashboardDeployed = await this.kube.deploymentExist(this.dashboardDeploymentName, this.cheNamespace) + if (ctx.isDashboardDeployed) { + ctx.isDashboardReady = await this.kube.deploymentReady(this.dashboardDeploymentName, this.cheNamespace) + if (!ctx.isDashboardReady) { + ctx.isDashboardStopped = await this.kube.deploymentStopped(this.dashboardDeploymentName, this.cheNamespace) + } + } + ctx.isKeycloakDeployed = await this.kube.deploymentExist(this.keycloakDeploymentName, this.cheNamespace) if (ctx.isKeycloakDeployed) { ctx.isKeycloakReady = await this.kube.deploymentReady(this.keycloakDeploymentName, this.cheNamespace) @@ -252,6 +263,14 @@ export class CheTasks { return this.kubeTasks.podStartTasks(this.cheSelector, this.cheNamespace) } }, + { + title: 'Eclipse Che dashboard pod bootstrap', + enabled: ctx => ctx.isDashboardDeployed && !ctx.isDashboardReady, + task: async () => { + await this.kube.scaleDeployment(this.dashboardDeploymentName, this.cheNamespace, 1) + return this.kubeTasks.podStartTasks(this.dashboardSelector, this.cheNamespace) + } + }, ...this.checkEclipseCheStatus() ] } @@ -295,6 +314,18 @@ export class CheTasks { } } }, + { + title: 'Scale \"dashboard\" deployment to zero', + enabled: (ctx: any) => ctx.isDashboardDeployed && !ctx.isDashboardStopped, + task: async (_ctx: any, task: any) => { + try { + await this.kube.scaleDeployment(this.dashboardDeploymentName, this.cheNamespace, 0) + task.title = await `${task.title}...done` + } catch (error) { + command.error(`E_SCALE_DEPLOY_FAIL - Failed to scale dashboard deployment. ${error.message}`) + } + } + }, { title: 'Scale \"keycloak\" deployment to zero', enabled: (ctx: any) => ctx.isKeycloakDeployed && !ctx.isKeycloakStopped,