From 016e3b99eccc716fcb00a739eb9524c08ca71f3a Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 10 Nov 2023 08:47:49 +0000 Subject: [PATCH 01/13] Release oncall Helm chart 1.3.56 --- helm/oncall/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm/oncall/Chart.yaml b/helm/oncall/Chart.yaml index 12eb4b2d..652ea032 100644 --- a/helm/oncall/Chart.yaml +++ b/helm/oncall/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: oncall description: Developer-friendly incident response with brilliant Slack integration type: application -version: 1.3.55 -appVersion: v1.3.55 +version: 1.3.56 +appVersion: v1.3.56 dependencies: - name: cert-manager version: v1.8.0 From a189d79635c029d3e93e00ea496a916536d63002 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 10 Nov 2023 14:44:49 +0000 Subject: [PATCH 02/13] Release oncall Helm chart 1.3.57 --- helm/oncall/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm/oncall/Chart.yaml b/helm/oncall/Chart.yaml index 652ea032..d5df6a1d 100644 --- a/helm/oncall/Chart.yaml +++ b/helm/oncall/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: oncall description: Developer-friendly incident response with brilliant Slack integration type: application -version: 1.3.56 -appVersion: v1.3.56 +version: 1.3.57 +appVersion: v1.3.57 dependencies: - name: cert-manager version: v1.8.0 From 6fe741b516705f846b61d1ca9472b19cc70afaa5 Mon Sep 17 00:00:00 2001 From: vivekkoya <67130044+vivekkoya@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:40:04 -0800 Subject: [PATCH 03/13] =?UTF-8?q?docs:=20remove=20stray=20bullet=20point?= =?UTF-8?q?=20&=20organize=20subtopic=20"Possible=20transit=E2=80=A6=20(#3?= =?UTF-8?q?135)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …ions" in _index.md --------- Co-authored-by: Joey Orlando Co-authored-by: Joey Orlando --- docs/sources/get-started/_index.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/sources/get-started/_index.md b/docs/sources/get-started/_index.md index fb0dc82c..b81760b4 100644 --- a/docs/sources/get-started/_index.md +++ b/docs/sources/get-started/_index.md @@ -126,9 +126,8 @@ the "Firing" state and will re-launch Escalation Chain. re-launch Escalation Chain and move Alert Group to the "Firing" state. * **Resolved:** Similar to "Acknowledged". -* -* Possible transitions: +**Possible transitions**: * Firing -> Acknowledged * Firing -> Silenced * Firing -> Resolved From c9846130f4c3af97edf153af316bc3db20ca91f7 Mon Sep 17 00:00:00 2001 From: Isabel <76437239+imatwawana@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:40:38 -0500 Subject: [PATCH 04/13] Docs: Typo fix (#3210) # What this PR does Fixes a typo ## Which issue(s) this PR fixes N/A ## Checklist - [ ] Unit, integration, and e2e (if applicable) tests updated - [ ] 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) --- docs/sources/escalation-chains-and-routes/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/escalation-chains-and-routes/_index.md b/docs/sources/escalation-chains-and-routes/_index.md index 036ea6d0..bf45192c 100644 --- a/docs/sources/escalation-chains-and-routes/_index.md +++ b/docs/sources/escalation-chains-and-routes/_index.md @@ -42,7 +42,7 @@ chain (e.g. acknowledge, resolve, silence etc), the escalation chain will contin execute. Users can create escalation chains to configure different type of escalation workflows. -For example, you can create a chain that will notify on-call users with high priopity, and +For example, you can create a chain that will notify on-call users with high priority, and another chain that will only send a message into a Slack channel. Escalation chains determine Who and When to notify. [How to notify][notify] is set by the user, based on their own preferences. From fdb8962e027ff6c1f2a777cecca1fa05f0f1a296 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 14 Nov 2023 20:19:41 +0000 Subject: [PATCH 05/13] Release oncall Helm chart 1.3.58 --- helm/oncall/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm/oncall/Chart.yaml b/helm/oncall/Chart.yaml index d5df6a1d..184ee44c 100644 --- a/helm/oncall/Chart.yaml +++ b/helm/oncall/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: oncall description: Developer-friendly incident response with brilliant Slack integration type: application -version: 1.3.57 -appVersion: v1.3.57 +version: 1.3.58 +appVersion: v1.3.58 dependencies: - name: cert-manager version: v1.8.0 From 7985c43dc83cf09d61084f6b9a890875d8badb90 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 16 Nov 2023 16:39:55 +0000 Subject: [PATCH 06/13] Release oncall Helm chart 1.3.59 --- helm/oncall/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm/oncall/Chart.yaml b/helm/oncall/Chart.yaml index 184ee44c..28431c81 100644 --- a/helm/oncall/Chart.yaml +++ b/helm/oncall/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: oncall description: Developer-friendly incident response with brilliant Slack integration type: application -version: 1.3.58 -appVersion: v1.3.58 +version: 1.3.59 +appVersion: v1.3.59 dependencies: - name: cert-manager version: v1.8.0 From aecb20e6ee5eb93e9df33f156ff71089cc71d121 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Mon, 20 Nov 2023 22:54:53 +0000 Subject: [PATCH 07/13] Release oncall Helm chart 1.3.60 --- helm/oncall/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm/oncall/Chart.yaml b/helm/oncall/Chart.yaml index 28431c81..1e5130db 100644 --- a/helm/oncall/Chart.yaml +++ b/helm/oncall/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: oncall description: Developer-friendly incident response with brilliant Slack integration type: application -version: 1.3.59 -appVersion: v1.3.59 +version: 1.3.60 +appVersion: v1.3.60 dependencies: - name: cert-manager version: v1.8.0 From d197b22f7981420cb7274908fc9f77b734c032c0 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 21 Nov 2023 12:56:15 +0000 Subject: [PATCH 08/13] Release oncall Helm chart 1.3.61 --- helm/oncall/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm/oncall/Chart.yaml b/helm/oncall/Chart.yaml index 1e5130db..684127ee 100644 --- a/helm/oncall/Chart.yaml +++ b/helm/oncall/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: oncall description: Developer-friendly incident response with brilliant Slack integration type: application -version: 1.3.60 -appVersion: v1.3.60 +version: 1.3.61 +appVersion: v1.3.61 dependencies: - name: cert-manager version: v1.8.0 From 96284eef8fd10ab4bb11c1618854acba9939645b Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 21 Nov 2023 18:39:50 +0000 Subject: [PATCH 09/13] Release oncall Helm chart 1.3.62 --- helm/oncall/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm/oncall/Chart.yaml b/helm/oncall/Chart.yaml index 684127ee..5d608e4f 100644 --- a/helm/oncall/Chart.yaml +++ b/helm/oncall/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: oncall description: Developer-friendly incident response with brilliant Slack integration type: application -version: 1.3.61 -appVersion: v1.3.61 +version: 1.3.62 +appVersion: v1.3.62 dependencies: - name: cert-manager version: v1.8.0 From 0d5ef785bfd14061043819e1be7b736e11277108 Mon Sep 17 00:00:00 2001 From: Ildar Iskhakov Date: Thu, 23 Nov 2023 11:27:47 +0800 Subject: [PATCH 10/13] Make alert ingestion cache independent --- Tiltfile | 2 +- .../mixins/alert_channel_defining_mixin.py | 26 +++++++++++++------ .../integrations/mixins/ratelimit_mixin.py | 15 ++++++++--- engine/engine/views.py | 14 +++++++--- engine/settings/base.py | 2 ++ 5 files changed, 43 insertions(+), 16 deletions(-) diff --git a/Tiltfile b/Tiltfile index 5a293c92..eb71dad6 100644 --- a/Tiltfile +++ b/Tiltfile @@ -58,7 +58,7 @@ local_resource( allow_parallel=True, ) -yaml = helm("helm/oncall", name=HELM_PREFIX, values=["./dev/helm-local.yml"]) +yaml = helm("helm/oncall", name=HELM_PREFIX, values=["./dev/helm-local.yml", "./dev/helm-local.dev.yml"]) k8s_yaml(yaml) diff --git a/engine/apps/integrations/mixins/alert_channel_defining_mixin.py b/engine/apps/integrations/mixins/alert_channel_defining_mixin.py index c621412f..15d24dbc 100644 --- a/engine/apps/integrations/mixins/alert_channel_defining_mixin.py +++ b/engine/apps/integrations/mixins/alert_channel_defining_mixin.py @@ -5,6 +5,8 @@ from django.core import serializers from django.core.cache import cache from django.core.exceptions import PermissionDenied from django.db import OperationalError +from django_redis.exceptions import ConnectionInterrupted as RedisConnectionInterrupted +from redis.exceptions import ConnectionError as RedisConnectionError from apps.user_management.exceptions import OrganizationMovedException @@ -33,21 +35,29 @@ class AlertChannelDefiningMixin(object): try: # Trying to define from short-term cache cache_key_short_term = self.CACHE_KEY_SHORT_TERM + "_" + str(kwargs["alert_channel_key"]) - cached_alert_receive_channel_raw = cache.get(cache_key_short_term) + try: + cached_alert_receive_channel_raw = cache.get(cache_key_short_term) + except RedisConnectionError: + logger.error("Skip reading AlertReceiveChannel from cache as Redis is not available") + cached_alert_receive_channel_raw = None + if cached_alert_receive_channel_raw is not None: alert_receive_channel = next(serializers.deserialize("json", cached_alert_receive_channel_raw)).object if alert_receive_channel is None: # Trying to define channel from DB alert_receive_channel = AlertReceiveChannel.objects.get(token=kwargs["alert_channel_key"]) - # Update short term cache - serialized = serializers.serialize("json", [alert_receive_channel]) - cache.set(cache_key_short_term, serialized, self.CACHE_SHORT_TERM_TIMEOUT) + try: + # Update short term cache + serialized = serializers.serialize("json", [alert_receive_channel]) + cache.set(cache_key_short_term, serialized, self.CACHE_SHORT_TERM_TIMEOUT) - # Update cached channels - if cache.get(self.CACHE_DB_FALLBACK_OBSOLETE_KEY) is None: - cache.set(self.CACHE_DB_FALLBACK_OBSOLETE_KEY, True, self.CACHE_DB_FALLBACK_REFRESH_INTERVAL) - self.update_alert_receive_channel_cache() + # Update cached channels + if cache.get(self.CACHE_DB_FALLBACK_OBSOLETE_KEY) is None: + cache.set(self.CACHE_DB_FALLBACK_OBSOLETE_KEY, True, self.CACHE_DB_FALLBACK_REFRESH_INTERVAL) + self.update_alert_receive_channel_cache() + except (RedisConnectionError, RedisConnectionInterrupted): + logger.error("Skip updating AlertReceiveChannel cache as Redis is not available") except AlertReceiveChannel.DoesNotExist: raise PermissionDenied("Integration key was not found. Permission denied.") diff --git a/engine/apps/integrations/mixins/ratelimit_mixin.py b/engine/apps/integrations/mixins/ratelimit_mixin.py index 808b4276..58bda952 100644 --- a/engine/apps/integrations/mixins/ratelimit_mixin.py +++ b/engine/apps/integrations/mixins/ratelimit_mixin.py @@ -2,12 +2,14 @@ import logging from abc import ABC, abstractmethod from functools import wraps +from django.conf import settings from django.core.cache import cache from django.http import HttpRequest, HttpResponse from django.views import View from ratelimit import ALL from ratelimit.exceptions import Ratelimited from ratelimit.utils import is_ratelimited +from redis.exceptions import ConnectionError as RedisConnectionError from apps.integrations.tasks import start_notify_about_integration_ratelimit @@ -54,9 +56,16 @@ def ratelimit(group=None, key=None, rate=None, method=ALL, block=False, reason=N request.limited = getattr(request, "limited", False) was_limited_before = request.limited - ratelimited = is_ratelimited( - request=request, group=group, fn=fn, key=key, rate=rate, method=method, increment=True - ) + # Allow requests when redis cache backend fails and RATELIMIT_FAIL_OPEN setting is true + try: + ratelimited = is_ratelimited( + request=request, group=group, fn=fn, key=key, rate=rate, method=method, increment=True + ) + except RedisConnectionError as e: + if settings.RATELIMIT_FAIL_OPEN: + ratelimited = False + else: + raise e # We need to know if it's the first ratelimited request for notification purposes. request.is_first_rate_limited_request = getattr(request, "is_first_rate_limited_request", False) diff --git a/engine/engine/views.py b/engine/engine/views.py index 7f3e2f5d..dca68143 100644 --- a/engine/engine/views.py +++ b/engine/engine/views.py @@ -1,10 +1,15 @@ +import logging + from django.conf import settings from django.core.cache import cache from django.http import HttpResponse, JsonResponse from django.views.generic import View +from redis.exceptions import ConnectionError as RedisConnectionError from apps.integrations.mixins import AlertChannelDefiningMixin +logger = logging.getLogger(__name__) + class HealthCheckView(View): """ @@ -43,11 +48,12 @@ class StartupProbeView(View): dangerously_bypass_middlewares = True def get(self, request): - if cache.get(AlertChannelDefiningMixin.CACHE_KEY_DB_FALLBACK) is None: - AlertChannelDefiningMixin().update_alert_receive_channel_cache() + try: + if cache.get(AlertChannelDefiningMixin.CACHE_KEY_DB_FALLBACK) is None: + AlertChannelDefiningMixin().update_alert_receive_channel_cache() - cache.set("healthcheck", "healthcheck", 30) # Checking cache connectivity - assert cache.get("healthcheck") == "healthcheck" + except RedisConnectionError: + logger.error("Skip updating AlertReceiveChannel cache as Redis is not available") return HttpResponse("Ok") diff --git a/engine/settings/base.py b/engine/settings/base.py index 50eee03d..17cba72b 100644 --- a/engine/settings/base.py +++ b/engine/settings/base.py @@ -838,3 +838,5 @@ ZVONOK_POSTBACK_USER_CHOICE = os.getenv("ZVONOK_POSTBACK_USER_CHOICE", None) ZVONOK_POSTBACK_USER_CHOICE_ACK = os.getenv("ZVONOK_POSTBACK_USER_CHOICE_ACK", None) DETACHED_INTEGRATIONS_SERVER = getenv_boolean("DETACHED_INTEGRATIONS_SERVER", default=False) + +RATELIMIT_FAIL_OPEN = getenv_boolean("RATELIMIT_FAIL_OPEN", default=True) From 566e8c53baf7df8a177f984712ca3d2a66359739 Mon Sep 17 00:00:00 2001 From: Ildar Iskhakov Date: Thu, 23 Nov 2023 16:14:30 +0800 Subject: [PATCH 11/13] Ignore typing checks for imported library (https://mypy.readthedocs.io/en/stable/running_mypy.html\#missing-library-stubs-or-py-typed-marker) --- engine/apps/integrations/mixins/alert_channel_defining_mixin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/apps/integrations/mixins/alert_channel_defining_mixin.py b/engine/apps/integrations/mixins/alert_channel_defining_mixin.py index 15d24dbc..b5128d3a 100644 --- a/engine/apps/integrations/mixins/alert_channel_defining_mixin.py +++ b/engine/apps/integrations/mixins/alert_channel_defining_mixin.py @@ -5,7 +5,7 @@ from django.core import serializers from django.core.cache import cache from django.core.exceptions import PermissionDenied from django.db import OperationalError -from django_redis.exceptions import ConnectionInterrupted as RedisConnectionInterrupted +from django_redis.exceptions import ConnectionInterrupted as RedisConnectionInterrupted # type: ignore from redis.exceptions import ConnectionError as RedisConnectionError from apps.user_management.exceptions import OrganizationMovedException From 95a3ab3b75d64834437c73120add868daaa72de3 Mon Sep 17 00:00:00 2001 From: Ildar Iskhakov Date: Thu, 23 Nov 2023 21:38:06 +0800 Subject: [PATCH 12/13] Revert "Cache independent ingestion" (#3417) Reverts grafana/oncall#3415 --- Tiltfile | 2 +- .../mixins/alert_channel_defining_mixin.py | 26 ++++++------------- .../integrations/mixins/ratelimit_mixin.py | 15 +++-------- engine/engine/views.py | 14 +++------- engine/settings/base.py | 2 -- 5 files changed, 16 insertions(+), 43 deletions(-) diff --git a/Tiltfile b/Tiltfile index eb71dad6..5a293c92 100644 --- a/Tiltfile +++ b/Tiltfile @@ -58,7 +58,7 @@ local_resource( allow_parallel=True, ) -yaml = helm("helm/oncall", name=HELM_PREFIX, values=["./dev/helm-local.yml", "./dev/helm-local.dev.yml"]) +yaml = helm("helm/oncall", name=HELM_PREFIX, values=["./dev/helm-local.yml"]) k8s_yaml(yaml) diff --git a/engine/apps/integrations/mixins/alert_channel_defining_mixin.py b/engine/apps/integrations/mixins/alert_channel_defining_mixin.py index b5128d3a..c621412f 100644 --- a/engine/apps/integrations/mixins/alert_channel_defining_mixin.py +++ b/engine/apps/integrations/mixins/alert_channel_defining_mixin.py @@ -5,8 +5,6 @@ from django.core import serializers from django.core.cache import cache from django.core.exceptions import PermissionDenied from django.db import OperationalError -from django_redis.exceptions import ConnectionInterrupted as RedisConnectionInterrupted # type: ignore -from redis.exceptions import ConnectionError as RedisConnectionError from apps.user_management.exceptions import OrganizationMovedException @@ -35,29 +33,21 @@ class AlertChannelDefiningMixin(object): try: # Trying to define from short-term cache cache_key_short_term = self.CACHE_KEY_SHORT_TERM + "_" + str(kwargs["alert_channel_key"]) - try: - cached_alert_receive_channel_raw = cache.get(cache_key_short_term) - except RedisConnectionError: - logger.error("Skip reading AlertReceiveChannel from cache as Redis is not available") - cached_alert_receive_channel_raw = None - + cached_alert_receive_channel_raw = cache.get(cache_key_short_term) if cached_alert_receive_channel_raw is not None: alert_receive_channel = next(serializers.deserialize("json", cached_alert_receive_channel_raw)).object if alert_receive_channel is None: # Trying to define channel from DB alert_receive_channel = AlertReceiveChannel.objects.get(token=kwargs["alert_channel_key"]) - try: - # Update short term cache - serialized = serializers.serialize("json", [alert_receive_channel]) - cache.set(cache_key_short_term, serialized, self.CACHE_SHORT_TERM_TIMEOUT) + # Update short term cache + serialized = serializers.serialize("json", [alert_receive_channel]) + cache.set(cache_key_short_term, serialized, self.CACHE_SHORT_TERM_TIMEOUT) - # Update cached channels - if cache.get(self.CACHE_DB_FALLBACK_OBSOLETE_KEY) is None: - cache.set(self.CACHE_DB_FALLBACK_OBSOLETE_KEY, True, self.CACHE_DB_FALLBACK_REFRESH_INTERVAL) - self.update_alert_receive_channel_cache() - except (RedisConnectionError, RedisConnectionInterrupted): - logger.error("Skip updating AlertReceiveChannel cache as Redis is not available") + # Update cached channels + if cache.get(self.CACHE_DB_FALLBACK_OBSOLETE_KEY) is None: + cache.set(self.CACHE_DB_FALLBACK_OBSOLETE_KEY, True, self.CACHE_DB_FALLBACK_REFRESH_INTERVAL) + self.update_alert_receive_channel_cache() except AlertReceiveChannel.DoesNotExist: raise PermissionDenied("Integration key was not found. Permission denied.") diff --git a/engine/apps/integrations/mixins/ratelimit_mixin.py b/engine/apps/integrations/mixins/ratelimit_mixin.py index 58bda952..808b4276 100644 --- a/engine/apps/integrations/mixins/ratelimit_mixin.py +++ b/engine/apps/integrations/mixins/ratelimit_mixin.py @@ -2,14 +2,12 @@ import logging from abc import ABC, abstractmethod from functools import wraps -from django.conf import settings from django.core.cache import cache from django.http import HttpRequest, HttpResponse from django.views import View from ratelimit import ALL from ratelimit.exceptions import Ratelimited from ratelimit.utils import is_ratelimited -from redis.exceptions import ConnectionError as RedisConnectionError from apps.integrations.tasks import start_notify_about_integration_ratelimit @@ -56,16 +54,9 @@ def ratelimit(group=None, key=None, rate=None, method=ALL, block=False, reason=N request.limited = getattr(request, "limited", False) was_limited_before = request.limited - # Allow requests when redis cache backend fails and RATELIMIT_FAIL_OPEN setting is true - try: - ratelimited = is_ratelimited( - request=request, group=group, fn=fn, key=key, rate=rate, method=method, increment=True - ) - except RedisConnectionError as e: - if settings.RATELIMIT_FAIL_OPEN: - ratelimited = False - else: - raise e + ratelimited = is_ratelimited( + request=request, group=group, fn=fn, key=key, rate=rate, method=method, increment=True + ) # We need to know if it's the first ratelimited request for notification purposes. request.is_first_rate_limited_request = getattr(request, "is_first_rate_limited_request", False) diff --git a/engine/engine/views.py b/engine/engine/views.py index dca68143..7f3e2f5d 100644 --- a/engine/engine/views.py +++ b/engine/engine/views.py @@ -1,15 +1,10 @@ -import logging - from django.conf import settings from django.core.cache import cache from django.http import HttpResponse, JsonResponse from django.views.generic import View -from redis.exceptions import ConnectionError as RedisConnectionError from apps.integrations.mixins import AlertChannelDefiningMixin -logger = logging.getLogger(__name__) - class HealthCheckView(View): """ @@ -48,12 +43,11 @@ class StartupProbeView(View): dangerously_bypass_middlewares = True def get(self, request): - try: - if cache.get(AlertChannelDefiningMixin.CACHE_KEY_DB_FALLBACK) is None: - AlertChannelDefiningMixin().update_alert_receive_channel_cache() + if cache.get(AlertChannelDefiningMixin.CACHE_KEY_DB_FALLBACK) is None: + AlertChannelDefiningMixin().update_alert_receive_channel_cache() - except RedisConnectionError: - logger.error("Skip updating AlertReceiveChannel cache as Redis is not available") + cache.set("healthcheck", "healthcheck", 30) # Checking cache connectivity + assert cache.get("healthcheck") == "healthcheck" return HttpResponse("Ok") diff --git a/engine/settings/base.py b/engine/settings/base.py index 17cba72b..50eee03d 100644 --- a/engine/settings/base.py +++ b/engine/settings/base.py @@ -838,5 +838,3 @@ ZVONOK_POSTBACK_USER_CHOICE = os.getenv("ZVONOK_POSTBACK_USER_CHOICE", None) ZVONOK_POSTBACK_USER_CHOICE_ACK = os.getenv("ZVONOK_POSTBACK_USER_CHOICE_ACK", None) DETACHED_INTEGRATIONS_SERVER = getenv_boolean("DETACHED_INTEGRATIONS_SERVER", default=False) - -RATELIMIT_FAIL_OPEN = getenv_boolean("RATELIMIT_FAIL_OPEN", default=True) From 85f9b0f168a5c6469374e75141604967b3a18147 Mon Sep 17 00:00:00 2001 From: Innokentii Konstantinov Date: Mon, 27 Nov 2023 18:36:53 +0800 Subject: [PATCH 13/13] Log slack bot_id and bot_user_it (#3429) Log slack bot id and bot user id to check if we can avoid request to slack api --- docs/sources/get-started/_index.md | 1 + engine/apps/slack/views.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/docs/sources/get-started/_index.md b/docs/sources/get-started/_index.md index b81760b4..332726b9 100644 --- a/docs/sources/get-started/_index.md +++ b/docs/sources/get-started/_index.md @@ -128,6 +128,7 @@ re-launch Escalation Chain and move Alert Group * **Resolved:** Similar to "Acknowledged". **Possible transitions**: + * Firing -> Acknowledged * Firing -> Silenced * Firing -> Resolved diff --git a/engine/apps/slack/views.py b/engine/apps/slack/views.py index 60a2ebee..48b065b2 100644 --- a/engine/apps/slack/views.py +++ b/engine/apps/slack/views.py @@ -222,6 +222,20 @@ class SlackEventApiEndpointView(APIView): response = sc.bots_info(bot=payload_event_bot_id) bot_user_id = response.get("bot", {}).get("user_id", "") + # test if we can use user from authorizations instead of api call + payload_bot_user_id = payload_event.get("authorizations", {}).get("user_id") + logger.info( + f"checkin_bot_user_id equal={payload_bot_user_id==slack_team_identity.bot_user_id}" + f" payload_bot_user_id={payload_bot_user_id} reqiest_bot_user_id={bot_user_id}" + f" sti_bot_user_id={slack_team_identity.bot_user_id}" + ) + + # test if we can use bot_id instead of api call + logger.info( + f"checking_bot_id equal={payload_event_bot_id == slack_team_identity.bot_id}" + f" payload_bot_id={payload_event_bot_id} sti_bot_id={slack_team_identity.bot_id}" + ) + # Don't react on own bot's messages. if bot_user_id == slack_team_identity.bot_user_id: return Response(status=200)