fix: switching to clusterip service (#26975)

also adding the previous log when things fail

closes: #26790

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
This commit is contained in:
Steven Hawkins 2024-02-13 02:59:29 -05:00 committed by GitHub
parent 8d3d94f904
commit ee126f73e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View file

@ -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());
}
}
}
}
}

View file

@ -45,7 +45,6 @@ metadata:
spec:
selector:
app: postgresql-db
type: LoadBalancer
ports:
- port: 5432
targetPort: 5432