Skip to content

Commit f27e321

Browse files
committed
Merge branch 'diagnose-owls-121733' into 'main'
Generate correct introspection timeout log even if introspection failure is detected while looking at the job rather than the job pod See merge request weblogic-cloud/weblogic-kubernetes-operator!4926
2 parents 74c63d6 + 14f1441 commit f27e321

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

operator/src/main/java/oracle/kubernetes/operator/helpers/JobHelper.java

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// Copyright (c) 2018, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2018, 2025, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.operator.helpers;
55

66
import java.time.OffsetDateTime;
7+
import java.time.temporal.ChronoUnit;
78
import java.util.ArrayList;
89
import java.util.Collection;
910
import java.util.Collections;
@@ -60,6 +61,7 @@
6061
import static oracle.kubernetes.common.logging.MessageKeys.INTROSPECTOR_FLUENTD_CONTAINER_TERMINATED;
6162
import static oracle.kubernetes.common.logging.MessageKeys.INTROSPECTOR_JOB_FAILED;
6263
import static oracle.kubernetes.common.logging.MessageKeys.INTROSPECTOR_JOB_FAILED_DETAIL;
64+
import static oracle.kubernetes.common.logging.MessageKeys.JOB_DEADLINE_EXCEEDED_MESSAGE;
6365
import static oracle.kubernetes.operator.DomainSourceType.FROM_MODEL;
6466
import static oracle.kubernetes.operator.DomainStatusUpdater.createIntrospectionFailureSteps;
6567
import static oracle.kubernetes.operator.DomainStatusUpdater.createRemoveFailuresStep;
@@ -208,6 +210,18 @@ private static class IntrospectionStartStep extends Step {
208210

209211
}
210212

213+
private static boolean isJobPodTimedOut(V1Pod jobPod) {
214+
return "DeadlineExceeded".equals(getJobPodStatusReason(jobPod));
215+
}
216+
217+
private static String getJobPodStatusReason(V1Pod jobPod) {
218+
return Optional.ofNullable(jobPod.getStatus()).map(V1PodStatus::getReason).orElse(null);
219+
}
220+
221+
private static boolean isJobTimedOut(V1Job job) {
222+
return "DeadlineExceeded".equals(JobWatcher.getFailedReason(job));
223+
}
224+
211225
private static class IntrospectorJobStepContext extends JobStepContext {
212226

213227
IntrospectorJobStepContext(Packet packet) {
@@ -861,14 +875,6 @@ protected Throwable createTerminationException(Packet packet) {
861875
return new JobWatcher.DeadlineExceededException((V1Job) packet.get(DOMAIN_INTROSPECTOR_JOB));
862876
}
863877

864-
private boolean isJobPodTimedOut(V1Pod jobPod) {
865-
return "DeadlineExceeded".equals(getJobPodStatusReason(jobPod));
866-
}
867-
868-
private String getJobPodStatusReason(V1Pod jobPod) {
869-
return Optional.ofNullable(jobPod.getStatus()).map(V1PodStatus::getReason).orElse(null);
870-
}
871-
872878
private Step createIntrospectorConfigMap() {
873879
return ConfigMapHelper.createIntrospectorConfigMapStep(null);
874880
}
@@ -955,7 +961,21 @@ private static void logIntrospectorFailure(Packet packet, V1Job domainIntrospect
955961
domainIntrospectorJob.getMetadata().getNamespace(),
956962
domainIntrospectorJob.getMetadata().getName(),
957963
domainIntrospectorJob.toString());
964+
if (isJobTimedOut(domainIntrospectorJob) || (jobPod != null && isJobPodTimedOut(jobPod))) {
965+
LOGGER.info(JOB_DEADLINE_EXCEEDED_MESSAGE,
966+
Optional.of(domainIntrospectorJob).map(V1Job::getMetadata).map(V1ObjectMeta::getName).orElse(""),
967+
Optional.of(domainIntrospectorJob).map(V1Job::getSpec)
968+
.map(V1JobSpec::getActiveDeadlineSeconds).map(Object::toString).orElse(""),
969+
getJobStartedSeconds(domainIntrospectorJob));
970+
}
971+
}
972+
}
973+
974+
private static long getJobStartedSeconds(V1Job job) {
975+
if (job.getStatus() != null && job.getStatus().getStartTime() != null) {
976+
return ChronoUnit.SECONDS.between(job.getStatus().getStartTime(), SystemClock.now());
958977
}
978+
return -1;
959979
}
960980

961981
private static String getName(V1Pod pod) {

operator/src/main/java/oracle/kubernetes/operator/watcher/JobWatcher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2018, 2025, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.operator.watcher;
@@ -230,7 +230,7 @@ public String toString() {
230230
MessageKeys.JOB_DEADLINE_EXCEEDED_MESSAGE,
231231
Optional.ofNullable(job).map(V1Job::getMetadata).map(V1ObjectMeta::getName).orElse(""),
232232
Optional.ofNullable(job).map(V1Job::getSpec)
233-
.map(V1JobSpec::getActiveDeadlineSeconds).map(l -> l.toString()).orElse(""),
233+
.map(V1JobSpec::getActiveDeadlineSeconds).map(Object::toString).orElse(""),
234234
getJobStartedSeconds());
235235
}
236236

0 commit comments

Comments
 (0)