Catch errors during get PVC Phase

pull/289/head
Frostebite 2021-09-12 17:36:58 +01:00
parent b00a0baa34
commit 4ee780c5c8
3 changed files with 43 additions and 17 deletions

14
dist/index.js vendored
View File

@ -1887,17 +1887,31 @@ class KubernetesStorage {
static getPVCPhase(kubeClient, name, namespace) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
try {
return (_a = (yield kubeClient.readNamespacedPersistentVolumeClaim(name, namespace)).body.status) === null || _a === void 0 ? void 0 : _a.phase;
}
catch (error) {
core.error('Failed to get PVC phase');
core.error(JSON.stringify(error, undefined, 4));
throw error;
}
});
}
static watchUntilPVCNotPending(kubeClient, name, namespace) {
return __awaiter(this, void 0, void 0, function* () {
try {
core.info(`watch Until PVC Not Pending ${name} ${namespace}`);
core.info(`${yield this.getPVCPhase(kubeClient, name, namespace)}`);
yield async_wait_until_1.default(() => __awaiter(this, void 0, void 0, function* () { return (yield this.getPVCPhase(kubeClient, name, namespace)) !== 'Pending'; }), {
timeout: 500000,
intervalBetweenAttempts: 15000,
});
}
catch (error) {
core.error('Failed to watch PVC');
core.error(JSON.stringify(error, undefined, 4));
throw error;
}
});
}
static createPVC(pvcName, buildParameters, kubeClient, namespace) {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -31,16 +31,28 @@ class KubernetesStorage {
}
public static async getPVCPhase(kubeClient: k8s.CoreV1Api, name: string, namespace: string) {
try {
return (await kubeClient.readNamespacedPersistentVolumeClaim(name, namespace)).body.status?.phase;
} catch (error) {
core.error('Failed to get PVC phase');
core.error(JSON.stringify(error, undefined, 4));
throw error;
}
}
public static async watchUntilPVCNotPending(kubeClient: k8s.CoreV1Api, name: string, namespace: string) {
try {
core.info(`watch Until PVC Not Pending ${name} ${namespace}`);
core.info(`${await this.getPVCPhase(kubeClient, name, namespace)}`);
await waitUntil(async () => (await this.getPVCPhase(kubeClient, name, namespace)) !== 'Pending', {
timeout: 500000,
intervalBetweenAttempts: 15000,
});
} catch (error) {
core.error('Failed to watch PVC');
core.error(JSON.stringify(error, undefined, 4));
throw error;
}
}
private static async createPVC(