Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wait for some time when che-operator updated status with an error #1763

Merged
merged 4 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ OPTIONS
[default: 600000] Waiting time for Pod downloading image (in milliseconds)

--k8spoderrorrechecktimeout=k8spoderrorrechecktimeout
[default: 15000] Waiting time for Pod rechecking error (in milliseconds)
[default: 60000] Waiting time for Pod rechecking error (in milliseconds)

--k8spodreadytimeout=k8spodreadytimeout
[default: 600000] Waiting time for Pod Ready condition (in milliseconds)
Expand Down Expand Up @@ -738,7 +738,7 @@ OPTIONS
--k8spoddownloadimagetimeout=k8spoddownloadimagetimeout [default: 600000] Waiting time for Pod downloading image (in
milliseconds)

--k8spoderrorrechecktimeout=k8spoderrorrechecktimeout [default: 15000] Waiting time for Pod rechecking error (in
--k8spoderrorrechecktimeout=k8spoderrorrechecktimeout [default: 60000] Waiting time for Pod rechecking error (in
milliseconds)

--k8spodreadytimeout=k8spodreadytimeout [default: 600000] Waiting time for Pod Ready condition (in
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const DEFAULT_ANALYTIC_HOOK_NAME = 'analytics'

// Timeouts
export const DEFAULT_K8S_POD_WAIT_TIMEOUT = 600000
export const DEFAULT_K8S_POD_ERROR_RECHECK_TIMEOUT = 15000
export const DEFAULT_K8S_POD_ERROR_RECHECK_TIMEOUT = 60000

// Custom Resources names
export const CHE_CLUSTER_CRD = 'checlusters.org.eclipse.che'
Expand Down
28 changes: 16 additions & 12 deletions src/tasks/kube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,19 @@ export class KubeTasks {
for (let i = 1; i <= iterations; i++) {
// check cheCluster status
const cheClusterFailState = await this.getCheClusterFailState(namespace)
if (cheClusterFailState) {
task.title = `${task.title}...failed`
throw new Error(`Eclipse Che operator failed, reason: ${cheClusterFailState.reason}, message: ${cheClusterFailState.message}. Consider increasing error recheck timeout with --k8spoderrorrechecktimeout flag.`)
}

// check 'PodScheduled' condition
const podFailState = await this.getPodFailState(namespace, selector, 'PodScheduled')
if (podFailState) {
// for instance we need some time for pvc provisioning...

if (cheClusterFailState || podFailState) {
// wait some time to recheck
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do something like:

await cli.wait(10 * 1000)
i += 10
continue

Otherwise, if we face a problem that is resolved in a dozen of seconds, current code will wait whole minute.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

improved

await cli.wait(this.kubeHelper.podErrorRecheckTimeout)

const cheClusterFailState = await this.getCheClusterFailState(namespace)
if (cheClusterFailState) {
task.title = `${task.title}...failed`
throw new Error(`Eclipse Che operator failed, reason: ${cheClusterFailState.reason}, message: ${cheClusterFailState.message}. Consider increasing error recheck timeout with --k8spoderrorrechecktimeout flag.`)
}

const podFailState = await this.getPodFailState(namespace, selector, 'PodScheduled')
if (podFailState) {
task.title = `${task.title}...failed`
Expand Down Expand Up @@ -103,15 +105,17 @@ export class KubeTasks {
for (let i = 1; i <= iterations; i++) {
// check cheCluster status
const cheClusterFailState = await this.getCheClusterFailState(namespace)
if (cheClusterFailState) {
task.title = `${task.title}...failed`
throw new Error(`Eclipse Che operator failed, reason: ${cheClusterFailState.reason}, message: ${cheClusterFailState.message}. Consider increasing error recheck timeout with --k8spoderrorrechecktimeout flag.`)
}

const failedState = await this.getContainerFailState(namespace, selector, 'Running')
if (failedState) {
if (cheClusterFailState || failedState) {
await cli.wait(this.kubeHelper.podErrorRecheckTimeout)

const cheClusterFailState = await this.getCheClusterFailState(namespace)
if (cheClusterFailState) {
task.title = `${task.title}...failed`
throw new Error(`Eclipse Che operator failed, reason: ${cheClusterFailState.reason}, message: ${cheClusterFailState.message}. Consider increasing error recheck timeout with --k8spoderrorrechecktimeout flag.`)
}

const failedState = await this.getContainerFailState(namespace, selector, 'Running')
if (failedState) {
task.title = `${task.title}...failed`
Expand Down