remove unused dynamic settings (#2735)
# What this PR does While working on https://github.com/grafana/oncall/pull/2734 I removed a block of code that was the last reference to a dynamic setting (`enabled_web_schedules_orgs`). That led me to see which dynamic settings we still have references to (at the database level), and create this cleanup migration for deprecated dynamic settings. ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
This commit is contained in:
parent
8e73de35b1
commit
33c5e89299
2 changed files with 42 additions and 12 deletions
|
|
@ -0,0 +1,42 @@
|
|||
# Generated by Django 3.2.20 on 2023-08-02 17:56
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def remove_unused_dynamic_settings(apps, schema_editor):
|
||||
"""
|
||||
These are deprecated dynamic settings that no longer have references and should be dropped
|
||||
"""
|
||||
DynamicSetting = apps.get_model("base", "DynamicSetting")
|
||||
|
||||
DynamicSetting.objects.filter(
|
||||
name__in=[
|
||||
"enabled_web_schedules_orgs",
|
||||
"enabled_mobile_test_push",
|
||||
"enabled_webhooks_2_orgs",
|
||||
"org_id_to_enable_insight_logs",
|
||||
"messaging_backends_enabled_orgs",
|
||||
"mobile_app_settings",
|
||||
"is_grafana_integration_enabled",
|
||||
"skip_web_cache_for_alert_group",
|
||||
"postpone_distribute_alert",
|
||||
"async_alert_creation",
|
||||
"postpone_distribute_alert_task",
|
||||
"postpone_create_alert_task",
|
||||
"simulate_slack_downtime",
|
||||
"skip_invalidate_web_cache_for_alert_group",
|
||||
"enabled_final_schedule_export",
|
||||
"self_hosted_invitations",
|
||||
]
|
||||
).delete()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("base", "0004_auto_20230616_1510"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(remove_unused_dynamic_settings, migrations.RunPython.noop),
|
||||
]
|
||||
|
|
@ -12,7 +12,6 @@ from .exceptions import (
|
|||
SlackAPIException,
|
||||
SlackAPIRateLimitException,
|
||||
SlackAPITokenException,
|
||||
SlackClientException,
|
||||
)
|
||||
from .slack_client_server import SlackClientServer
|
||||
|
||||
|
|
@ -88,17 +87,6 @@ class SlackClientWithErrorHandling(SlackClient):
|
|||
return cumulative_response, cursor, rate_limited
|
||||
|
||||
def api_call(self, *args, **kwargs):
|
||||
from apps.base.models import DynamicSetting
|
||||
|
||||
simulate_slack_downtime = DynamicSetting.objects.get_or_create(
|
||||
name="simulate_slack_downtime", defaults={"boolean_value": False}
|
||||
)[0]
|
||||
|
||||
if simulate_slack_downtime.boolean_value:
|
||||
# When slack is down it returns 503 with no response.text which leads to JSONDecodeError.
|
||||
# We handle it in SlackClientServer and raise SlackClientException instead
|
||||
raise SlackClientException("Slack Downtime Simulation")
|
||||
|
||||
response = super(SlackClientWithErrorHandling, self).api_call(*args, **kwargs)
|
||||
|
||||
if not response["ok"]:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue