mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-29 11:31:32 +00:00
Do not retry for some kind of errors in Github (#9055)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
39d1c0a76a
commit
6d4337febb
@ -365,6 +365,11 @@ export async function OnToDoUpdate (txes: Tx[], control: TriggerControl): Promis
|
||||
const description = updTx.operations.description
|
||||
const visibility = updTx.operations.visibility
|
||||
if (doneOn != null) {
|
||||
const todo = (await control.findAll(control.ctx, time.class.ToDo, { _id: updTx.objectId }))[0]
|
||||
if (todo === undefined || todo.doneOn != null) {
|
||||
// Do not process already processed todos.
|
||||
continue
|
||||
}
|
||||
const events = await control.findAll(control.ctx, time.class.WorkSlot, { attachedTo: updTx.objectId })
|
||||
const resEvents: WorkSlot[] = []
|
||||
for (const event of events) {
|
||||
@ -405,10 +410,7 @@ export async function OnToDoUpdate (txes: Tx[], control: TriggerControl): Promis
|
||||
resEvents.push(event)
|
||||
}
|
||||
}
|
||||
const todo = (await control.findAll(control.ctx, time.class.ToDo, { _id: updTx.objectId }))[0]
|
||||
if (todo === undefined) {
|
||||
continue
|
||||
}
|
||||
|
||||
const funcs = control.hierarchy.classHierarchyMixin<Class<Doc>, OnToDo>(
|
||||
todo.attachedToClass,
|
||||
serverTime.mixin.OnToDo
|
||||
|
@ -728,7 +728,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
if (allResolved) {
|
||||
// We need to complete or remove todo, in case all are resolved.
|
||||
if (!Array.from(approvedOrChangesRequested.values()).includes('CHANGES_REQUESTED')) {
|
||||
const todos = allTodos.filter((it) => it.purpose === 'fix')
|
||||
const todos = allTodos.filter((it) => it.purpose === 'fix' && it.doneOn == null)
|
||||
for (const t of todos) {
|
||||
await this.markDoneOrDeleteTodo(t)
|
||||
}
|
||||
@ -853,7 +853,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
|
||||
private async markDoneOrDeleteTodo (td: WithLookup<GithubTodo>): Promise<void> {
|
||||
// Let's mark as done in any case
|
||||
await this.client.update(td, {
|
||||
await this.client.diffUpdate(td, {
|
||||
doneOn: Date.now()
|
||||
})
|
||||
}
|
||||
|
@ -1156,6 +1156,30 @@ export class GithubWorker implements IntegrationManager {
|
||||
state: wrongAuthentications
|
||||
})
|
||||
}
|
||||
|
||||
const fixWrongLastGithubAccount = 'migrate-lastGithubAccount'
|
||||
|
||||
if (migrations.find((it) => it.plugin === githubId && it.state === fixWrongLastGithubAccount) === undefined) {
|
||||
while (true) {
|
||||
const syncInfos = await this.client.findAll(
|
||||
github.class.DocSyncInfo,
|
||||
{ lastGithubUser: { $ne: null } },
|
||||
{ limit: 500 }
|
||||
)
|
||||
if (syncInfos.length === 0) {
|
||||
break
|
||||
}
|
||||
const ops = this._client.apply()
|
||||
for (const auth of syncInfos) {
|
||||
await ops.update(auth, { lastGithubUser: null })
|
||||
}
|
||||
await ops.commit()
|
||||
}
|
||||
await derivedClient.createDoc(core.class.MigrationState, core.space.Configuration, {
|
||||
plugin: githubId,
|
||||
state: fixWrongLastGithubAccount
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async syncAndWait (): Promise<void> {
|
||||
@ -1606,7 +1630,18 @@ export class GithubWorker implements IntegrationManager {
|
||||
}
|
||||
const ops = derivedClient.apply()
|
||||
for (const d of withError) {
|
||||
await ops.update(d, { error: null, needSync: '' })
|
||||
const errStr = JSON.stringify(d.error)
|
||||
// Skip this error's and not retry
|
||||
const skipError =
|
||||
errStr.includes('Bad credentials') ||
|
||||
errStr.includes('Resource not accessible by integration') ||
|
||||
errStr.includes('does not have permission to update') ||
|
||||
errStr.includes('State cannot be changed') ||
|
||||
errStr.includes('Not Found') ||
|
||||
errStr.includes('Could not resolve to a node with the global') ||
|
||||
errStr.includes('Body is too long, Body is too long')
|
||||
|
||||
await ops.update(d, { error: null, needSync: skipError ? githubSyncVersion : '' })
|
||||
}
|
||||
await ops.commit()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user