Skip to content

Commit 97e43ec

Browse files
authored
fix(uptime): Fix bug where regions are not created in shadow mode for new subscriptions (#85911)
We need to specify the mode for the region when creating it
1 parent 4c942a4 commit 97e43ec

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/sentry/uptime/subscriptions/subscriptions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ def create_uptime_subscription(
282282
# Associate active regions with this subscription
283283
for region_config in get_active_regions():
284284
UptimeSubscriptionRegion.objects.create(
285-
uptime_subscription=subscription, region_slug=region_config.slug
285+
uptime_subscription=subscription,
286+
region_slug=region_config.slug,
287+
mode=region_config.mode,
286288
)
287289

288290
create_remote_uptime_subscription.delay(subscription.id)

tests/sentry/uptime/subscriptions/test_subscriptions.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,30 @@ def test_without_task(self):
105105
assert uptime_sub.interval_seconds == uptime_sub.interval_seconds
106106
assert uptime_sub.timeout_ms == timeout_ms
107107

108+
def test_regions(self):
109+
with (
110+
override_settings(
111+
UPTIME_REGIONS=[
112+
UptimeRegionConfig(slug="active_region", name="active_region"),
113+
UptimeRegionConfig(slug="shadow_region", name="shadow_region"),
114+
]
115+
),
116+
override_options(
117+
{
118+
"uptime.checker-regions-mode-override": {
119+
"shadow_region": UptimeSubscriptionRegion.RegionMode.SHADOW
120+
}
121+
}
122+
),
123+
):
124+
uptime_sub = create_uptime_subscription("https://sentry.io", 300, 500)
125+
assert [
126+
(r.region_slug, r.mode) for r in uptime_sub.regions.all().order_by("region_slug")
127+
] == [
128+
("active_region", UptimeSubscriptionRegion.RegionMode.ACTIVE),
129+
("shadow_region", UptimeSubscriptionRegion.RegionMode.SHADOW),
130+
]
131+
108132

109133
class UpdateUptimeSubscriptionTest(UptimeTestCase):
110134
def test(self):

0 commit comments

Comments
 (0)