Skip to content

Commit

Permalink
check real nativeUserMode from checluster
Browse files Browse the repository at this point in the history
Co-authored-by: Anatolii Bazko <[email protected]>
Signed-off-by: Michal Vala <[email protected]>
  • Loading branch information
sparkoo and tolusha committed Aug 5, 2021
1 parent fc76775 commit 0c66367
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
26 changes: 24 additions & 2 deletions src/tasks/che.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ export class CheTasks {
this.cheDeploymentName = flags['deployment-name']
}

async skipKeycloakDeploy(): Promise<boolean> {
const cheCluster = await this.kube.getCheCluster(this.cheNamespace)
if (!cheCluster) {
return false
}
return cheCluster.spec.auth.nativeUserMode
}

/**
* Returns tasks list that waits until every Eclipse Che component will be started.
*
Expand All @@ -93,7 +101,15 @@ export class CheTasks {
{
title: 'Keycloak pod bootstrap',
enabled: ctx => ctx.isKeycloakDeployed && !ctx.isKeycloakReady,
task: () => this.kubeTasks.podStartTasks(this.keycloakSelector, this.cheNamespace),
task: async (_ctx: any, task: any) => {
if (await this.skipKeycloakDeploy()) {
task.title = `${task.title}...skipped`
return {
task: () => {},
}
}
return this.kubeTasks.podStartTasks(this.keycloakSelector, this.cheNamespace)
},
},
{
title: 'Devfile Registry pod bootstrap',
Expand Down Expand Up @@ -252,7 +268,13 @@ export class CheTasks {
{
title: 'Keycloak pod bootstrap',
enabled: ctx => ctx.isKeycloakDeployed && !ctx.isKeycloakReady,
task: async () => {
task: async (_ctx: any, task: any) => {
if (await this.skipKeycloakDeploy()) {
task.title = `${task.title}...skipped`
return {
task: () => {},
}
}
await this.kube.scaleDeployment(this.keycloakDeploymentName, this.cheNamespace, 1)
return this.kubeTasks.podStartTasks(this.keycloakSelector, this.cheNamespace)
},
Expand Down
9 changes: 2 additions & 7 deletions src/tasks/installers/common-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { CheGithubClient } from '../../api/github-client'
import { KubeHelper } from '../../api/kube'
import { VersionHelper } from '../../api/version'
import { CHE_CLUSTER_CRD, DOCS_LINK_IMPORT_CA_CERT_INTO_BROWSER, OPERATOR_TEMPLATE_DIR } from '../../constants'
import { getProjectVersion, isOpenshiftPlatformFamily } from '../../util'
import { getProjectVersion } from '../../util'

export function createNamespaceTask(namespaceName: string, labels: {}): Listr.ListrTask {
return {
Expand Down Expand Up @@ -141,7 +141,7 @@ export function createEclipseCheCluster(flags: any, kube: KubeHelper): Listr.Lis
const cheClusterCR = ctx.customCR || ctx.defaultCR
const cr = await kube.createCheCluster(cheClusterCR, flags, ctx, !ctx.customCR)

ctx.isKeycloakReady = ctx.isKeycloakReady || shouldNotDeployKeycloak(flags, cr)
ctx.isKeycloakReady = ctx.isKeycloakReady || cr.spec.auth.externalIdentityProvider
ctx.isPostgresReady = ctx.isPostgresReady || cr.spec.database.externalDb
ctx.isDevfileRegistryReady = ctx.isDevfileRegistryReady || cr.spec.server.externalDevfileRegistry
ctx.isPluginRegistryReady = ctx.isPluginRegistryReady || cr.spec.server.externalPluginRegistry
Expand All @@ -155,11 +155,6 @@ export function createEclipseCheCluster(flags: any, kube: KubeHelper): Listr.Lis
}
}

function shouldNotDeployKeycloak(flags: any, cr: any): boolean {
return cr.spec.auth.externalIdentityProvider || cr.spec.auth.nativeUserMode ||
(isOpenshiftPlatformFamily(flags.platform) && cr.spec.devWorkspace.enable)
}

/**
* Update CheCluster CR object using CR patch file.
* Clean up custom images if they weren't defined in the CR patch file to prevent update failing.
Expand Down

0 comments on commit 0c66367

Please sign in to comment.