@@ -38,6 +38,7 @@ import kotlinx.coroutines.delay
3838import kotlinx.coroutines.launch
3939import kotlinx.coroutines.runBlocking
4040import kotlinx.coroutines.withTimeout
41+ import java.util.concurrent.RejectedExecutionException
4142
4243
4344abstract class IntegrationTestBase {
@@ -60,7 +61,7 @@ abstract class IntegrationTestBase {
6061 Runtime .getRuntime().addShutdownHook(Thread {
6162 runBlocking {
6263 deleteNamespaces()
63- deleteCRD(stableClient )
64+ deleteCRD()
6465 }
6566 })
6667
@@ -126,20 +127,24 @@ abstract class IntegrationTestBase {
126127 }
127128
128129 private suspend fun deleteNamespaces () {
129- for (managedNamespace in managedNamespaces) {
130- val ns = stableClient.namespaces().withName(managedNamespace).get() ? : continue
131- try {
132- stableClient.namespaces().delete(ns)
133- } catch (e: KubernetesClientException ) {
134- // this namespace is probably all being deleted
135- }
136- while (stableClient.namespaces().withName(managedNamespace).get() != null ) {
130+ do {
131+ for (managedNamespace in managedNamespaces) {
132+ val ns = stableClient.namespaces().withName(managedNamespace).get() ? : continue
133+ try {
134+ stableClient.namespaces().resource(ns).delete()
135+ } catch (_: KubernetesClientException ) {
136+ // this namespace is probably all being deleted
137+ } catch (_: RejectedExecutionException ) {
138+ // ignore error as long as ns get deleted
139+ } catch (_: InterruptedException ) {
140+ // ignore error as long as ns get deleted
141+ }
137142 delay(1000 )
138143 }
139- }
144+ } while (managedNamespaces.any { stableClient.namespaces().withName(it).get() != null })
140145 }
141146
142- private suspend fun deleteCRD (client : DefaultKubernetesClient ) {
147+ private suspend fun deleteCRD () {
143148 val crd = stableClient.apiextensions().v1().customResourceDefinitions().load(this .javaClass.getResource(" /crd.yaml" )).get()
144149 stableClient.apiextensions().v1().customResourceDefinitions().delete(crd)
145150 delay(2000 )
0 commit comments