mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-21 15:59:15 +00:00
UBERF-8525: Fix Github stuck on adding new integrations (#7009)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
15ce5442c6
commit
5e234a0646
@ -162,10 +162,15 @@ export class PlatformWorker {
|
|||||||
errors = true
|
errors = true
|
||||||
}
|
}
|
||||||
await new Promise<void>((resolve) => {
|
await new Promise<void>((resolve) => {
|
||||||
this.triggerCheckWorkspaces = resolve
|
this.triggerCheckWorkspaces = () => {
|
||||||
this.ctx.info('Workspaces check triggered')
|
this.ctx.info('Workspaces check triggered')
|
||||||
|
this.triggerCheckWorkspaces = () => {}
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
if (errors) {
|
if (errors) {
|
||||||
setTimeout(resolve, 5000)
|
setTimeout(() => {
|
||||||
|
this.triggerCheckWorkspaces()
|
||||||
|
}, 5000)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -650,6 +655,9 @@ export class PlatformWorker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async checkWorkspaces (): Promise<boolean> {
|
private async checkWorkspaces (): Promise<boolean> {
|
||||||
|
this.ctx.info('************************* Check workspaces ************************* ', {
|
||||||
|
workspaces: this.clients.size
|
||||||
|
})
|
||||||
let workspaces = await this.getWorkspaces()
|
let workspaces = await this.getWorkspaces()
|
||||||
if (process.env.GITHUB_USE_WS !== undefined) {
|
if (process.env.GITHUB_USE_WS !== undefined) {
|
||||||
workspaces = [process.env.GITHUB_USE_WS]
|
workspaces = [process.env.GITHUB_USE_WS]
|
||||||
@ -660,7 +668,14 @@ export class PlatformWorker {
|
|||||||
let errors = 0
|
let errors = 0
|
||||||
let idx = 0
|
let idx = 0
|
||||||
const connecting = new Map<string, number>()
|
const connecting = new Map<string, number>()
|
||||||
|
const st = Date.now()
|
||||||
const connectingInfo = setInterval(() => {
|
const connectingInfo = setInterval(() => {
|
||||||
|
this.ctx.info('****** connecting to workspaces ******', {
|
||||||
|
connecting: connecting.size,
|
||||||
|
time: Date.now() - st,
|
||||||
|
workspaces: workspaces.length,
|
||||||
|
queue: rateLimiter.processingQueue.size
|
||||||
|
})
|
||||||
for (const [c, d] of connecting.entries()) {
|
for (const [c, d] of connecting.entries()) {
|
||||||
this.ctx.info('connecting to workspace', { workspace: c, time: Date.now() - d })
|
this.ctx.info('connecting to workspace', { workspace: c, time: Date.now() - d })
|
||||||
}
|
}
|
||||||
@ -727,7 +742,7 @@ export class PlatformWorker {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
if (worker !== undefined) {
|
if (worker !== undefined) {
|
||||||
workerCtx.info('Register worker Done', {
|
workerCtx.info('************************* Register worker Done ************************* ', {
|
||||||
workspaceId: workspaceInfo.workspaceId,
|
workspaceId: workspaceInfo.workspaceId,
|
||||||
workspace: workspaceInfo.workspace,
|
workspace: workspaceInfo.workspace,
|
||||||
index: widx,
|
index: widx,
|
||||||
@ -736,12 +751,15 @@ export class PlatformWorker {
|
|||||||
// No if no integration, we will try connect one more time in a time period
|
// No if no integration, we will try connect one more time in a time period
|
||||||
this.clients.set(workspace, worker)
|
this.clients.set(workspace, worker)
|
||||||
} else {
|
} else {
|
||||||
workerCtx.info('Failed Register worker, timeout or integrations removed', {
|
workerCtx.info(
|
||||||
|
'************************* Failed Register worker, timeout or integrations removed *************************',
|
||||||
|
{
|
||||||
workspaceId: workspaceInfo.workspaceId,
|
workspaceId: workspaceInfo.workspaceId,
|
||||||
workspace: workspaceInfo.workspace,
|
workspace: workspaceInfo.workspace,
|
||||||
index: widx,
|
index: widx,
|
||||||
total: workspaces.length
|
total: workspaces.length
|
||||||
})
|
}
|
||||||
|
)
|
||||||
errors++
|
errors++
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
@ -754,6 +772,10 @@ export class PlatformWorker {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
this.ctx.info('************************* Waiting To complete Workspace processing ************************* ', {
|
||||||
|
workspaces: this.clients.size,
|
||||||
|
rateLimiter: rateLimiter.processingQueue.size
|
||||||
|
})
|
||||||
try {
|
try {
|
||||||
await rateLimiter.waitProcessing()
|
await rateLimiter.waitProcessing()
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
@ -761,6 +783,11 @@ export class PlatformWorker {
|
|||||||
errors++
|
errors++
|
||||||
}
|
}
|
||||||
clearInterval(connectingInfo)
|
clearInterval(connectingInfo)
|
||||||
|
|
||||||
|
this.ctx.info('************************* Check close deleted ************************* ', {
|
||||||
|
workspaces: this.clients.size,
|
||||||
|
deleted: toDelete.size
|
||||||
|
})
|
||||||
// Close deleted workspaces
|
// Close deleted workspaces
|
||||||
for (const deleted of Array.from(toDelete.keys())) {
|
for (const deleted of Array.from(toDelete.keys())) {
|
||||||
const ws = this.clients.get(deleted)
|
const ws = this.clients.get(deleted)
|
||||||
@ -768,7 +795,7 @@ export class PlatformWorker {
|
|||||||
try {
|
try {
|
||||||
this.ctx.info('workspace removed from tracking list', { workspace: deleted })
|
this.ctx.info('workspace removed from tracking list', { workspace: deleted })
|
||||||
this.clients.delete(deleted)
|
this.clients.delete(deleted)
|
||||||
await ws.close()
|
void ws.close()
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
Analytics.handleError(err)
|
Analytics.handleError(err)
|
||||||
errors++
|
errors++
|
||||||
|
@ -127,8 +127,9 @@ export class GithubWorker implements IntegrationManager {
|
|||||||
this.closing = true
|
this.closing = true
|
||||||
this.ctx.warn('Closing', { workspace: this.workspace.name })
|
this.ctx.warn('Closing', { workspace: this.workspace.name })
|
||||||
this.triggerSync()
|
this.triggerSync()
|
||||||
await this.syncPromise
|
await Promise.all([await this.syncPromise, new Promise<void>((resolve) => setTimeout(resolve, 5000))])
|
||||||
this.ctx.warn('ClosingDone', { workspace: this.workspace.name })
|
|
||||||
|
this.ctx.warn('Closing Done', { workspace: this.workspace.name })
|
||||||
await this.client.close()
|
await this.client.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user