From ed3a4c8771e4e41ba0b7828a082d20c933d69c5c Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Tue, 10 Sep 2024 12:29:44 +0200 Subject: [PATCH] chore: Update CRD before deletion in 2 steps (#2930) * chore: Update CRD before deletion in 2 steps Signed-off-by: Anatolii Bazko --- src/api/kube-client.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api/kube-client.ts b/src/api/kube-client.ts index 14f0960da..8e571162e 100644 --- a/src/api/kube-client.ts +++ b/src/api/kube-client.ts @@ -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) { @@ -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: {}}