From ee126f73e532baaabd8c82b94df8c70031ff650b Mon Sep 17 00:00:00 2001 From: Steven Hawkins Date: Tue, 13 Feb 2024 02:59:29 -0500 Subject: [PATCH] fix: switching to clusterip service (#26975) also adding the previous log when things fail closes: #26790 Signed-off-by: Steve Hawkins --- .../testsuite/integration/BaseOperatorTest.java | 12 ++++++++++++ operator/src/test/resources/example-postgres.yaml | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/operator/src/test/java/org/keycloak/operator/testsuite/integration/BaseOperatorTest.java b/operator/src/test/java/org/keycloak/operator/testsuite/integration/BaseOperatorTest.java index 5f58df0685..302c1e7c3d 100644 --- a/operator/src/test/java/org/keycloak/operator/testsuite/integration/BaseOperatorTest.java +++ b/operator/src/test/java/org/keycloak/operator/testsuite/integration/BaseOperatorTest.java @@ -70,6 +70,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileWriter; import java.lang.reflect.Method; +import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.time.Duration; @@ -342,6 +343,17 @@ public class BaseOperatorTest implements QuarkusTestAfterEachCallback { Log.warnf("%s not ready log: %s", instance.getMetadata().getName(), log); } catch (KubernetesClientException e) { Log.warnf("No %s log: %s", instance.getMetadata().getName(), e.getMessage()); + if (instance instanceof Pod) { + try { + String previous = k8sclient.raw(String.format("/api/v1/namespaces/%s/pods/%s/log?previous=true", namespace, instance.getMetadata().getName())); + Log.warnf("%s previous log: %s", instance.getMetadata().getName(), previous); + } catch (KubernetesClientException pe) { + // not available + if (pe.getCode() != HttpURLConnection.HTTP_BAD_REQUEST) { + Log.infof("Could not obtain previous log for %s: %s", instance.getMetadata().getName(), e.getMessage()); + } + } + } } } diff --git a/operator/src/test/resources/example-postgres.yaml b/operator/src/test/resources/example-postgres.yaml index 819b3042a4..fbcb52e89b 100644 --- a/operator/src/test/resources/example-postgres.yaml +++ b/operator/src/test/resources/example-postgres.yaml @@ -45,7 +45,6 @@ metadata: spec: selector: app: postgresql-db - type: LoadBalancer ports: - port: 5432 targetPort: 5432 \ No newline at end of file