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: Fix Che update when backup/restore CRDs don't exist #1264

Merged
merged 1 commit into from
May 27, 2021
Merged
Changes from all 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
32 changes: 19 additions & 13 deletions src/tasks/installers/operator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,26 +386,32 @@ export class OperatorTasks {
task: async (ctx: any, task: any) => {
const existedBackupCRD = await kube.getCrd(this.cheClusterBackupCrd)
const newBackupCRDPath = path.join(ctx.resourcesPath, 'crds', 'org.eclipse.che_checlusterbackups_crd.yaml')
if (existedBackupCRD) {
if (!existedBackupCRD.metadata || !existedBackupCRD.metadata.resourceVersion) {
throw new Error(`Fetched CRD ${this.cheClusterBackupCrd} without resource version`)
if (fs.existsSync(newBackupCRDPath)) {
if (existedBackupCRD) {
if (!existedBackupCRD.metadata || !existedBackupCRD.metadata.resourceVersion) {
throw new Error(`Fetched CRD ${this.cheClusterBackupCrd} without resource version`)
}
await kube.replaceCrdFromFile(newBackupCRDPath, existedBackupCRD.metadata.resourceVersion)
} else {
await kube.createCrdFromFile(newBackupCRDPath)
}
await kube.replaceCrdFromFile(newBackupCRDPath, existedBackupCRD.metadata.resourceVersion)
} else {
await kube.createCrdFromFile(newBackupCRDPath)
}

const existedRestoreCRD = await kube.getCrd(this.cheClusterRestoreCrd)
const newRestoreCRDPath = path.join(ctx.resourcesPath, 'crds', 'org.eclipse.che_checlusterrestores_crd.yaml')
if (existedRestoreCRD) {
if (!existedRestoreCRD.metadata || !existedRestoreCRD.metadata.resourceVersion) {
throw new Error(`Fetched CRD ${this.cheClusterRestoreCrd} without resource version`)
if (fs.existsSync(newRestoreCRDPath)) {
if (existedRestoreCRD) {
if (!existedRestoreCRD.metadata || !existedRestoreCRD.metadata.resourceVersion) {
throw new Error(`Fetched CRD ${this.cheClusterRestoreCrd} without resource version`)
}
await kube.replaceCrdFromFile(newRestoreCRDPath, existedRestoreCRD.metadata.resourceVersion)
task.title = `${task.title}...updated.`
} else {
await kube.createCrdFromFile(newRestoreCRDPath)
task.title = `${task.title}...created new one.`
}
await kube.replaceCrdFromFile(newRestoreCRDPath, existedRestoreCRD.metadata.resourceVersion)
task.title = `${task.title}...updated.`
} else {
await kube.createCrdFromFile(newRestoreCRDPath)
task.title = `${task.title}...created new one.`
task.title = `${task.title}...skipped.`
}
}
},
Expand Down