task: adding more diagnostics for remote failed runs (#27441)
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
This commit is contained in:
parent
6609b591e1
commit
ffc1b69afa
1 changed files with 14 additions and 6 deletions
|
@ -321,7 +321,7 @@ public class BaseOperatorTest implements QuarkusTestAfterEachCallback {
|
||||||
// provide some helpful entries in the main log as well
|
// provide some helpful entries in the main log as well
|
||||||
logFailedKeycloaks();
|
logFailedKeycloaks();
|
||||||
if (operatorDeployment == OperatorDeployment.remote) {
|
if (operatorDeployment == OperatorDeployment.remote) {
|
||||||
logFailed(k8sclient.apps().deployments().withName("keycloak-operator"), Deployment::getStatus);
|
log(k8sclient.apps().deployments().withName("keycloak-operator"), Deployment::getStatus, false);
|
||||||
}
|
}
|
||||||
logFailed(k8sclient.apps().statefulSets().withName(POSTGRESQL_NAME), StatefulSet::getStatus);
|
logFailed(k8sclient.apps().statefulSets().withName(POSTGRESQL_NAME), StatefulSet::getStatus);
|
||||||
k8sclient.pods().withLabel("app", "keycloak-realm-import").list().getItems().stream()
|
k8sclient.pods().withLabel("app", "keycloak-realm-import").list().getItems().stream()
|
||||||
|
@ -331,16 +331,20 @@ public class BaseOperatorTest implements QuarkusTestAfterEachCallback {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T extends HasMetadata, R extends Resource<T> & Loggable> void logFailed(R resource, Function<T, Object> statusExtractor) {
|
private <T extends HasMetadata, R extends Resource<T> & Loggable> void log(R resource, Function<T, Object> statusExtractor, boolean failedOnly) {
|
||||||
var instance = resource.get();
|
var instance = resource.get();
|
||||||
if (resource.isReady()) {
|
if (failedOnly) {
|
||||||
return;
|
if (resource.isReady()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log.warnf("%s failed to become ready %s", instance.getMetadata().getName(), Serialization.asYaml(statusExtractor.apply(instance)));
|
||||||
|
} else {
|
||||||
|
Log.infof("%s is ready %s", instance.getMetadata().getName(), Serialization.asYaml(statusExtractor.apply(instance)));
|
||||||
}
|
}
|
||||||
Log.warnf("%s failed to become ready %s", instance.getMetadata().getName(), Serialization.asYaml(statusExtractor.apply(instance)));
|
|
||||||
try {
|
try {
|
||||||
String log = resource.getLog();
|
String log = resource.getLog();
|
||||||
log = log.substring(Math.max(0, log.length() - 5000));
|
log = log.substring(Math.max(0, log.length() - 5000));
|
||||||
Log.warnf("%s not ready log: %s", instance.getMetadata().getName(), log);
|
Log.warnf("%s log: %s", instance.getMetadata().getName(), log);
|
||||||
} catch (KubernetesClientException e) {
|
} catch (KubernetesClientException e) {
|
||||||
Log.warnf("No %s log: %s", instance.getMetadata().getName(), e.getMessage());
|
Log.warnf("No %s log: %s", instance.getMetadata().getName(), e.getMessage());
|
||||||
if (instance instanceof Pod) {
|
if (instance instanceof Pod) {
|
||||||
|
@ -357,6 +361,10 @@ public class BaseOperatorTest implements QuarkusTestAfterEachCallback {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private <T extends HasMetadata, R extends Resource<T> & Loggable> void logFailed(R resource, Function<T, Object> statusExtractor) {
|
||||||
|
log(resource, statusExtractor, true);
|
||||||
|
}
|
||||||
|
|
||||||
private void logFailedKeycloaks() {
|
private void logFailedKeycloaks() {
|
||||||
k8sclient.resources(Keycloak.class).list().getItems().stream()
|
k8sclient.resources(Keycloak.class).list().getItems().stream()
|
||||||
.filter(kc -> !Optional.ofNullable(kc.getStatus()).map(KeycloakStatus::isReady).orElse(false))
|
.filter(kc -> !Optional.ofNullable(kc.getStatus()).map(KeycloakStatus::isReady).orElse(false))
|
||||||
|
|
Loading…
Reference in a new issue