Skip to content

gitlab: Backoff correctly when sync is forbidden

Administrator requested to merge core/failed-sync-backoff into main

Created by: ryanslade

Currently, we're seeing quite a few user added GitLab code hosts on Cloud that have never synced. It appears that most of the cases are caused by GitLab returning a 403 Forbidden when attempting to list repos. Our current code handles this as a hard failure and bails out without writing to the last_sync column. This in turn means that the code host sync will be attempted again in about a minute.

Instead, we handle 403 errors in the same way as Unauthorized errors and treat it as if the code host returned a list of zero repos. This allows us to "complete" the sync and means we'll properly back off with sync attempts.

The forbidden case will now be handled here: https://github.com/sourcegraph/sourcegraph/blob/de0c449c16b7d1502aac0fe77b6f49d28f69177d/internal/repos/syncer.go#L216-L227

Merge request reports

Loading