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

chore: Update CRD before deletion in 2 steps #2930

Merged
merged 3 commits into from
Sep 10, 2024
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
6 changes: 4 additions & 2 deletions src/api/kube-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,7 @@ export class KubeClient {
const k8sApi = this.kubeConfig.makeApiClient(ApiextensionsV1Api)
try {
const response = await k8sApi.readCustomResourceDefinition(crd.metadata!.name!)

crd.metadata!.resourceVersion = (response.body as any).metadata.resourceVersion
await k8sApi.replaceCustomResourceDefinition(crd.metadata!.name!, crd)
} catch (e: any) {
Expand Down Expand Up @@ -1096,11 +1097,12 @@ export class KubeClient {
return
}

crd = await this.getCustomResourceDefinition(crdName)
// 1. Disable conversion webhook
crd.spec.conversion = null
await this.replaceCustomResourceDefinition(crd)

// 2. Patch CRD to unblock potential invalid resource
// 2. Patch CRD to unblock potential invalid resource error
crd = await this.getCustomResourceDefinition(crdName)
for (let i = 0; i < crd.spec.versions.length; i++) {
if (crd.spec.versions[i].schema?.openAPIV3Schema?.properties?.spec) {
crd.spec.versions[i].schema.openAPIV3Schema.properties.spec = {type: 'object', properties: {}}
Expand Down
Loading