Skip to content

Commit

Permalink
Handle dashboard pod on server start/stop commands (#1024)
Browse files Browse the repository at this point in the history
Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
  • Loading branch information
mmorhun committed Dec 9, 2020
1 parent 17b1025 commit 87a18ad
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/tasks/che.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
]
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 87a18ad

Please sign in to comment.