Log PVC state

pull/273/head
Frostebite 2021-06-18 23:55:48 +01:00
parent dcb6b5241c
commit adf74e9bde
4 changed files with 10 additions and 19 deletions

10
dist/index.js vendored
View File

@ -1537,7 +1537,7 @@ class Kubernetes {
core.info('Creating build job');
yield this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
core.info('Job created');
yield kubernetes_storage_1.default.watchPersistentVolumeClaimUntilBoundToContainer(this.kubeClient, this.pvcName, this.namespace);
yield kubernetes_storage_1.default.watchUntilPVCNotPending(this.kubeClient, this.pvcName, this.namespace);
core.info('PVC Bound');
this.setPodNameAndContainerName(yield this.getPod());
core.info('Watching pod and streaming logs');
@ -1727,7 +1727,7 @@ class KubernetesStorage {
return (_a = (yield kubeClient.readNamespacedPersistentVolumeClaim(name, namespace)).body.status) === null || _a === void 0 ? void 0 : _a.phase;
});
}
static watchPersistentVolumeClaimUntilBoundToContainer(kubeClient, name, namespace) {
static watchUntilPVCNotPending(kubeClient, name, namespace) {
return __awaiter(this, void 0, void 0, function* () {
yield async_wait_until_1.default(() => __awaiter(this, void 0, void 0, function* () { return (yield this.getPVCPhase(kubeClient, name, namespace)) !== 'Pending'; }), {
timeout: 500000,
@ -1736,6 +1736,7 @@ class KubernetesStorage {
});
}
static createPersistentVolumeClaim(buildParameters, pvcName, kubeClient, namespace) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
if (buildParameters.kubeVolume) {
core.info(buildParameters.kubeVolume);
@ -1757,9 +1758,8 @@ class KubernetesStorage {
},
},
};
yield kubeClient.createNamespacedPersistentVolumeClaim(namespace, pvc);
core.info(`Persistent Volume Claim created`);
core.info(`PVC state: ${yield this.getPVCPhase(kubeClient, pvcName, namespace)}`);
const result = yield kubeClient.createNamespacedPersistentVolumeClaim(namespace, pvc);
core.info(`Persistent Volume Claim ${(_a = result.body.metadata) === null || _a === void 0 ? void 0 : _a.name} created`);
});
}
}

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -318,11 +318,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
core.info('Creating build job');
await this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
core.info('Job created');
await KubernetesStorage.watchPersistentVolumeClaimUntilBoundToContainer(
this.kubeClient,
this.pvcName,
this.namespace,
);
await KubernetesStorage.watchUntilPVCNotPending(this.kubeClient, this.pvcName, this.namespace);
core.info('PVC Bound');
this.setPodNameAndContainerName(await this.getPod());
core.info('Watching pod and streaming logs');

View File

@ -7,11 +7,7 @@ class KubernetesStorage {
public static async getPVCPhase(kubeClient: k8s.CoreV1Api, name: string, namespace: string) {
return (await kubeClient.readNamespacedPersistentVolumeClaim(name, namespace)).body.status?.phase;
}
public static async watchPersistentVolumeClaimUntilBoundToContainer(
kubeClient: k8s.CoreV1Api,
name: string,
namespace: string,
) {
public static async watchUntilPVCNotPending(kubeClient: k8s.CoreV1Api, name: string, namespace: string) {
await waitUntil(async () => (await this.getPVCPhase(kubeClient, name, namespace)) !== 'Pending', {
timeout: 500000,
intervalBetweenAttempts: 15000,
@ -44,9 +40,8 @@ class KubernetesStorage {
},
},
};
await kubeClient.createNamespacedPersistentVolumeClaim(namespace, pvc);
core.info(`Persistent Volume Claim created`);
core.info(`PVC state: ${await this.getPVCPhase(kubeClient, pvcName, namespace)}`);
const result = await kubeClient.createNamespacedPersistentVolumeClaim(namespace, pvc);
core.info(`Persistent Volume Claim ${result.body.metadata?.name} created`);
}
}