Skip to content

Commit 50f0491

Browse files
committed
added delete verification to delete namespace
Signed-off-by: Jeromy Cannon <jeromy@swirldslabs.com>
1 parent 74edacd commit 50f0491

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/core/kube/k8_client/resources/namespace/k8_client_namespaces.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {type V1Status, type CoreV1Api} from '@kubernetes/client-node';
66
import {StatusCodes} from 'http-status-codes';
77
import {SoloError} from '../../../../errors.js';
88
import {NamespaceName} from '../../../resources/namespace/namespace_name.js';
9-
import {ResourceDeleteError} from '../../../errors/resource_operation_errors.js';
10-
import {ResourceType} from '../../../resources/resource_type.js';
9+
import {sleep} from '../../../../helpers.js';
10+
import {Duration} from '../../../../time/duration.js';
1111

1212
export class K8ClientNamespaces implements Namespaces {
1313
constructor(private readonly kubeClient: CoreV1Api) {}
@@ -26,6 +26,17 @@ export class K8ClientNamespaces implements Namespaces {
2626
public async delete(namespace: NamespaceName): Promise<boolean> {
2727
try {
2828
const resp: {response: any; body?: V1Status} = await this.kubeClient.deleteNamespace(namespace.name);
29+
let namespaceExists = true;
30+
while (namespaceExists) {
31+
const response = await this.kubeClient.readNamespace(namespace.name);
32+
33+
if (!response?.body?.metadata?.deletionTimestamp) {
34+
namespaceExists = false;
35+
} else {
36+
await sleep(Duration.ofSeconds(1));
37+
}
38+
}
39+
2940
return resp.response.statusCode === StatusCodes.OK;
3041
} catch {
3142
return false;

0 commit comments

Comments
 (0)