Skip to content

Commit

Permalink
Address comments v1
Browse files Browse the repository at this point in the history
Signed-off-by: David Kornel <[email protected]>
  • Loading branch information
kornys committed Oct 22, 2024
1 parent 4406644 commit 596a464
Showing 1 changed file with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,26 +419,10 @@ public final <T extends HasMetadata> void deleteResource(boolean async, T... res
try {
if (type == null) {
client.getClient().resource(resource).delete();
CompletableFuture<Void> c = CompletableFuture.runAsync(() ->
assertTrue(waitResourceCondition(resource, ResourceCondition.deletion()),
String.format("Timed out deleting %s/%s in %s", resource.getKind(),
resource.getMetadata().getName(), resource.getMetadata().getNamespace())));
if (async) {
waitExecutors.add(c);
} else {
CompletableFuture.allOf(c).join();
}
decideDeleteWaitAsync(waitExecutors, async, resource);
} else {
type.delete(resource);
CompletableFuture<Void> c = CompletableFuture.runAsync(() ->
assertTrue(waitResourceCondition(resource, ResourceCondition.deletion()),
String.format("Timed out deleting %s/%s in %s", resource.getKind(),
resource.getMetadata().getName(), resource.getMetadata().getNamespace())));
if (async) {
waitExecutors.add(c);
} else {
CompletableFuture.allOf(c).join();
}
decideDeleteWaitAsync(waitExecutors, async, resource);
}
} catch (Exception e) {
if (resource.getMetadata().getNamespace() == null) {
Expand Down Expand Up @@ -621,4 +605,17 @@ private void writeResourceAsYaml(HasMetadata resource) {
throw new RuntimeException(e);
}
}

private <T extends HasMetadata> void decideDeleteWaitAsync(List<CompletableFuture<Void>> waitExecutors,
boolean async, T resource) {
CompletableFuture<Void> c = CompletableFuture.runAsync(() ->
assertTrue(waitResourceCondition(resource, ResourceCondition.deletion()),
String.format("Timed out deleting %s/%s in %s", resource.getKind(),
resource.getMetadata().getName(), resource.getMetadata().getNamespace())));
if (async) {
waitExecutors.add(c);
} else {
CompletableFuture.allOf(c).join();
}
}
}

0 comments on commit 596a464

Please sign in to comment.