From b6901d2093457230a62dc132e84b2566c99c2497 Mon Sep 17 00:00:00 2001 From: Michal Vala Date: Fri, 19 Jul 2019 09:23:52 +0200 Subject: [PATCH 1/3] feat: remove devfile and plugin registries defaults Signed-off-by: Michal Vala --- src/commands/server/start.ts | 6 ++---- src/installers/helm.ts | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/commands/server/start.ts b/src/commands/server/start.ts index 0e61a34c2..7ac7d1eb3 100644 --- a/src/commands/server/start.ts +++ b/src/commands/server/start.ts @@ -53,13 +53,11 @@ export default class Start extends Command { env: 'CHE_TEMPLATES_FOLDER' }), 'devfile-registry-url': string({ - description: 'The URL of the Devfile registry.', - default: 'https://che-devfile-registry.openshift.io/', + description: 'The URL of the external Devfile registry.', env: 'CHE_WORKSPACE_DEVFILE__REGISTRY__URL' }), 'plugin-registry-url': string({ - description: 'The URL of the plugin registry.', - default: 'https://che-plugin-registry.openshift.io/v3', + description: 'The URL of the external plugin registry.', env: 'CHE_WORKSPACE_PLUGIN__REGISTRY__URL' }), cheboottimeout: string({ diff --git a/src/installers/helm.ts b/src/installers/helm.ts index 45b26cb71..9f6aaf1e0 100644 --- a/src/installers/helm.ts +++ b/src/installers/helm.ts @@ -195,18 +195,30 @@ error: E_COMMAND_FAILED`) let multiUserFlag = '' let tlsFlag = '' - let setOptions = '' + let setOptions = [] if (flags.multiuser) { multiUserFlag = `-f ${destDir}values/multi-user.yaml` } if (flags.tls) { - setOptions = `--set global.cheDomain=${flags.domain} --set global.tls.email='${ctx.tlsEmail}'` + setOptions.push(`--set global.cheDomain=${flags.domain} --set global.tls.email='${ctx.tlsEmail}'`) tlsFlag = `-f ${destDir}values/tls.yaml` } - let command = `helm upgrade --install che --force --namespace ${flags.chenamespace} --set global.ingressDomain=${flags.domain} ${setOptions} --set cheImage=${flags.cheimage} --set global.cheWorkspacesNamespace=${flags.chenamespace} --set che.workspace.devfileRegistryUrl=${flags['devfile-registry-url']} --set che.workspace.pluginRegistryUrl=${flags['plugin-registry-url']} ${multiUserFlag} ${tlsFlag} ${destDir}` + if (flags['plugin-registry-url']) { + setOptions.push(`--set che.workspace.pluginRegistryUrl=${flags['plugin-registry-url']} --set chePluginRegistry.deploy=false`) + } + + if (flags['devfile-registry-url']) { + setOptions.push(`--set che.workspace.devfileRegistryUrl=${flags['devfile-registry-url']} --set cheDevfileRegistry.deploy=false`) + } + + setOptions.push(`--set global.ingressDomain=${flags.domain}`) + setOptions.push(`--set cheImage=${flags.cheimage}`) + setOptions.push(`--set global.cheWorkspacesNamespace=${flags.chenamespace}`) + + let command = `helm upgrade --install che --force --namespace ${flags.chenamespace} ${setOptions.join(' ')} ${multiUserFlag} ${tlsFlag} ${destDir}` let {code, stderr} = await execa.shell(command, { timeout: execTimeout, reject: false }) // if process failed, check the following From afb7a0fa6e8d8f8e599f49c57cf7ed194662485e Mon Sep 17 00:00:00 2001 From: Michal Vala Date: Mon, 22 Jul 2019 10:12:27 +0200 Subject: [PATCH 2/3] feat: add registries to post install checks Signed-off-by: Michal Vala --- src/commands/server/start.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/commands/server/start.ts b/src/commands/server/start.ts index 7ac7d1eb3..77faed075 100644 --- a/src/commands/server/start.ts +++ b/src/commands/server/start.ts @@ -286,6 +286,20 @@ export default class Start extends Command { }) } + if (!flags['devfile-registry-url']) { + cheBootstrapSubTasks.add({ + title: 'Devfile registry pod bootstrap', + task: () => this.podStartTasks(this.getDevfileRegistrySelector(), flags.chenamespace) + }) + } + + if (!flags['plugin-registry-url']) { + cheBootstrapSubTasks.add({ + title: 'Plugin registry pod bootstrap', + task: () => this.podStartTasks(this.getPluginRegistrySelector(), flags.chenamespace) + }) + } + cheBootstrapSubTasks.add({ title: 'Che pod bootstrap', task: () => this.podStartTasks(this.getCheServerSelector(), flags.chenamespace) @@ -329,6 +343,14 @@ export default class Start extends Command { return 'app=che,component=keycloak' } + getDevfileRegistrySelector(): string { + return 'app=che,component=devfile-registry' + } + + getPluginRegistrySelector(): string { + return 'app=che,component=plugin-registry' + } + getCheServerSelector(): string { return 'app=che,component=che' } From 1cbb8d022ee77ae997e02fde6a8a2c1a49136688 Mon Sep 17 00:00:00 2001 From: Michal Vala Date: Mon, 22 Jul 2019 13:46:01 +0200 Subject: [PATCH 3/3] fix: fix server:stop and stop registries if started Signed-off-by: Michal Vala --- src/commands/server/stop.ts | 54 +++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/src/commands/server/stop.ts b/src/commands/server/stop.ts index ad1c7306e..834e1dae6 100644 --- a/src/commands/server/stop.ts +++ b/src/commands/server/stop.ts @@ -34,7 +34,7 @@ export default class Stop extends Command { }), 'che-selector': string({ description: 'Selector for Che Server resources', - default: 'app=che', + default: 'app=che,component=che', env: 'CHE_SELECTOR' }), 'access-token': string({ @@ -87,6 +87,8 @@ export default class Stop extends Command { // helm chart and Che operator use a deployment ctx.foundKeycloakDeployment = await kh.deploymentExist('keycloak', flags.chenamespace) ctx.foundPostgresDeployment = await kh.deploymentExist('postgres', flags.chenamespace) + ctx.foundDevfileRegistryDeployment = await kh.deploymentExist('devfile-registry', flags.chenamespace) + ctx.foundPluginRegistryDeployment = await kh.deploymentExist('plugin-registry', flags.chenamespace) if (ctx.foundKeycloakDeployment && ctx.foundPostgresDeployment) { task.title = await `${task.title}...it does (as well as keycloak and postgres)` } else { @@ -170,7 +172,7 @@ Che server is not ready yet. Try again in a few seconds.` title: 'Wait until Che pod is deleted', enabled: (ctx: any) => !ctx.isAlreadyStopped && !ctx.isNotReadyYet, task: async (_ctx: any, task: any) => { - await kh.waitUntilPodIsDeleted('app=che', flags.chenamespace) + await kh.waitUntilPodIsDeleted('app=che,component=che', flags.chenamespace) task.title = `${task.title}...done.` } }, @@ -222,6 +224,54 @@ Che server is not ready yet. Try again in a few seconds.` task.title = `${task.title}...done.` } }, + { + title: 'Scale \"devfile registry\" deployment to zero', + enabled: (ctx: any) => ctx.foundDevfileRegistryDeployment, + task: async (ctx: any, task: any) => { + try { + if (ctx.deploymentConfigExist) { + await oc.scaleDeploymentConfig('devfile-registry', flags.chenamespace, 0) + } else { + await kh.scaleDeployment('devfile-registry', flags.chenamespace, 0) + } + task.title = await `${task.title}...done` + } catch (error) { + this.error(`E_SCALE_DEPLOY_FAIL - Failed to scale devfile-registry deployment. ${error.message}`) + } + } + }, + { + title: 'Wait until Devfile registry pod is deleted', + enabled: (ctx: any) => ctx.foundDevfileRegistryDeployment, + task: async (_ctx: any, task: any) => { + await kh.waitUntilPodIsDeleted('app=che,component=devfile-registry', flags.chenamespace) + task.title = `${task.title}...done.` + } + }, + { + title: 'Scale \"plugin registry\" deployment to zero', + enabled: (ctx: any) => ctx.foundPluginRegistryDeployment, + task: async (ctx: any, task: any) => { + try { + if (ctx.deploymentConfigExist) { + await oc.scaleDeploymentConfig('plugin-registry', flags.chenamespace, 0) + } else { + await kh.scaleDeployment('plugin-registry', flags.chenamespace, 0) + } + task.title = await `${task.title}...done` + } catch (error) { + this.error(`E_SCALE_DEPLOY_FAIL - Failed to scale plugin-registry deployment. ${error.message}`) + } + } + }, + { + title: 'Wait until Plugin registry pod is deleted', + enabled: (ctx: any) => ctx.foundPluginRegistryDeployment, + task: async (_ctx: any, task: any) => { + await kh.waitUntilPodIsDeleted('app=che,component=plugin-registry', flags.chenamespace) + task.title = `${task.title}...done.` + } + }, ], {renderer: flags['listr-renderer'] as any}) try {