Skip to content
This repository was archived by the owner on Feb 13, 2026. It is now read-only.

Commit 0de9d63

Browse files
authored
Fix async deletion of stored resources in KRM (#303)
## Description Fix for async deletion issue of stored resources caused by implementation of multi kube context feature ## Type of Change Please delete options that are not relevant. * Bug fix (non-breaking change which fixes an issue) ## Checklist - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit/integration tests pass locally with my changes Signed-off-by: David Kornel <kornys@outlook.com>
1 parent 9e5924f commit 0de9d63

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

test-frame-common/src/main/java/io/skodjob/testframe/resources/KubeResourceManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -786,9 +786,9 @@ public void deleteResources(boolean async) {
786786
LOGGER.info("Deleting all resources for [{}]/{}", ctxId, testName);
787787
Stack<ResourceItem<?>> stack = byTest.get(testName);
788788
AtomicInteger count = new AtomicInteger(stack.size());
789+
List<CompletableFuture<Void>> waiters = new ArrayList<>();
789790
while (!stack.isEmpty()) {
790791
ResourceItem<?> item = stack.pop();
791-
List<CompletableFuture<Void>> waiters = new ArrayList<>();
792792
CompletableFuture<Void> cf = CompletableFuture.runAsync(() -> {
793793
try {
794794
item.throwableRunner().run();
@@ -803,9 +803,9 @@ public void deleteResources(boolean async) {
803803
}
804804
count.decrementAndGet();
805805
deleteCallbacks.forEach(cb -> Optional.ofNullable(item.resource()).ifPresent(cb));
806-
if (!waiters.isEmpty()) {
807-
CompletableFuture.allOf(waiters.toArray(new CompletableFuture[0])).join();
808-
}
806+
}
807+
if (!waiters.isEmpty()) {
808+
CompletableFuture.allOf(waiters.toArray(new CompletableFuture[0])).join();
809809
}
810810
byTest.remove(testName);
811811
if (byTest.isEmpty()) {

test-frame-test-examples/src/test/java/io/skodjob/testframe/test/integration/KubeResourceManagerCleanerIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import static org.junit.jupiter.api.Assertions.assertTrue;
2828

2929
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
30-
@ResourceManager(asyncDeletion = false)
30+
@ResourceManager(asyncDeletion = true)
3131
final class KubeResourceManagerCleanerIT extends AbstractIT {
3232

3333
@BeforeAll

0 commit comments

Comments
 (0)