Skip to content

Commit

Permalink
Log cause when cluster role creation fails, increase additional timeouts
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Edgar <medgar@redhat.com>
  • Loading branch information
MikeEdgar committed Jan 8, 2024
1 parent 281ef4a commit 284547c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ private static Future<Void> leaderElection(KubernetesClient client, ClusterOpera
Future.all(futures).onComplete(res -> {
if (res.succeeded()) {
returnPromise.complete();
} else {
} else {
LOGGER.error("Failed to create Cluster Roles.", res.cause());
returnPromise.fail("Failed to create Cluster Roles.");
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,16 @@ public void testPodCreationDeletionAndRecreation(VertxTestContext context) {
// Delete the PodSet
podSetOp().inNamespace(NAMESPACE).withName(podSetName).delete();

// Check that pod is deleted after pod set deletion
/*
* Check that pod is deleted after pod set deletion
*
* The CR finalizer removal does not complete in a consistent amount of time,
* therefore the timeout for waiting on the deletion is increased to 1 minute.
*/
TestUtils.waitFor(
"Wait for Pod to be deleted",
100,
10_000,
60_000,
() -> client.pods().inNamespace(NAMESPACE).withName(podName).get() == null,
() -> context.failNow("Test timed out waiting for pod deletion!"));

Expand Down Expand Up @@ -655,11 +660,16 @@ public void testNonCascadingDeletion(VertxTestContext context) {
// Delete the PodSet in non-cascading way
podSetOp().inNamespace(NAMESPACE).withName(podSetName).withPropagationPolicy(DeletionPropagation.ORPHAN).delete();

// Check that the PodSet is deleted
/*
* Check that the PodSet is deleted
*
* The CR finalizer removal does not complete in a consistent amount of time,
* therefore the timeout for waiting on the deletion is increased to 1 minute.
*/
TestUtils.waitFor(
"Wait for StrimziPodSet deletion",
100,
10_000,
60_000,
() -> {
StrimziPodSet podSet = podSetOp().inNamespace(NAMESPACE).withName(podSetName).get();
return podSet == null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.strimzi.test.TestUtils;
import io.vertx.core.Promise;
import io.vertx.junit5.Checkpoint;
import io.vertx.junit5.Timeout;
import io.vertx.junit5.VertxExtension;
import io.vertx.junit5.VertxTestContext;
import org.apache.logging.log4j.LogManager;
Expand All @@ -28,6 +29,7 @@
import org.junit.jupiter.api.extension.ExtendWith;

import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import static org.hamcrest.CoreMatchers.instanceOf;
Expand Down Expand Up @@ -190,11 +192,15 @@ public void testUpdateStatus(VertxTestContext context) {
}

/**
* Tests what happens when the resource is deleted while updating the status
* Tests what happens when the resource is deleted while updating the status.
*
* @param context Test context
* The CR removal does not consistently complete within the default timeout.
* This requires increasing the timeout for completion to 1 minute.
*
* @param context Test context
*/
@Test
@Timeout(value = 1, timeUnit = TimeUnit.MINUTES)
public void testUpdateStatusAfterResourceDeletedThrowsKubernetesClientException(VertxTestContext context) {
String resourceName = getResourceName(RESOURCE_NAME);
Checkpoint async = context.checkpoint();
Expand All @@ -215,10 +221,6 @@ public void testUpdateStatusAfterResourceDeletedThrowsKubernetesClientException(
return op.reconcile(Reconciliation.DUMMY_RECONCILIATION, namespace, resourceName, null);
})
.onComplete(context.succeeding(i -> { }))
.compose(i -> {
LOGGER.info("Wait for confirmed deletion");
return op.waitFor(Reconciliation.DUMMY_RECONCILIATION, namespace, resourceName, 100L, 10_000L, (n, ns) -> operator().get(namespace, resourceName) == null);
})
.compose(i -> {
LOGGER.info("Updating resource with new status - should fail");
return op.updateStatusAsync(Reconciliation.DUMMY_RECONCILIATION, newStatus.get());
Expand Down

0 comments on commit 284547c

Please sign in to comment.