UBERF-10479: Fix github service logs flood (#8828)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2025-05-05 13:12:11 +07:00 committed by GitHub
parent 4e2bb68635
commit 0f53f0e95c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,6 +12,7 @@ import core, {
ClientWorkspaceInfo,
DocumentUpdate,
isActiveMode,
isArchivingMode,
isDeletingMode,
MeasureContext,
RateLimiter,
@ -184,7 +185,7 @@ export class PlatformWorker {
if (errors) {
setTimeout(() => {
this.triggerCheckWorkspaces()
}, 5000)
}, 15000)
}
})
}
@ -731,12 +732,23 @@ export class PlatformWorker {
return { workspaceInfo: undefined, needRecheck: false }
}
if (workspaceInfo?.disabled === true || isDeletingMode(workspaceInfo?.mode)) {
this.ctx.warn('Workspace is disabled', { workspace })
if (!this.checkedWorkspaces.has(workspace)) {
this.checkedWorkspaces.add(workspace)
this.ctx.warn('Workspace is disabled', { workspace })
}
return { workspaceInfo: undefined, needRecheck: false }
}
if (!isActiveMode(workspaceInfo?.mode)) {
this.ctx.warn('Workspace is in maitenance, skipping for now.', { workspace, mode: workspaceInfo?.mode })
return { workspaceInfo: undefined, needRecheck: true }
const archived = isArchivingMode(workspaceInfo?.mode)
if (archived) {
if (!this.checkedWorkspaces.has(workspace)) {
this.checkedWorkspaces.add(workspace)
this.ctx.warn('Workspace is in maitenance, skipping for now.', { workspace, mode: workspaceInfo?.mode })
}
} else {
this.ctx.warn('Workspace is in maitenance, skipping for now.', { workspace, mode: workspaceInfo?.mode })
}
return { workspaceInfo: undefined, needRecheck: !archived }
}
const lastVisit = (Date.now() - workspaceInfo.lastVisit) / (3600 * 24 * 1000) // In days
@ -761,7 +773,7 @@ export class PlatformWorker {
const toDelete = new Set<string>(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()
@ -793,7 +805,7 @@ export class PlatformWorker {
const { workspaceInfo, needRecheck } = await this.checkWorkspaceIsActive(token, workspace)
if (workspaceInfo === undefined) {
if (needRecheck) {
errors++
rechecks.push(workspace)
}
return
}
@ -869,13 +881,13 @@ 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.workspace)
}
@ -889,7 +901,7 @@ export class PlatformWorker {
await rateLimiter.waitProcessing()
} catch (e: any) {
Analytics.handleError(e)
errors++
this.ctx.error('Error', { err: e })
}
clearInterval(connectingInfo)
@ -909,14 +921,16 @@ export class PlatformWorker {
})
} catch (err: any) {
Analytics.handleError(err)
errors++
this.ctx.error('Error', { err })
}
}
}
this.ctx.info('************************* Check workspaces done ************************* ', {
workspaces: this.clients.size
workspaces: this.clients.size,
recheckCount: rechecks.length,
workspacesToCheck: rechecks
})
return errors > 0
return rechecks.length > 0
}
getWorkers (): GithubWorker[] {