Limit on Attach To action in Slack (#2049)

# What this PR does
Reduce number of alert groups returned for grouping on slack request to
20 to avoid event trigger expiry.

## Which issue(s) this PR fixes
https://github.com/grafana/oncall-private/issues/1835

## Checklist

- [ ] 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)

---------

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
This commit is contained in:
Michael Derynck 2023-05-31 07:49:40 -06:00 committed by GitHub
parent 9169eeb9df
commit 61d456ce3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -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

View file

@ -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",