feat: improve API keys and build workflows
This commit is contained in:
@@ -887,18 +887,42 @@ export class KubernetesBuildOperations implements BuildKubernetesOperations {
|
||||
(condition) =>
|
||||
condition.type === "Complete" && condition.status === "True",
|
||||
);
|
||||
const phase = failed
|
||||
? "failed"
|
||||
: complete
|
||||
? "succeeded"
|
||||
: (job.status?.active ?? 0) > 0
|
||||
let phase: BuildJobObservation["phase"] = "queued";
|
||||
let podError: string | undefined;
|
||||
let containerStartedAt: string | undefined;
|
||||
if (!failed && !complete) {
|
||||
const pods = await this.core.listNamespacedPod({
|
||||
namespace,
|
||||
labelSelector: `job-name=${name}`,
|
||||
});
|
||||
const pod = pods.items
|
||||
.sort(
|
||||
(a, b) =>
|
||||
(a.metadata?.creationTimestamp?.getTime() ?? 0) -
|
||||
(b.metadata?.creationTimestamp?.getTime() ?? 0),
|
||||
)
|
||||
.at(-1);
|
||||
const container = pod?.status?.containerStatuses?.find(
|
||||
(entry) => entry.name === "buildkit",
|
||||
);
|
||||
phase =
|
||||
pod?.status?.phase === "Running" && container?.state?.running
|
||||
? "running"
|
||||
: "queued";
|
||||
: !pod || !pod.spec?.nodeName
|
||||
? "creating"
|
||||
: "starting";
|
||||
podError =
|
||||
container?.state?.terminated?.message ??
|
||||
container?.state?.waiting?.message;
|
||||
containerStartedAt = container?.state?.running?.startedAt?.toISOString();
|
||||
} else phase = failed ? "failed" : "succeeded";
|
||||
return {
|
||||
phase,
|
||||
startedAt: job.status?.startTime?.toISOString(),
|
||||
startedAt: phase === "running" ? containerStartedAt : undefined,
|
||||
finishedAt: job.status?.completionTime?.toISOString(),
|
||||
...(failed?.message && { error: failed.message }),
|
||||
...((failed?.message || podError) && {
|
||||
error: failed?.message ?? podError,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user