Skip to content

Conversation

@scefali
Copy link
Contributor

@scefali scefali commented Oct 14, 2020

Historically, we have prevented users from uninstalling Github from Sentry because there is still an installation on the Github side. We forced users to uninstall from Github which triggers a webhook to disable the integration in Sentry. Only at that point could a user remove the integration. However, this is proving problematic because sometimes integrations get in a bad state and it would be better to just remove the installation (and sometimes reinstall).

In the new flow, users can always uninstall the Github integration from Sentry. When that happens, the app is still installed on Github's side but we remove the OrganizationIntegration row and remove the integration_id on the attached repos. If the user wants to reinstall then they would uninstall and reinstall in Github. Those repos which were unattached automatically get reattached to the new integration. So there isn't really a downside to letting the user uninstall in Sentry (things won't get into a bad state).

I've also fixed a KeyError in Sentry when the webhook tries to remove an integration that doesn't exist (SENTRY-CF1).

Fixes: #20599

@scefali scefali requested review from a team and MeredithAnya October 14, 2020 18:05
integration_cls = GitHubIntegration
features = frozenset([IntegrationFeatures.COMMITS, IntegrationFeatures.ISSUE_BASIC])

can_disable = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd explicitly set can_disable to false and leave comment describing the user issue.
Also the comment above IntegrationProvider.can_disable doesn't really describe what disabling does.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it's a little confusing because technically the integration can still be set to disabled if the user uninstalls from GH first. But we use this attribute for whether or not we show the disable dialog text.

I think we should really be documenting the install and uninstall flows for our integrations and related data (i.e. repos, commits, alert rules)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MeredithAnya @mgaeta I added a new comment in the base class what can_disable actually does

@MeredithAnya
Copy link
Member

For anyone who is curious, the organization_integration_details.py delete endpoint ends up calling a task that resets the integration_id to None:

Repository.objects.filter(
organization_id=instance.organization_id, integration_id=instance.integration_id
).update(integration_id=None)

The reason the repos get reattached is that we added the post_install method that does the work of finding the "orphaned" repos and giving them back their integration_id

def post_install(self, integration, organization, extra=None):

Copy link
Member

@MeredithAnya MeredithAnya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish we could still link people to GH so that they uninstall over there. But not sure where that would go. And maybe we just see if that is even a problem

@scefali
Copy link
Contributor Author

scefali commented Oct 15, 2020

I wish we could still link people to GH so that they uninstall over there. But not sure where that would go. And maybe we just see if that is even a problem

Based on my testing, it's rather unnecessary IMO. Uninstalling from Github's side doesn't really provide any benefits.

@scefali scefali merged commit a355bde into master Oct 16, 2020
@scefali scefali deleted the feat/allow-github-uninstall branch October 16, 2020 16:24
@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitHub Integration: Cannot remove integration after uninstalling from GitHub

4 participants