Skip to content

Commit

Permalink
Handle deleted state of che helm chart by rollbacking or purging the …
Browse files Browse the repository at this point in the history
…charts based on revisions

Fix #18

Change-Id: I30a7e4462d5c10219c216ee528e73f2853aeaba5
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
  • Loading branch information
benoitf committed Jul 3, 2019
1 parent 8139730 commit 42a14c5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/installers/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,21 @@ error: E_COMMAND_FAILED`)
}

let command = `helm upgrade --install che --force --namespace ${flags.chenamespace} --set global.ingressDomain=${flags.domain} --set cheImage=${flags.cheimage} --set global.cheWorkspacesNamespace=${flags.chenamespace} ${multiUserFlag} ${tlsFlag} ${destDir}`
await execa.shell(command, { timeout: execTimeout })
let {code} = await execa.shell(command, { timeout: execTimeout, reject: false })
// if process failed, check the following
// if revision=1, purge and retry command else rollback
if (code !== 0) {
// get revision
const {stdout} = await execa.shell(`helm history ${flags.chenamespace} | tail -1 | head -1 | awk '{print $1}'`, { timeout: execTimeout })
if (stdout === '1') {
await this.purgeHelmChart(flags.chenamespace)
} else {
await execa('helm', ['rollback', flags.chenamespace, stdout], { timeout: execTimeout })

}
await execa.shell(command, { timeout: execTimeout })

}
}

async purgeHelmChart(name: string, execTimeout= 30000) {
Expand Down

0 comments on commit 42a14c5

Please sign in to comment.