diff --git a/CHANGELOG.md b/CHANGELOG.md index 40232600..17700252 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Properly address `Organization.DoesNotExist` exceptions thrown which result in HTTP 500 for the Slack `interactive_api_endpoint` endpoint by @joeyorlando ([#2040](https://github.com/grafana/oncall/pull/2040)) - Fix issue when trying to sync Grafana contact point and config receivers miss a key ([#2046](https://github.com/grafana/oncall/pull/2046)) +- Reduce number of alert groups returned by `Attach To` in slack to avoid event trigger timeout @mderynck ([#2049](https://github.com/grafana/oncall/pull/2049)) ### Changed diff --git a/engine/apps/slack/scenarios/distribute_alerts.py b/engine/apps/slack/scenarios/distribute_alerts.py index a916255d..7b67a991 100644 --- a/engine/apps/slack/scenarios/distribute_alerts.py +++ b/engine/apps/slack/scenarios/distribute_alerts.py @@ -37,6 +37,8 @@ from common.utils import clean_markup, is_string_with_visible_characters from .step_mixins import CheckAlertIsUnarchivedMixin, IncidentActionsAccessControlMixin +ATTACH_TO_ALERT_GROUPS_LIMIT = 20 + logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) @@ -398,7 +400,7 @@ class SelectAttachGroupStep( .order_by("-pk") ) - for alert_group_to_attach in alert_groups_queryset[:60]: + for alert_group_to_attach in alert_groups_queryset[:ATTACH_TO_ALERT_GROUPS_LIMIT]: # long_verbose_name_without_formatting was removed from here because it increases queries count due to # alerts.first(). # alert_group_to_attach.alerts.exists() and alerts.all()[0] don't make additional queries to db due to @@ -435,7 +437,7 @@ class SelectAttachGroupStep( "text": "Attach to...", }, "action_id": AttachGroupStep.routing_uid(), - "options": collected_options[:60], + "options": collected_options[:ATTACH_TO_ALERT_GROUPS_LIMIT], }, "label": { "type": "plain_text",