Run build with input commands
parent
821b9eeddf
commit
fce88635b8
|
|
@ -1005,27 +1005,26 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static watchPodUntilReadyAndRead(statusFilter) {
|
static watchPodUntilRunningAndRead() {
|
||||||
var _a, _b, _c;
|
var _a, _b;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let ready = false;
|
let ready = false;
|
||||||
while (!ready) {
|
while (!ready) {
|
||||||
yield new Promise((resolve) => setTimeout(resolve, pollInterval));
|
yield new Promise((resolve) => setTimeout(resolve, pollInterval));
|
||||||
const pods = yield this.kubeClient.listNamespacedPod(this.namespace);
|
const pod = (_a = (yield this.kubeClient.readNamespacedPod(this.name, this.namespace))) === null || _a === void 0 ? void 0 : _a.body;
|
||||||
for (let index = 0; index < pods.body.items.length; index++) {
|
if (pod === undefined) {
|
||||||
const element = pods.body.items[index];
|
throw new Error('no pod found');
|
||||||
const jobname = (_b = (_a = element.metadata) === null || _a === void 0 ? void 0 : _a.labels) === null || _b === void 0 ? void 0 : _b['job-name'];
|
}
|
||||||
const phase = (_c = element.status) === null || _c === void 0 ? void 0 : _c.phase;
|
const phase = (_b = pod.status) === null || _b === void 0 ? void 0 : _b.phase;
|
||||||
if (jobname === this.jobName && phase !== statusFilter) {
|
if (phase === 'Running') {
|
||||||
core.info('Pod no longer pending');
|
core.info('Pod no longer pending');
|
||||||
if (phase === 'Failure') {
|
}
|
||||||
core.error('Kubernetes job failed');
|
if (phase !== 'Pending') {
|
||||||
}
|
core.error('Kubernetes job failed');
|
||||||
else {
|
}
|
||||||
ready = true;
|
else {
|
||||||
return element;
|
ready = true;
|
||||||
}
|
return pod;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -1034,9 +1033,9 @@ class Kubernetes {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const pod = (yield Kubernetes.watchPodUntilReadyAndRead('Pending')) || {};
|
const pod = yield Kubernetes.watchPodUntilRunningAndRead();
|
||||||
core.info(`Watching build job ${(_a = pod.metadata) === null || _a === void 0 ? void 0 : _a.name}`);
|
core.info(`Watching build job ${(_a = pod === null || pod === void 0 ? void 0 : pod.metadata) === null || _a === void 0 ? void 0 : _a.name}`);
|
||||||
yield Kubernetes.streamLogs(((_b = pod.metadata) === null || _b === void 0 ? void 0 : _b.name) || '', this.namespace);
|
yield Kubernetes.streamLogs(((_b = pod === null || pod === void 0 ? void 0 : pod.metadata) === null || _b === void 0 ? void 0 : _b.name) || '', this.namespace);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.error('Failed while watching build job');
|
core.error('Failed while watching build job');
|
||||||
|
|
@ -1092,6 +1091,7 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
static cleanup() {
|
static cleanup() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
core.info('cleaning up');
|
||||||
yield this.kubeClientBatch.deleteNamespacedJob(this.jobName, this.namespace);
|
yield this.kubeClientBatch.deleteNamespacedJob(this.jobName, this.namespace);
|
||||||
yield this.kubeClient.deletePersistentVolume(this.pvcName, this.namespace);
|
yield this.kubeClient.deletePersistentVolume(this.pvcName, this.namespace);
|
||||||
yield this.kubeClient.deleteNamespacedSecret(this.secretName, this.namespace);
|
yield this.kubeClient.deleteNamespacedSecret(this.secretName, this.namespace);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -292,34 +292,33 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async watchPodUntilReadyAndRead(statusFilter: string) {
|
static async watchPodUntilRunningAndRead() {
|
||||||
let ready = false;
|
let ready = false;
|
||||||
|
|
||||||
while (!ready) {
|
while (!ready) {
|
||||||
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
||||||
const pods = await this.kubeClient.listNamespacedPod(this.namespace);
|
const pod = (await this.kubeClient.readNamespacedPod(this.name, this.namespace))?.body;
|
||||||
for (let index = 0; index < pods.body.items.length; index++) {
|
if (pod === undefined) {
|
||||||
const element = pods.body.items[index];
|
throw new Error('no pod found');
|
||||||
const jobname = element.metadata?.labels?.['job-name'];
|
}
|
||||||
const phase = element.status?.phase;
|
const phase = pod.status?.phase;
|
||||||
if (jobname === this.jobName && phase !== statusFilter) {
|
if (phase === 'Running') {
|
||||||
core.info('Pod no longer pending');
|
core.info('Pod no longer pending');
|
||||||
if (phase === 'Failure') {
|
}
|
||||||
core.error('Kubernetes job failed');
|
if (phase !== 'Pending') {
|
||||||
} else {
|
core.error('Kubernetes job failed');
|
||||||
ready = true;
|
} else {
|
||||||
return element;
|
ready = true;
|
||||||
}
|
return pod;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async watchBuildJobUntilFinished() {
|
static async watchBuildJobUntilFinished() {
|
||||||
try {
|
try {
|
||||||
const pod = (await Kubernetes.watchPodUntilReadyAndRead('Pending')) || {};
|
const pod = await Kubernetes.watchPodUntilRunningAndRead();
|
||||||
core.info(`Watching build job ${pod.metadata?.name}`);
|
core.info(`Watching build job ${pod?.metadata?.name}`);
|
||||||
await Kubernetes.streamLogs(pod.metadata?.name || '', this.namespace);
|
await Kubernetes.streamLogs(pod?.metadata?.name || '', this.namespace);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.error('Failed while watching build job');
|
core.error('Failed while watching build job');
|
||||||
throw error;
|
throw error;
|
||||||
|
|
@ -380,6 +379,7 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
|
|
||||||
static async cleanup() {
|
static async cleanup() {
|
||||||
|
core.info('cleaning up');
|
||||||
await this.kubeClientBatch.deleteNamespacedJob(this.jobName, this.namespace);
|
await this.kubeClientBatch.deleteNamespacedJob(this.jobName, this.namespace);
|
||||||
await this.kubeClient.deletePersistentVolume(this.pvcName, this.namespace);
|
await this.kubeClient.deletePersistentVolume(this.pvcName, this.namespace);
|
||||||
await this.kubeClient.deleteNamespacedSecret(this.secretName, this.namespace);
|
await this.kubeClient.deleteNamespacedSecret(this.secretName, this.namespace);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue