From 623649f6d92427af3eb95f32a1d566fca0a870d8 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Wed, 31 Jul 2024 11:41:09 +0700 Subject: [PATCH] UBERF-7743: Make check-clean non blocking (#6195) --- services/github/pod-github/src/platform.ts | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/services/github/pod-github/src/platform.ts b/services/github/pod-github/src/platform.ts index 8f27a710215..4bc9f17347c 100644 --- a/services/github/pod-github/src/platform.ts +++ b/services/github/pod-github/src/platform.ts @@ -120,15 +120,26 @@ export class PlatformWorker { } } - for (const workspace of workspacesToCheck) { - // We need to connect to workspace and verify all installations and clean if required - try { - ctx.info('check clean', { workspace }) - await this.cleanWorkspaceInstallations(ctx, workspace) - } catch (err: any) { - ctx.error('failed to clean workspace', { err, workspace }) + const checkClean = async (): Promise => { + const rateLimit = new RateLimiter(10) + for (const workspace of workspacesToCheck) { + // We need to connect to workspace and verify all installations and clean if required + try { + await rateLimit.add(async () => { + ctx.info('check clean', { workspace }) + try { + await this.cleanWorkspaceInstallations(ctx, workspace) + } catch (err: any) { + ctx.error('failed to check clean', { workspace }) + } + }) + } catch (err: any) { + ctx.error('failed to clean workspace', { err, workspace }) + } } + await rateLimit.waitProcessing() } + void checkClean() void this.doSyncWorkspaces().catch((err) => { ctx.error('error during sync workspaces', { err }) @@ -220,7 +231,7 @@ export class PlatformWorker { try { workspaceInfo = await getWorkspaceInfo(token) } catch (err: any) { - this.ctx.error('Workspace not found:', { workspace }) + ctx.error('Workspace not found:', { workspace }) return } if (workspaceInfo === undefined) {