Skip to content
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

ref(hc): Move PagerDutyService into control silo #53084

Merged
merged 10 commits into from
Jul 20, 2023
Merged

Conversation

corps
Copy link
Contributor

@corps corps commented Jul 18, 2023

Notably, this migration is a net zero SQL, it only has to change the state of these columns in django.

I'll want to add the constraint on organization_integration incrementally as a separate PR for 2 reasons

  1. It is unsafe to do so synchronously -- it will be plausible that there are some organization_integration_ids that don't point to existing rows.
  2. Related to ^^ but since this column was a HybridCloudForeignKey, it means the cascade was applied asynchronously for deletes. The goal will be to roll this out, making future deletes stop cascading, then manually clean up any objects pointing to missing OIs, then roll out the migration that adds the constraint back in.

@corps corps requested a review from a team July 18, 2023 17:12
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 18, 2023
@github-actions
Copy link
Contributor

This PR has a migration; here is the generated SQL for src/sentry/migrations/0515_switch_pagerduty_silo.py ()

--
-- Custom state/database change combination
--

@codecov
Copy link

codecov bot commented Jul 18, 2023

Codecov Report

Merging #53084 (fe9bc12) into master (4ec75b8) will increase coverage by 0.00%.
The diff coverage is 90.47%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #53084   +/-   ##
=======================================
  Coverage   79.51%   79.51%           
=======================================
  Files        4938     4939    +1     
  Lines      207934   207971   +37     
  Branches    35473    35478    +5     
=======================================
+ Hits       165335   165372   +37     
+ Misses      37566    37559    -7     
- Partials     5033     5040    +7     
Impacted Files Coverage Δ
src/sentry/integrations/pagerduty/integration.py 95.74% <ø> (ø)
...terfaces/crashContent/exception/sourceMapDebug.tsx 81.13% <ø> (+1.50%) ⬆️
...faces/crashContent/exception/useSourceMapDebug.tsx 88.23% <ø> (ø)
...ummary/transactionOverview/durationChart/index.tsx 65.00% <ø> (-4.57%) ⬇️
...app/views/performance/transactionSummary/utils.tsx 81.08% <ø> (ø)
...try/integrations/pagerduty/actions/notification.py 77.77% <73.33%> (-0.56%) ⬇️
.../serializers/rest_framework/notification_action.py 82.66% <100.00%> (+0.11%) ⬆️
src/sentry/integrations/pagerduty/actions/form.py 82.92% <100.00%> (+2.92%) ⬆️
...rc/sentry/models/integrations/pagerduty_service.py 100.00% <100.00%> (ø)
...c/sentry/services/hybrid_cloud/integration/impl.py 84.30% <100.00%> (ø)
... and 2 more

... and 25 files with indirect coverage changes

@github-actions
Copy link
Contributor

github-actions bot commented Jul 18, 2023

This PR has a migration; here is the generated SQL for src/sentry/migrations/0516_switch_pagerduty_silo.py ()

--
-- Custom state/database change combination
--

@corps corps marked this pull request as ready for review July 19, 2023 23:21
@corps corps requested review from a team as code owners July 19, 2023 23:21
@corps corps requested a review from a team July 19, 2023 23:21

integration = integration_service.get_integration(
organization_integration_id=service.organization_integration_id
ois = integration_service.get_organization_integrations(
Copy link
Member

Choose a reason for hiding this comment

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

nit: I find these 2-3 letter variable names harder to follow than a more verbose variable at least denoting the type

pds
for oi in ois
for pds in oi.config.get("pagerduty_services", [])
if pds["id"] == service_id
Copy link
Member

Choose a reason for hiding this comment

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

is it possible to have more than one match per service_id? If so is this expected/valid behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, there should only be one -- the service_id is a global unique identifier from the PagerDutyService object. In the future, we'll likely generate these by other means when we drop the model all together.

__include_in_export__ = False

organization_integration_id = HybridCloudForeignKey(
"sentry.OrganizationIntegration", on_delete="CASCADE"
# organization_integration_id = HybridCloudForeignKey(
Copy link
Member

Choose a reason for hiding this comment

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

Leftover comments?

Comment on lines 20 to 22
# if oi.integration
# i for i in integrations if i.provider == ExternalProviders.PAGERDUTY.name
# if
Copy link
Member

Choose a reason for hiding this comment

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

More leftover comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, I'll clean up

@corps corps merged commit 4840bb4 into master Jul 20, 2023
@corps corps deleted the zc/switch-pagerduty-silo branch July 20, 2023 01:26
@corps corps added the Trigger: Revert Add to a merged PR to revert it (skips CI) label Jul 20, 2023
@getsentry-bot
Copy link
Contributor

PR reverted: 7e86a48

getsentry-bot added a commit that referenced this pull request Jul 20, 2023
This reverts commit 4840bb4.

Co-authored-by: corps <593850+corps@users.noreply.github.com>
corps added a commit that referenced this pull request Jul 20, 2023
This is #53084 but with the
additional commit
7c0ad04
due to the issue in production caused by bad tests that don't simulate
the form behavior.
@github-actions github-actions bot locked and limited conversation to collaborators Aug 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components Trigger: Revert Add to a merged PR to revert it (skips CI)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants