Skip to content

Commit cfc47a7

Browse files
committed
fix infra resource deletion
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent fce47b6 commit cfc47a7

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

operator-framework-junit/src/main/java/io/javaoperatorsdk/operator/junit/AbstractOperatorExtension.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -204,23 +204,22 @@ protected void after(ExtensionContext context) {
204204
if (namespace != null) {
205205
if (preserveNamespaceOnError && context.getExecutionException().isPresent()) {
206206
LOGGER.info("Preserving namespace {}", namespace);
207-
} else if (skipNamespaceDeletion) {
208-
LOGGER.info("Skipping namespace deletion for {}", namespace);
209-
deleteOperator();
210207
} else {
211208
infrastructureKubernetesClient.resourceList(infrastructure).delete();
212209
deleteOperator();
213-
LOGGER.info("Deleting namespace {} and stopping operator", namespace);
214-
infrastructureKubernetesClient.namespaces().withName(namespace).delete();
215-
if (waitForNamespaceDeletion) {
216-
LOGGER.info("Waiting for namespace {} to be deleted", namespace);
217-
Awaitility.await("namespace deleted")
218-
.pollInterval(50, TimeUnit.MILLISECONDS)
219-
.atMost(namespaceDeleteTimeout, TimeUnit.SECONDS)
220-
.until(
221-
() ->
222-
infrastructureKubernetesClient.namespaces().withName(namespace).get()
223-
== null);
210+
if (skipNamespaceDeletion) {
211+
LOGGER.info("Deleting namespace {} and stopping operator", namespace);
212+
infrastructureKubernetesClient.namespaces().withName(namespace).delete();
213+
if (waitForNamespaceDeletion) {
214+
LOGGER.info("Waiting for namespace {} to be deleted", namespace);
215+
Awaitility.await("namespace deleted")
216+
.pollInterval(50, TimeUnit.MILLISECONDS)
217+
.atMost(namespaceDeleteTimeout, TimeUnit.SECONDS)
218+
.until(
219+
() ->
220+
infrastructureKubernetesClient.namespaces().withName(namespace).get()
221+
== null);
222+
}
224223
}
225224
}
226225
}

0 commit comments

Comments
 (0)