Skip to content

Commit 9e31aee

Browse files
committed
More detailed error message for DeadlineExceededException
1 parent 80839b2 commit 9e31aee

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public NextAction apply(Packet packet) {
256256
// be available for reading
257257
if (isJobFailed && "DeadlineExceeded".equals(getFailedReason(job))) {
258258
fiber.terminate(
259-
new DeadlineExceededException(job.getMetadata().getName()), packet);
259+
new DeadlineExceededException(job), packet);
260260
}
261261
fiber.resume(packet);
262262
}
@@ -304,15 +304,37 @@ public NextAction onSuccess(
304304
}
305305

306306
static class DeadlineExceededException extends Exception {
307-
final String job;
307+
final V1Job job;
308308

309-
public DeadlineExceededException(String job) {
309+
public DeadlineExceededException(V1Job job) {
310310
super();
311311
this.job = job;
312312
}
313313

314314
public String toString() {
315-
return "Job " + job + " failed. Reason: DeadlineExceeded";
315+
StringBuilder sb = new StringBuilder("Job ")
316+
.append(job.getMetadata().getName()).append(" failed due to reason: DeadlineExceeded.")
317+
.append(" ActiveDeadlineSeconds of the job is configured with "
318+
+ job.getSpec().getActiveDeadlineSeconds()
319+
+ " seconds.")
320+
.append(getJobStartedSecondsMessage())
321+
.append(" Ensure all domain dependencies have been deployed")
322+
.append(" (any secrets, config-maps, PVs, and PVCs that the domain resource references).")
323+
.append(" Use kubectl describe the job and its pod for more job failure information.")
324+
.append(" The job may be retried by the operator up to "
325+
+ DomainPresence.getDomainPresenceFailureRetryMaxCount()
326+
+ " times with longer ActiveDeadlineSeconds value in each subsequent retry.")
327+
.append(" Use tuning parameter \"domainPresenceFailureRetryMaxCount\" to configure max retries.");
328+
return sb.toString();
329+
}
330+
331+
private String getJobStartedSecondsMessage() {
332+
if (job.getStatus() != null && job.getStatus().getStartTime() != null) {
333+
return " The job was started "
334+
+ ((System.currentTimeMillis() - job.getStatus().getStartTime().getMillis()) / 1000)
335+
+ " seconds ago.";
336+
}
337+
return null;
316338
}
317339
}
318340
}

0 commit comments

Comments
 (0)