Timeout pvc delete after 15s

pull/310/head
Frostebite 2022-01-30 18:47:54 +00:00
parent d8fce0aa21
commit b5d0bc31a9
3 changed files with 21 additions and 7 deletions

11
dist/index.js vendored
View File

@ -2011,8 +2011,8 @@ class Kubernetes {
yield async_wait_until_1.default(() => __awaiter(this, void 0, void 0, function* () {
var _b;
const jobBody = (yield this.kubeClientBatch.readNamespacedJob(this.jobName, this.namespace)).body;
const podname = (yield this.kubeClient.readNamespacedPod(this.podName, this.namespace)).body;
return (jobBody === null || ((_b = jobBody.status) === null || _b === void 0 ? void 0 : _b.active) === 0) && podname === null;
const podBody = (yield this.kubeClient.readNamespacedPod(this.podName, this.namespace)).body;
return (jobBody === null || ((_b = jobBody.status) === null || _b === void 0 ? void 0 : _b.active) === 0) && podBody === null;
}), {
timeout: 500000,
intervalBetweenAttempts: 15000,
@ -2032,7 +2032,12 @@ class Kubernetes {
// eslint-disable-next-line no-unused-vars
defaultSecretsArray) {
return __awaiter(this, void 0, void 0, function* () {
yield this.kubeClient.deleteNamespacedPersistentVolumeClaim(this.pvcName, this.namespace);
cloud_runner_logger_1.default.log(`deleting PVC`);
const deletePvcPromise = this.kubeClient.deleteNamespacedPersistentVolumeClaim(this.pvcName, this.namespace);
const awaitTimeout = (delay, reason) => new Promise((resolve, reject) => setTimeout(() => (reason === undefined ? resolve() : reject(reason)), delay));
const wrapPromise = (promise, delay, reason) => Promise.race([promise, awaitTimeout(delay, reason)]);
// eslint-disable-next-line unicorn/no-useless-undefined
yield wrapPromise(deletePvcPromise, 15000, undefined);
});
}
static findPodFromJob(kubeClient, jobName, namespace) {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -157,8 +157,8 @@ class Kubernetes implements CloudRunnerProviderInterface {
await waitUntil(
async () => {
const jobBody = (await this.kubeClientBatch.readNamespacedJob(this.jobName, this.namespace)).body;
const podname = (await this.kubeClient.readNamespacedPod(this.podName, this.namespace)).body;
return (jobBody === null || jobBody.status?.active === 0) && podname === null;
const podBody = (await this.kubeClient.readNamespacedPod(this.podName, this.namespace)).body;
return (jobBody === null || jobBody.status?.active === 0) && podBody === null;
},
{
timeout: 500000,
@ -179,7 +179,16 @@ class Kubernetes implements CloudRunnerProviderInterface {
// eslint-disable-next-line no-unused-vars
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
) {
await this.kubeClient.deleteNamespacedPersistentVolumeClaim(this.pvcName, this.namespace);
CloudRunnerLogger.log(`deleting PVC`);
const deletePvcPromise = this.kubeClient.deleteNamespacedPersistentVolumeClaim(this.pvcName, this.namespace);
const awaitTimeout = (delay, reason) =>
new Promise<void>((resolve, reject) =>
setTimeout(() => (reason === undefined ? resolve() : reject(reason)), delay),
);
const wrapPromise = (promise, delay, reason) => Promise.race([promise, awaitTimeout(delay, reason)]);
// eslint-disable-next-line unicorn/no-useless-undefined
await wrapPromise(deletePvcPromise, 15000, undefined);
}
static async findPodFromJob(kubeClient: CoreV1Api, jobName: string, namespace: string) {
const namespacedPods = await kubeClient.listNamespacedPod(namespace);