Skip to content

Commit

Permalink
Merge pull request #2385 from shreddedbacon/kubernetes-timer
Browse files Browse the repository at this point in the history
Use the lastTransitionTime for failed kubernetes build jobs
  • Loading branch information
Schnitzel authored Dec 11, 2020
2 parents a0a22cb + b0cdea9 commit c9012ed
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion services/kubernetesbuilddeploymonitor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,18 @@ ${podLog}`;
}
})(jobInfo.status.active ? 'active' : jobInfo.status.conditions[0].type.toLowerCase());

let completedTime = jobInfo.status.completionTime
if (status == 'failed') {
// failed jobs in kubernetes don't have a completionTime in them
// the status conditions will have a lastTransitionTime in them that will contain the state the job went into
// since jobs only have 1 attempt, there shouldn't be any other conditions
completedTime = jobInfo.status.conditions[0].lastTransitionTime
}

await updateDeployment(deployment.deploymentByRemoteId.id, {
status: status.toUpperCase(),
started: dateOrNull(jobInfo.status.startTime),
completed: dateOrNull(jobInfo.status.completionTime),
completed: dateOrNull(completedTime),
});
} catch (error) {
logger.error(`Could not update deployment ${projectName} ${jobName}. Message: ${error}`);
Expand Down

0 comments on commit c9012ed

Please sign in to comment.