From a489144c5aa4b48bf54275c723d5e281fa9e8150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TATSUNO=20=E2=80=9CTaz=E2=80=9D=20Yasuhiro?= Date: Sat, 7 Nov 2026 07:57:20 +0900 Subject: [PATCH] test(eks): log pod and k3s state when the registry-hosts pod does not run (#7661) --- ...EksRegistryHostsDockerIntegrationTest.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/test/java/io/floci/aws/services/eks/EksRegistryHostsDockerIntegrationTest.java b/src/test/java/io/floci/aws/services/eks/EksRegistryHostsDockerIntegrationTest.java index 247d7ed419..5d9517f281 100644 --- a/src/test/java/io/floci/aws/services/eks/EksRegistryHostsDockerIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/eks/EksRegistryHostsDockerIntegrationTest.java @@ -1,6 +1,8 @@ package io.floci.aws.services.eks; import com.github.dockerjava.api.DockerClient; +import com.github.dockerjava.api.async.ResultCallback; +import com.github.dockerjava.api.model.Frame; import io.floci.aws.core.common.Digests; import io.floci.aws.core.common.docker.ContainerExec; import io.floci.aws.core.common.docker.DockerHostResolver; @@ -249,10 +251,61 @@ class EksRegistryHostsDockerIntegrationTest { } Thread.sleep(2000); } + if (!running) { + logPodDiagnostics(containerId); + } assertTrue(running, "registry-hosts-pod must reach Running, pulling its image through the configured host"); execInContainerWithExitCode(containerId, new String[]{"kubectl", "delete", "pod", "registry-hosts-pod", "--now"}); } + /** Cleanup removes the k3s container, and kubelet's output reaches nothing else. */ + private void logPodDiagnostics(String containerId) { + String[][] commands = { + {"kubectl", "describe", "pod", "registry-hosts-pod"}, + {"kubectl", "describe", "nodes"}, + {"kubectl", "get", "pods", "-A", "-o", "wide"}, + {"crictl", "images"}, + {"cat", "/run/flannel/subnet.env"}, + // An unassigned pod on a Ready node points at the cloud controller, whose role k3s installs as an addon. + {"kubectl", "get", "crd", "addons.k3s.cattle.io", "-o", "json"}, + {"kubectl", "get", "clusterrole/k3s-cloud-controller-manager", + "clusterrolebinding/k3s-cloud-controller-manager", "-o", "json"} + }; + for (String[] command : commands) { + try { + ContainerExec.Result result = ContainerExec.run(dockerClient, containerId, command, 10); + LOG.warnv("{0}\n{1}", String.join(" ", command), result.summary()); + } catch (RuntimeException e) { + LOG.warnv(e, "Could not run {0}", String.join(" ", command)); + } + } + LOG.warnv("k3s log tail\n{0}", k3sLogTail(containerId)); + } + + private String k3sLogTail(String containerId) { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + String problem = ""; + try { + boolean completed = dockerClient.logContainerCmd(containerId).withStdOut(true).withStdErr(true) + .withTail(2000) + .exec(new ResultCallback.Adapter() { + @Override + public void onNext(Frame frame) { + out.writeBytes(frame.getPayload()); + } + }).awaitCompletion(10, TimeUnit.SECONDS); + if (!completed) { + problem = "(timed out reading logs)"; + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + problem = "(interrupted while reading logs)"; + } catch (Exception e) { + problem = "(could not read logs: " + e.getMessage() + ")"; + } + return out.toString(StandardCharsets.UTF_8) + problem; + } + /** * Pushes a minimal, genuinely pullable image via raw OCI Distribution calls against Floci's * ECR data plane. The image contains a tiny static executable at {@code /bin/sleep} so kubelet