Skip to content

Commit 4dcc634

Browse files
authored
bug: fix preivous job logs (#191)
1 parent fc190a9 commit 4dcc634

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

src/k8s/logging/logging.service.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,17 @@ export class LoggingService {
183183
return;
184184
}
185185

186-
if (isJob && pods.every((pod) => pod.status?.phase !== "Running")) {
186+
// Skip pod log fetching only when we have nothing useful to read from —
187+
// pods that never started (Pending) or are in an Unknown phase. Succeeded
188+
// and Failed pods still have container logs retained by K8s until
189+
// garbage collection, so we want those for finished match jobs.
190+
if (
191+
isJob &&
192+
pods.every((pod) => {
193+
const phase = pod.status?.phase;
194+
return phase === "Pending" || phase === "Unknown" || !phase;
195+
})
196+
) {
187197
if (download && archive) {
188198
void archive.finalize();
189199
return;
@@ -759,6 +769,14 @@ export class LoggingService {
759769
const diagnostics = await this.getJobBootDiagnostics(jobName);
760770
const syntheticPod = pod || diagnostics.pod;
761771

772+
// Job and pod have been cleaned up and no K8s events remain — the match
773+
// is finished and its server resources are gone. Don't fabricate a
774+
// "Waiting for Kubernetes…" fallback line; just return no synthetic logs
775+
// so the client renders the empty state.
776+
if (!diagnostics.job && !syntheticPod && diagnostics.events.length === 0) {
777+
return [];
778+
}
779+
762780
return buildSyntheticMatchServerLogEntries({
763781
diagnostic: diagnostics,
764782
events: diagnostics.events,

0 commit comments

Comments
 (0)