-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Sync RemoteRepository and RemoteOrganization in all VCS providers #7310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sync RemoteRepository and RemoteOrganization in all VCS providers #7310
Conversation
- Refactor `Service.sync` to be unique for all the VCS providers - Make `sync_repositories` and `sync_organizations` to return `repositories` and `(organizations, repositories)` to allow deleting old instances where the user does not have more access - rename `BitBucketService.sync_teams` to `BitBucketService.sync_organizations` to keep our internal naming With this commit, all VCS providers (GitHub, GitLab and BitBucket) will start deleting old RemoteRepository instances (not only GitHub as it's currently working) but also deleting old RemoteOrganization instances as well.
When fetching repositories and organizations always return a valid list. If the user does not have repositories or organizations, a empty list is returned. This allows the code to continue working properly in the further steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good 👍 Should keep our DB more nicely cleaned up.
repos = self.sync_repositories() | ||
organizations, organization_repos = self.sync_organizations() | ||
|
||
# Delete RemoteRepository where the user doesn't have access anymore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should run these delete tasks across all users as a one-time CLI command, to clean up our DB. There's likely a ton of these sitting around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one-time command would require to sync all VCS account connected and delete all the old objects. That may be too much. We may want to limit the amount of accounts re-synced and run it several times by chunks. It will remove a lot of stale data.
However, as this cleanup is in the core of the sync action, all active accounts will be cleanup automatically when they login next time or, when they click the arrow from Import Project page.
I'm going to merge this since it's useful as is it. We can keep the conversation about re-sync all the accounts and make a final decision, tho. |
Service.sync
to be unique for all the VCS providerssync_repositories
andsync_organizations
to returnrepositories
and
(organizations, repositories)
to allow deleting old instances where theuser does not have more access
BitBucketService.sync_teams
toBitBucketService.sync_organizations
to keep our internal naming
With this commit, all VCS providers (GitHub, GitLab and BitBucket) will start
deleting old RemoteRepository instances (not only GitHub as it's currently
working) but also deleting old RemoteOrganization instances as well.
This is a step previous to #2759 and it's required for GitLab/BitBucket VCS SSO
Closes #2412