Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (onLatest.length === relevantDynos.length) {
if (!released) {
cli.action.stop(`${releasedFraction}, done`)
}
break
}
if (released) {
released = false
cli.action.start(`Waiting for every dyno to be running v${latestRelease.version}`)
}
cli.action.status = releasedFraction
// eslint-disable-next-line no-await-in-loop
await cli.wait(interval * 1000)
}
}
}
task: async (_ctx: any, _task: any) => {
await cli.wait(1000)
await kube.waitLatestReplica(this.operatorName, flags.chenamespace)
}
}
async waitUntilReadyToShutdown(cheURL: string, intervalMs = 500, timeoutMs = 60000) {
const iterations = timeoutMs / intervalMs
for (let index = 0; index < iterations; index++) {
let status = await this.getCheServerStatus(cheURL)
if (status === 'READY_TO_SHUTDOWN') {
return
}
await cli.wait(intervalMs)
}
throw new Error('ERR_TIMEOUT')
}
task: async (_ctx: any, task: any) => {
if (await kh.crdExist(this.cheClusterCrd) &&
await kh.cheClusterExist(this.operatorCheCluster, flags.chenamespace)) {
await kh.deleteCheCluster(this.operatorCheCluster, flags.chenamespace)
await cli.wait(2000) //wait a couple of secs for the finalizers to be executed
task.title = await `${task.title}...OK`
} else {
task.title = await `${task.title}...CR not found`
}
}
},
async waitForPodReady(selector: string, namespace = '', intervalMs = 500, timeoutMs = this.podReadyTimeout) {
const iterations = timeoutMs / intervalMs
for (let index = 0; index < iterations; index++) {
let readyStatus = await this.getPodReadyConditionStatus(selector, namespace)
if (readyStatus === 'True') {
return
}
if (readyStatus !== 'False') {
throw new Error(`ERR_BAD_READY_STATUS: ${readyStatus} (True or False expected) `)
}
await cli.wait(intervalMs)
}
throw new Error(`ERR_TIMEOUT: Timeout set to pod ready timeout ${this.podReadyTimeout}`)
}
async waitLatestReplica(deploymentName: string, namespace = '', intervalMs = 500, timeoutMs = this.podWaitTimeout) {
const iterations = timeoutMs / intervalMs
for (let index = 0; index < iterations; index++) {
const deployment = await this.getDeployment(deploymentName, namespace)
if (!deployment) {
throw new Error(`Deployment ${namespace}/${deploymentName} is not found.`)
}
const deploymentStatus = deployment.status
if (!deploymentStatus) {
throw new Error(`Deployment ${namespace}/${deploymentName} does not have any status`)
}
if (deploymentStatus.unavailableReplicas && deploymentStatus.unavailableReplicas > 0) {
await cli.wait(intervalMs)
} else {
return
}
}
throw new Error(`ERR_TIMEOUT: Timeout set to pod wait timeout ${this.podWaitTimeout}`)
}
cli.action.stop('created!')
this.log(`${appName} is ready to deploy :)`)
break
case 'stop':
var appId = await cli.prompt('Enter your app id',{required:true})
await cli.action.start('please wait...')
await cli.wait(2000)
cli.action.stop('stoped!')
this.log(`your app (${appId}) is stoped`)
break
case 'rm':
var appId = await cli.prompt('Enter your app id',{required:true})
var confimation = await cli.confirm('are you really sure to remove?')
if (confimation){
await cli.action.start('please wait...')
await cli.wait(2000)
cli.action.stop('removed!')
this.log('your app is not any more exist in this universe!')
}else {
this.log('notting happend!')
}
break
case 'scale':
var appId = await cli.prompt('Enter your app id',{required:true})
var appId = await cli.prompt('Enter your app scale',{required:true})
}
}
}
async waitForService(selector: string, namespace = '', intervalMs = 500, timeoutMs = 30000) {
const iterations = timeoutMs / intervalMs
for (let index = 0; index < iterations; index++) {
let currentServices = await this.getServicesBySelector(selector, namespace)
if (currentServices && currentServices.items.length > 0) {
return
}
await cli.wait(intervalMs)
}
throw new Error(`ERR_TIMEOUT: Timeout set to waiting for service ${timeoutMs}`)
}
async waitForPodPhase(selector: string, targetPhase: string, namespace = '', intervalMs = 500, timeoutMs = this.podWaitTimeout) {
const iterations = timeoutMs / intervalMs
for (let index = 0; index < iterations; index++) {
let currentPhase = await this.getPodPhase(selector, namespace)
if (targetPhase === currentPhase) {
return
}
await cli.wait(intervalMs)
}
throw new Error(`ERR_TIMEOUT: Timeout set to pod wait timeout ${this.podWaitTimeout}`)
}
async waitUntilPodIsDeleted(selector: string, namespace = '', intervalMs = 500, timeoutMs = this.podReadyTimeout) {
const iterations = timeoutMs / intervalMs
for (let index = 0; index < iterations; index++) {
let readyStatus = await this.getPodReadyConditionStatus(selector, namespace)
if (readyStatus === 'False') {
return
}
if (readyStatus !== 'True') {
throw new Error(`ERR_BAD_READY_STATUS: ${readyStatus} (True or False expected) `)
}
await cli.wait(intervalMs)
}
throw new Error(`ERR_TIMEOUT: Timeout set to pod ready timeout ${this.podReadyTimeout}`)
}