Wait for PVC phase change after Job created
parent
1b24f65522
commit
09ed77c94a
|
|
@ -735,7 +735,6 @@ const client_node_1 = __webpack_require__(89679);
|
|||
const stream_1 = __webpack_require__(92413);
|
||||
const async_wait_until_1 = __webpack_require__(41299);
|
||||
const base64 = __webpack_require__(85848);
|
||||
const pollInterval = 20000;
|
||||
class Kubernetes {
|
||||
constructor(buildParameters, baseImage) {
|
||||
this.buildId = '';
|
||||
|
|
@ -865,7 +864,6 @@ class Kubernetes {
|
|||
};
|
||||
yield this.kubeClient.createNamespacedPersistentVolumeClaim(this.namespace, pvc);
|
||||
core.info(`Persistent Volume created, ${yield this.getPVCPhase()}`);
|
||||
yield async_wait_until_1.waitUntil(() => __awaiter(this, void 0, void 0, function* () { return (yield this.getPVCPhase()) !== 'Pending'; }));
|
||||
});
|
||||
}
|
||||
getJobSpec(command, image) {
|
||||
|
|
@ -1001,7 +999,7 @@ class Kubernetes {
|
|||
core.info('Creating build job');
|
||||
yield this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
|
||||
core.info('Job created');
|
||||
// await this.watchPersistentVolumeClaimUntilBoundToContainer();
|
||||
yield this.watchPersistentVolumeClaimUntilBoundToContainer();
|
||||
core.info('PVC Bound');
|
||||
this.setPodNameAndContainerName(yield this.getPod());
|
||||
core.info('Watching pod and streaming logs');
|
||||
|
|
@ -1069,16 +1067,8 @@ class Kubernetes {
|
|||
});
|
||||
}
|
||||
watchPersistentVolumeClaimUntilBoundToContainer() {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield new Promise((resolve) => setTimeout(resolve, pollInterval));
|
||||
const queryResult = yield this.kubeClient.readNamespacedPersistentVolumeClaim(this.pvcName, this.namespace);
|
||||
if (((_a = queryResult.body.status) === null || _a === void 0 ? void 0 : _a.phase) === 'Pending') {
|
||||
yield this.watchPersistentVolumeClaimUntilBoundToContainer();
|
||||
}
|
||||
else {
|
||||
core.info('Persistent Volume ready for claims');
|
||||
}
|
||||
yield async_wait_until_1.waitUntil(() => __awaiter(this, void 0, void 0, function* () { return (yield this.getPVCPhase()) !== 'Pending'; }));
|
||||
});
|
||||
}
|
||||
getPodStatusPhase() {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -9,8 +9,6 @@ import { waitUntil } from 'async-wait-until';
|
|||
|
||||
const base64 = require('base-64');
|
||||
|
||||
const pollInterval = 20000;
|
||||
|
||||
class Kubernetes implements RemoteBuilderProviderInterface {
|
||||
private kubeConfig: KubeConfig;
|
||||
private kubeClient: k8s.CoreV1Api;
|
||||
|
|
@ -149,7 +147,6 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
|||
};
|
||||
await this.kubeClient.createNamespacedPersistentVolumeClaim(this.namespace, pvc);
|
||||
core.info(`Persistent Volume created, ${await this.getPVCPhase()}`);
|
||||
await waitUntil(async () => (await this.getPVCPhase()) !== 'Pending');
|
||||
}
|
||||
|
||||
getJobSpec(command: string[], image: string) {
|
||||
|
|
@ -285,7 +282,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
|||
core.info('Creating build job');
|
||||
await this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
|
||||
core.info('Job created');
|
||||
// await this.watchPersistentVolumeClaimUntilBoundToContainer();
|
||||
await this.watchPersistentVolumeClaimUntilBoundToContainer();
|
||||
core.info('PVC Bound');
|
||||
this.setPodNameAndContainerName(await this.getPod());
|
||||
core.info('Watching pod and streaming logs');
|
||||
|
|
@ -356,14 +353,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
|||
}
|
||||
|
||||
async watchPersistentVolumeClaimUntilBoundToContainer() {
|
||||
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
||||
const queryResult = await this.kubeClient.readNamespacedPersistentVolumeClaim(this.pvcName, this.namespace);
|
||||
|
||||
if (queryResult.body.status?.phase === 'Pending') {
|
||||
await this.watchPersistentVolumeClaimUntilBoundToContainer();
|
||||
} else {
|
||||
core.info('Persistent Volume ready for claims');
|
||||
}
|
||||
await waitUntil(async () => (await this.getPVCPhase()) !== 'Pending');
|
||||
}
|
||||
|
||||
async getPodStatusPhase() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue