Skip to content

Commit

Permalink
feat: Use registry.devfile.io by default in Eclipse Che
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
  • Loading branch information
tolusha committed Feb 19, 2024
1 parent b9d376c commit 96a24ce
Showing 1 changed file with 42 additions and 38 deletions.
80 changes: 42 additions & 38 deletions src/tasks/pod-tasks.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
* Red Hat, Inc. - initial API and implementation
*/

import { ux } from '@oclif/core'
import {ux} from '@oclif/core'
import * as Listr from 'listr'
import {KubeClient} from '../api/kube-client'
import {KubeHelperContext} from '../context'
@@ -59,8 +59,12 @@ export namespace PodTasks {
return {
title: `Scale ${name} ${replicas > 0 ? 'Up' : 'Down'}`,
task: async (_ctx: any, task: any) => {
await kubeHelper.scaleDeployment(deploymentName, namespace, replicas)
task.title = `${task.title}...[OK]`
if (await kubeHelper.isDeploymentExist(deploymentName, namespace)) {
await kubeHelper.scaleDeployment(deploymentName, namespace, replicas)
task.title = `${task.title}...[OK]`
} else {
task.title = `${task.title}...[Not found]`
}
},
}
}
@@ -265,8 +269,8 @@ export namespace PodTasks {
}

/**
* Checks if there is any reason for a given pod state and returns message if so.
*/
* Checks if there is any reason for a given pod state and returns message if so.
*/
async function getContainerFailState(namespace: string, selector: string, state: string): Promise<FailState | undefined> {
const kubeHelper = KubeClient.getInstance()
const waitingState = await kubeHelper.getPodWaitingState(namespace, selector, state)
@@ -278,38 +282,38 @@ export namespace PodTasks {
/**
* Returns extended timeout error message explaining a failure.
*/
async function getTimeOutErrorMessage(namespace: string, selector: string): Promise<string> {
const kubeHelper = KubeClient.getInstance()
const pods = await kubeHelper.getPodListByLabel(namespace, selector)
if (!pods.length) {
throw new Error(`Timeout: there are no pods in the namespace: ${namespace}, selector: ${selector}. Check ${EclipseChe.PRODUCT_NAME} logs for details. Consider increasing error recheck timeout with --k8spoderrorrechecktimeout flag.`)
}

let errorMessage = 'Timeout:'
for (const pod of pods) {
errorMessage += `\nPod: ${pod.metadata!.name}`
if (pod.status) {
if (pod.status.containerStatuses) {
errorMessage += `\n\t\tstatus: ${JSON.stringify(pod.status.containerStatuses, undefined, ' ')}`
}

if (pod.status.conditions) {
errorMessage += `\n\t\tconditions: ${JSON.stringify(pod.status.conditions, undefined, ' ')}`
}
} else {
errorMessage += ', status not found.'
}
}

return errorMessage
}

async function getCheClusterFailState(namespace: string): Promise<FailState | undefined> {
const kubeHelper = KubeClient.getInstance()
const cheCluster = await kubeHelper.getCheCluster(namespace)
if (cheCluster?.status?.reason && cheCluster?.status?.message) {
return cheCluster.status
}
}
async function getTimeOutErrorMessage(namespace: string, selector: string): Promise<string> {
const kubeHelper = KubeClient.getInstance()
const pods = await kubeHelper.getPodListByLabel(namespace, selector)
if (!pods.length) {
throw new Error(`Timeout: there are no pods in the namespace: ${namespace}, selector: ${selector}. Check ${EclipseChe.PRODUCT_NAME} logs for details. Consider increasing error recheck timeout with --k8spoderrorrechecktimeout flag.`)
}

let errorMessage = 'Timeout:'
for (const pod of pods) {
errorMessage += `\nPod: ${pod.metadata!.name}`
if (pod.status) {
if (pod.status.containerStatuses) {
errorMessage += `\n\t\tstatus: ${JSON.stringify(pod.status.containerStatuses, undefined, ' ')}`
}

if (pod.status.conditions) {
errorMessage += `\n\t\tconditions: ${JSON.stringify(pod.status.conditions, undefined, ' ')}`
}
} else {
errorMessage += ', status not found.'
}
}

return errorMessage
}

async function getCheClusterFailState(namespace: string): Promise<FailState | undefined> {
const kubeHelper = KubeClient.getInstance()
const cheCluster = await kubeHelper.getCheCluster(namespace)
if (cheCluster?.status?.reason && cheCluster?.status?.message) {
return cheCluster.status
}
}
}

0 comments on commit 96a24ce

Please sign in to comment.