Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Log pod state if init pod wait condition times out (for debugging tra…
Browse files Browse the repository at this point in the history
…nsient test issue) (airbytehq#10639)

* log pod state if init pod search times out

* increase test timeout from 5 to 6 minutes to give kube pod process timeout time to trigger

* format
  • Loading branch information
pmossman authored Feb 24, 2022
1 parent def938a commit 2157b47
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.fabric8.kubernetes.api.model.VolumeMount;
import io.fabric8.kubernetes.api.model.VolumeMountBuilder;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.dsl.PodResource;
import io.fabric8.kubernetes.client.internal.readiness.Readiness;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -300,8 +301,18 @@ public static void copyFilesToKubeConfigVolume(final KubernetesClient client,
*/
private static void waitForInitPodToRun(final KubernetesClient client, final Pod podDefinition) throws InterruptedException {
LOGGER.info("Waiting for init container to be ready before copying files...");
client.pods().inNamespace(podDefinition.getMetadata().getNamespace()).withName(podDefinition.getMetadata().getName())
.waitUntilCondition(p -> p.getStatus().getInitContainerStatuses().size() != 0, 5, TimeUnit.MINUTES);
final PodResource<Pod> pod =
client.pods().inNamespace(podDefinition.getMetadata().getNamespace()).withName(podDefinition.getMetadata().getName());
try {
pod.waitUntilCondition(p -> p.getStatus().getInitContainerStatuses().size() != 0, 5, TimeUnit.MINUTES);
} catch (InterruptedException e) {
LOGGER.error("Init pod not found after 5 minutes");
LOGGER.error("Pod search executed in namespace {} for pod name {} resulted in: {}",
podDefinition.getMetadata().getNamespace(),
podDefinition.getMetadata().getName(),
pod.get().toString());
throw e;
}
LOGGER.info("Init container present..");
client.pods().inNamespace(podDefinition.getMetadata().getNamespace()).withName(podDefinition.getMetadata().getName())
.waitUntilCondition(p -> p.getStatus().getInitContainerStatuses().get(0).getState().getRunning() != null, 5, TimeUnit.MINUTES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
// requires kube running locally to run. If using Minikube it requires MINIKUBE=true
// Must have a timeout on this class because it tests child processes that may misbehave; otherwise
// this can hang forever during failures.
@Timeout(value = 5,
@Timeout(value = 6,
unit = TimeUnit.MINUTES)
public class KubePodProcessIntegrationTest {

Expand Down

0 comments on commit 2157b47

Please sign in to comment.