mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-09 19:27:44 +02:00
UBERF-10590: Suport disabled integrations (#8937)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -177,14 +177,17 @@ export class PlatformWorker {
|
||||
triggerCheckWorkspaces = (): void => {}
|
||||
|
||||
async doSyncWorkspaces (): Promise<void> {
|
||||
let oldErrors = ''
|
||||
let sameErrors = 1
|
||||
|
||||
while (!this.canceled) {
|
||||
let errors = false
|
||||
let errors: string[] = []
|
||||
try {
|
||||
errors = await this.checkWorkspaces()
|
||||
} catch (err: any) {
|
||||
Analytics.handleError(err)
|
||||
this.ctx.error('check workspace', err)
|
||||
errors = true
|
||||
errors.push(err.message)
|
||||
}
|
||||
await new Promise<void>((resolve) => {
|
||||
this.triggerCheckWorkspaces = () => {
|
||||
@@ -192,10 +195,19 @@ export class PlatformWorker {
|
||||
this.triggerCheckWorkspaces = () => {}
|
||||
resolve()
|
||||
}
|
||||
if (errors) {
|
||||
if (errors.length > 0) {
|
||||
const timeout = 15000 * sameErrors
|
||||
const ne = errors.join(',')
|
||||
if (oldErrors === ne) {
|
||||
if (sameErrors < 25) {
|
||||
sameErrors++
|
||||
}
|
||||
} else {
|
||||
oldErrors = ne
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.triggerCheckWorkspaces()
|
||||
}, 5000)
|
||||
}, timeout)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -836,7 +848,7 @@ export class PlatformWorker {
|
||||
return { workspaceInfo, needRecheck: true }
|
||||
}
|
||||
|
||||
private async checkWorkspaces (): Promise<boolean> {
|
||||
private async checkWorkspaces (): Promise<string[]> {
|
||||
this.ctx.info('************************* Check workspaces ************************* ', {
|
||||
workspaces: this.clients.size
|
||||
})
|
||||
@@ -844,7 +856,7 @@ export class PlatformWorker {
|
||||
const toDelete = new Set<WorkspaceUuid>(this.clients.keys())
|
||||
|
||||
const rateLimiter = new RateLimiter(5)
|
||||
let errors = 0
|
||||
const rechecks: string[] = []
|
||||
let idx = 0
|
||||
const connecting = new Map<string, number>()
|
||||
const st = Date.now()
|
||||
@@ -870,7 +882,7 @@ export class PlatformWorker {
|
||||
const { workspaceInfo, needRecheck } = await this.checkWorkspaceIsActive(token, workspace)
|
||||
if (workspaceInfo === undefined) {
|
||||
if (needRecheck) {
|
||||
errors++
|
||||
rechecks.push(workspace)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -946,13 +958,12 @@ export class PlatformWorker {
|
||||
total: workspaces.length
|
||||
}
|
||||
)
|
||||
errors++
|
||||
rechecks.push(workspace)
|
||||
}
|
||||
} catch (e: any) {
|
||||
Analytics.handleError(e)
|
||||
this.ctx.info("Couldn't create WS worker", { workspace, error: e })
|
||||
console.error(e)
|
||||
errors++
|
||||
rechecks.push(workspace)
|
||||
} finally {
|
||||
connecting.delete(workspaceInfo.uuid)
|
||||
}
|
||||
@@ -966,7 +977,6 @@ export class PlatformWorker {
|
||||
await rateLimiter.waitProcessing()
|
||||
} catch (e: any) {
|
||||
Analytics.handleError(e)
|
||||
errors++
|
||||
}
|
||||
clearInterval(connectingInfo)
|
||||
|
||||
@@ -986,14 +996,13 @@ export class PlatformWorker {
|
||||
})
|
||||
} catch (err: any) {
|
||||
Analytics.handleError(err)
|
||||
errors++
|
||||
}
|
||||
}
|
||||
}
|
||||
this.ctx.info('************************* Check workspaces done ************************* ', {
|
||||
workspaces: this.clients.size
|
||||
})
|
||||
return errors > 0
|
||||
return rechecks
|
||||
}
|
||||
|
||||
getWorkers (): GithubWorker[] {
|
||||
|
||||
Reference in New Issue
Block a user