Skip to content

Commit 7e4c18a

Browse files
authored
Merge pull request #408 from grafana/dev
Merge dev to main
2 parents 0411117 + 79692b2 commit 7e4c18a

File tree

4 files changed

+32
-19
lines changed

4 files changed

+32
-19
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Change Log
22

3+
## v1.0.25 (2022-08-24)
4+
- Bug fixes
5+
36
## v1.0.24 (2022-08-24)
47
- Insight logs
58
- Default DATA_UPLOAD_MAX_MEMORY_SIZE to 1mb

engine/apps/alerts/models/alert.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ def render_group_data(cls, alert_receive_channel, raw_request_data, is_demo=Fals
196196
if grouping_id_template is not None:
197197
group_distinction, _ = apply_jinja_template(grouping_id_template, raw_request_data)
198198

199-
# Insert demo uuid to prevent grouping of demo alerts.
200-
if is_demo:
201-
group_distinction = cls.insert_demo_uuid(group_distinction)
199+
# Insert random uuid to prevent grouping of demo alerts or alerts with group_distinction=None
200+
if is_demo or not group_distinction:
201+
group_distinction = cls.insert_random_uuid(group_distinction)
202202

203203
if group_distinction is not None:
204204
group_distinction = hashlib.md5(str(group_distinction).encode()).hexdigest()
@@ -224,7 +224,7 @@ def render_group_data(cls, alert_receive_channel, raw_request_data, is_demo=Fals
224224
)
225225

226226
@staticmethod
227-
def insert_demo_uuid(distinction):
227+
def insert_random_uuid(distinction):
228228
if distinction is not None:
229229
distinction += str(uuid4())
230230
else:

engine/apps/telegram/tasks.py

+24-14
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,30 @@ def send_log_and_actions_message(self, channel_chat_id, group_chat_id, channel_m
136136
with OkToRetry(
137137
task=self, exc=(error.RetryAfter, error.TimedOut), compute_countdown=lambda e: getattr(e, "retry_after", 3)
138138
):
139-
if not log_message_sent:
140-
telegram_client.send_message(
141-
chat_id=group_chat_id,
142-
message_type=TelegramMessage.LOG_MESSAGE,
143-
alert_group=alert_group,
144-
reply_to_message_id=reply_to_message_id,
145-
)
146-
if not actions_message_sent:
147-
telegram_client.send_message(
148-
chat_id=group_chat_id,
149-
message_type=TelegramMessage.ACTIONS_MESSAGE,
150-
alert_group=alert_group,
151-
reply_to_message_id=reply_to_message_id,
152-
)
139+
try:
140+
if not log_message_sent:
141+
telegram_client.send_message(
142+
chat_id=group_chat_id,
143+
message_type=TelegramMessage.LOG_MESSAGE,
144+
alert_group=alert_group,
145+
reply_to_message_id=reply_to_message_id,
146+
)
147+
if not actions_message_sent:
148+
telegram_client.send_message(
149+
chat_id=group_chat_id,
150+
message_type=TelegramMessage.ACTIONS_MESSAGE,
151+
alert_group=alert_group,
152+
reply_to_message_id=reply_to_message_id,
153+
)
154+
except error.BadRequest as e:
155+
if e.message == "Chat not found":
156+
logger.warning(
157+
f"Could not send log and actions messages to Telegram group with id {group_chat_id} "
158+
f"due to 'Chat not found'. alert_group {alert_group.pk}"
159+
)
160+
return
161+
else:
162+
raise
153163

154164

155165
@shared_dedicated_queue_retry_task(

engine/apps/telegram/updates/update_handlers/verification/personal.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from apps.telegram.utils import is_verification_message
55

66
USER_CONNECTED_TEXT = "Done! This Telegram account is now linked to <b>{username}</b> 🎉"
7-
RELINK_ACCOUNT_TEXT = """This user is already connected to a Telegram account</b>
7+
RELINK_ACCOUNT_TEXT = """This user is already connected to a Telegram account.
88
Please unlink Telegram account in profile settings of user <b>{username}</b> or contact Grafana OnCall support."""
99
WRONG_VERIFICATION_CODE = "Verification failed: wrong verification code"
1010

0 commit comments

Comments
 (0)