Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <[email protected]>
  • Loading branch information
tolusha committed Feb 19, 2024
1 parent 71f3363 commit 3e2c2c9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
14 changes: 11 additions & 3 deletions src/tasks/che-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,21 @@ export namespace CheTasks {
title: `Scale ${EclipseChe.PRODUCT_NAME} down`,
task: async (_ctx: any, _task: any) => {
const flags = CheCtlContext.getFlags()
const kubeHelper = KubeClient.getInstance()
const cheCluster = await kubeHelper.getCheCluster(flags[CHE_NAMESPACE_FLAG])

const tasks = newListr()
tasks.add(PodTasks.getScaleDeploymentTask(EclipseChe.GATEWAY, EclipseChe.GATEWAY_DEPLOYMENT_NAME, 0, flags[CHE_NAMESPACE_FLAG]))
tasks.add(PodTasks.getScaleDeploymentTask(EclipseChe.DASHBOARD, EclipseChe.DASHBOARD_DEPLOYMENT_NAME, 0, flags[CHE_NAMESPACE_FLAG]))
tasks.add(PodTasks.getScaleDeploymentTask(EclipseChe.CHE_SERVER, EclipseChe.CHE_SERVER_DEPLOYMENT_NAME, 0, flags[CHE_NAMESPACE_FLAG]))
tasks.add(PodTasks.getScaleDeploymentTask(EclipseChe.PLUGIN_REGISTRY, EclipseChe.PLUGIN_REGISTRY_DEPLOYMENT_NAME, 0, flags[CHE_NAMESPACE_FLAG]))
tasks.add(PodTasks.getScaleDeploymentTask(EclipseChe.DEVFILE_REGISTRY, EclipseChe.DEVFILE_REGISTRY_DEPLOYMENT_NAME, 0, flags[CHE_NAMESPACE_FLAG]))
if (!cheCluster?.spec?.components?.pluginRegistry?.disableInternalRegistry) {
tasks.add(PodTasks.getScaleDeploymentTask(EclipseChe.PLUGIN_REGISTRY, EclipseChe.PLUGIN_REGISTRY_DEPLOYMENT_NAME, 0, flags[CHE_NAMESPACE_FLAG]))
}

if (!cheCluster?.spec?.components?.devfileRegistry?.disableInternalRegistry) {
tasks.add(PodTasks.getScaleDeploymentTask(EclipseChe.DEVFILE_REGISTRY, EclipseChe.DEVFILE_REGISTRY_DEPLOYMENT_NAME, 0, flags[CHE_NAMESPACE_FLAG]))
}

return tasks
},
}
Expand All @@ -94,9 +102,9 @@ export namespace CheTasks {
task: async (_ctx: any, _task: any) => {
const flags = CheCtlContext.getFlags()
const kubeHelper = KubeClient.getInstance()
const cheCluster = await kubeHelper.getCheCluster(flags[CHE_NAMESPACE_FLAG])

const tasks = newListr()
const cheCluster = await kubeHelper.getCheCluster(flags[CHE_NAMESPACE_FLAG])
if (cheCluster) {
if (!cheCluster.spec?.components?.devfileRegistry?.disableInternalRegistry) {
tasks.add(PodTasks.getScaleDeploymentTask(EclipseChe.DEVFILE_REGISTRY, EclipseChe.DEVFILE_REGISTRY_DEPLOYMENT_NAME, 1, flags[CHE_NAMESPACE_FLAG]))
Expand Down
9 changes: 5 additions & 4 deletions src/tasks/pod-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ export namespace PodTasks {
return {
title: `Scale ${name} ${replicas > 0 ? 'Up' : 'Down'}`,
task: async (_ctx: any, task: any) => {
if (await kubeHelper.isDeploymentExist(deploymentName, namespace)) {
await kubeHelper.scaleDeployment(deploymentName, namespace, replicas)
task.title = `${task.title}...[OK]`
} else {
if (replicas === 0 && !await kubeHelper.isDeploymentExist(deploymentName, namespace)) {
task.title = `${task.title}...[Not found]`
return
}

await kubeHelper.scaleDeployment(deploymentName, namespace, replicas)
task.title = `${task.title}...[OK]`
},
}
}
Expand Down

0 comments on commit 3e2c2c9

Please sign in to comment.