Timeout pvc delete after 15s
							parent
							
								
									d8fce0aa21
								
							
						
					
					
						commit
						b5d0bc31a9
					
				|  | @ -2011,8 +2011,8 @@ class Kubernetes { | ||||||
|                 yield async_wait_until_1.default(() => __awaiter(this, void 0, void 0, function* () { |                 yield async_wait_until_1.default(() => __awaiter(this, void 0, void 0, function* () { | ||||||
|                     var _b; |                     var _b; | ||||||
|                     const jobBody = (yield this.kubeClientBatch.readNamespacedJob(this.jobName, this.namespace)).body; |                     const jobBody = (yield this.kubeClientBatch.readNamespacedJob(this.jobName, this.namespace)).body; | ||||||
|                     const podname = (yield this.kubeClient.readNamespacedPod(this.podName, this.namespace)).body; |                     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) && podname === null; |                     return (jobBody === null || ((_b = jobBody.status) === null || _b === void 0 ? void 0 : _b.active) === 0) && podBody === null; | ||||||
|                 }), { |                 }), { | ||||||
|                     timeout: 500000, |                     timeout: 500000, | ||||||
|                     intervalBetweenAttempts: 15000, |                     intervalBetweenAttempts: 15000, | ||||||
|  | @ -2032,7 +2032,12 @@ class Kubernetes { | ||||||
|     // eslint-disable-next-line no-unused-vars
 |     // eslint-disable-next-line no-unused-vars
 | ||||||
|     defaultSecretsArray) { |     defaultSecretsArray) { | ||||||
|         return __awaiter(this, void 0, void 0, function* () { |         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) { |     static findPodFromJob(kubeClient, jobName, namespace) { | ||||||
|  |  | ||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							|  | @ -157,8 +157,8 @@ class Kubernetes implements CloudRunnerProviderInterface { | ||||||
|       await waitUntil( |       await waitUntil( | ||||||
|         async () => { |         async () => { | ||||||
|           const jobBody = (await this.kubeClientBatch.readNamespacedJob(this.jobName, this.namespace)).body; |           const jobBody = (await this.kubeClientBatch.readNamespacedJob(this.jobName, this.namespace)).body; | ||||||
|           const podname = (await this.kubeClient.readNamespacedPod(this.podName, this.namespace)).body; |           const podBody = (await this.kubeClient.readNamespacedPod(this.podName, this.namespace)).body; | ||||||
|           return (jobBody === null || jobBody.status?.active === 0) && podname === null; |           return (jobBody === null || jobBody.status?.active === 0) && podBody === null; | ||||||
|         }, |         }, | ||||||
|         { |         { | ||||||
|           timeout: 500000, |           timeout: 500000, | ||||||
|  | @ -179,7 +179,16 @@ class Kubernetes implements CloudRunnerProviderInterface { | ||||||
|     // eslint-disable-next-line no-unused-vars
 |     // eslint-disable-next-line no-unused-vars
 | ||||||
|     defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[], |     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) { |   static async findPodFromJob(kubeClient: CoreV1Api, jobName: string, namespace: string) { | ||||||
|     const namespacedPods = await kubeClient.listNamespacedPod(namespace); |     const namespacedPods = await kubeClient.listNamespacedPod(namespace); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue