Catch errors during get PVC Phase
parent
b00a0baa34
commit
4ee780c5c8
|
|
@ -1585,8 +1585,8 @@ class KubernetesJobSpecFactory {
|
|||
command: [
|
||||
'bin/bash',
|
||||
'-c',
|
||||
`cd /data/builder/action/steps;
|
||||
chmod +x /return_license.sh;
|
||||
`cd /data/builder/action/steps;
|
||||
chmod +x /return_license.sh;
|
||||
/return_license.sh;`,
|
||||
],
|
||||
},
|
||||
|
|
@ -1887,17 +1887,31 @@ class KubernetesStorage {
|
|||
static getPVCPhase(kubeClient, name, namespace) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return (_a = (yield kubeClient.readNamespacedPersistentVolumeClaim(name, namespace)).body.status) === null || _a === void 0 ? void 0 : _a.phase;
|
||||
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* () {
|
||||
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,
|
||||
});
|
||||
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) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -31,16 +31,28 @@ class KubernetesStorage {
|
|||
}
|
||||
|
||||
public static async getPVCPhase(kubeClient: k8s.CoreV1Api, name: string, namespace: string) {
|
||||
return (await kubeClient.readNamespacedPersistentVolumeClaim(name, namespace)).body.status?.phase;
|
||||
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) {
|
||||
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,
|
||||
});
|
||||
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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue