Commit graph

1633 commits

Author SHA1 Message Date
Joey Orlando
6eac05abaf
apps.webhooks.tasks.trigger_webhook.execute_webhook task - don't retry on requests.exceptions.SSLError (#4796)
# Which issue(s) this PR closes

Address retrying `apps.webhooks.tasks.trigger_webhook.execute_webhook`
task when `requests.exceptions.SSLError` is raised
([logs](https://ops.grafana-ops.net/goto/vqrouqrIR?orgId=1)). Don't
retry the task on these exceptions as retrying will not help. From the
[`request`'s
docs](https://requests.readthedocs.io/en/latest/user/advanced/#ssl-cert-verification):
> By default, SSL verification is enabled, and Requests will throw a
SSLError if it’s unable to verify the certificate

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-08-09 17:45:09 +00:00
Joey Orlando
92ac1d884f
address occasional missing nextCursor data key from GCOM GET /instances (#4794)
# What this PR does

Addressing this task exception
([logs](https://ops.grafana-ops.net/goto/rkVAurrSR?orgId=1)):
```
2024-08-08 16:30:49,455 source=engine:celery worker=ForkPoolWorker-18 task_id=969226be-64a8-4616-ac32-3909d1f0cb60 task_name=apps.grafana_plugin.tasks.sync.start_sync_organizations name=celery.app.trace level=ERROR Task apps.grafana_plugin.tasks.sync.start_sync_organizations[969226be-64a8-4616-ac32-3909d1f0cb60] raised unexpected: KeyError('nextCursor')
```

[This
conversation](https://raintank-corp.slack.com/archives/C0K031RP1/p1723158123932529)
in `#grafana-com-dev` has more context. The _tldr;_ takeaway after
chatting w/ the GCOM team was lets simply retry requests in this case.

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-08-09 15:42:10 +00:00
Joey Orlando
c6a5c8ef10
add better logging for Google Calendar task (#4792)
# What this PR does

Attempting to solve some Celery retry errors we're seeing around
`apps.google.tasks.sync_out_of_office_calendar_events_for_user`. This PR
adds better logging and documents some findings so far.

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-08-09 14:51:20 +00:00
Joey Orlando
93c92a7a4c
Update Slack user group for a schedule - handle paid_team_only Slack API error (#4793)
# What this PR does

Semi-related to https://github.com/grafana/oncall-private/issues/2131

Addresses occasional task failures for
`apps.slack.tasks.update_slack_user_group_for_schedules` when trying to
update a Slack user group for a non-paid Slack account. [Slack's
documentation](https://slack.com/help/articles/212906697-Create-a-user-group)
mentions this is a paid only feature, hence the error
([logs](https://ops.grafana-ops.net/goto/-AWfsrrIR?orgId=1) from an
actual task):
```
2024-08-08 16:20:36,613 source=engine:celery worker=ForkPoolWorker-16 task_id=6bdaae94-1552-4b6d-93e2-e2fa0bae57b1 task_name=apps.slack.tasks.update_slack_user_group_for_schedules name=apps.slack.models.slack_usergroup level=WARNING Slack usergroup S06LW5GJ88Z update failed: Slack API error! Response: {'ok': False, 'error': 'paid_teams_only'}
```

Updated our docs on our Slack integration to emphasize that this feature
_only_ works for paid Slack accounts

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-08-09 14:51:01 +00:00
Dominik Broj
a332011f1e
adjust to unified slack (#4776)
# What this PR does

Introduce OnCall UI for Unified Slack migration. It's mostly banners and
text adjustments. Changes are behind feature flag.

<!--
*Note*: If you want the issue to be auto-closed once the PR is merged,
change "Related to" to "Closes" in the line above.
If you have more than one GitHub issue that this PR closes, be sure to
preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.

---------

Co-authored-by: Innokentii Konstantinov <innokenty.konstantinov@grafana.com>
2024-08-08 14:16:19 +00:00
Yulya Artyukhina
b755404518
Don't send request for permalink if slack token has been revoked (#4777)
# What this PR does
Don't send request for permalink if slack token has been revoked

## Which issue(s) this PR closes

Related to https://github.com/grafana/oncall-private/issues/2843

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-08-06 15:34:08 +00:00
Matias Bordese
7d6da1e157
Handle None values from sync data (#4775)
This is required to support the install v2 endpoint (to be used by
backend plugin) which could be pushing null permissions, teams, or team
memberships.
2024-08-02 18:08:45 +00:00
Michael Derynck
4c1639c944
Fix retrying email notification task (#4772)
# What this PR does
Email tasks are failing and retrying when they use the fallback default
notification policy as it does not get saved in the DB. This PR uses the
same way as UserNotificationPolicyLogRecord to set that field to null to
avoid `ValueError("save() prohibited to prevent data loss due to unsaved
related object 'notification_policy'.").` when that is the case.

## Which issue(s) this PR closes

Related to [issue link here]

<!--
*Note*: If you want the issue to be auto-closed once the PR is merged,
change "Related to" to "Closes" in the line above.
If you have more than one GitHub issue that this PR closes, be sure to
preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-08-01 14:48:39 +00:00
Yulya Artyukhina
62d7f72f38
Enable notification bundling feature by default (#4764)
# What this PR does
Sets feature flag to `True` to enable SMS notification bundling by
default

## Which issue(s) this PR closes

Related to https://github.com/grafana/oncall-private/issues/2554
Should be merged with https://github.com/grafana/oncall/pull/4757

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-08-01 09:07:26 +00:00
Matias Bordese
85c63e7ba2
Fix refactored permissions sync (#4771) 2024-07-31 20:27:42 +00:00
Matias Bordese
35f23cdcc6
Rework organization sync and grafana plugin engine backend (#4756)
Related to
https://github.com/grafana/oncall-private/issues/2806#issuecomment-2246286918.

Prepare engine for the backend plugin enablement/migration:

 - Refactor sync code
- Improve plugin user authentication to set up user on-the-fly (when
missing)
- Implement v2 endpoints for install, sync and status (to be used via
the backend plugin)

(most of the changes come from
https://github.com/grafana/oncall/pull/4657; backport all engine changes
that keep backwards compatibility)
2024-07-31 16:12:56 +00:00
Yulya Artyukhina
551cebddb9
Fix deleted schedule on getting on-call users from cache (#4763)
# What this PR does
Covers the case on getting cached on-call users when cached schedule was
deleted

## Which issue(s) this PR closes

Related to https://github.com/grafana/oncall-private/issues/2836

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-31 15:17:08 +00:00
Innokentii Konstantinov
1faffb3dae
chore: grafana-irm command (#4762) 2024-07-31 11:50:07 +00:00
Vadim Stepanov
7a2fc923df
Don't update RBAC status on Grafana server error (#4753)
# What this PR does

Fixes a bug when RBAC permissions are getting erased when Grafana's API
returns a 5xx server error on organization sync.

## Which issue(s) this PR closes

Closes https://github.com/grafana/oncall-private/issues/2834

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-29 16:28:35 +00:00
Ildar Iskhakov
5a9f124ba7
Stop posting new slack log reports (#4750)
Stop posting a new message, as it is available from the button
(https://github.com/grafana/oncall/pull/4641)
This is an intermediate step, so we will only update posted messages but
not post new ones
Once the majority of messages are updated, we can remove this step
(https://github.com/grafana/oncall/pull/4686)
2024-07-29 12:16:36 +00:00
Vadim Stepanov
eb9e2353b3
Fix N+1 issue on alert group list page (#4738)
# What this PR does

Before:

<img width="267" alt="Screenshot 2024-07-25 at 17 35 28"
src="https://github.com/user-attachments/assets/b0cdcb9d-f658-41cf-9fbb-b61819364dec">

After:
<img width="267" alt="Screenshot 2024-07-25 at 18 11 53"
src="https://github.com/user-attachments/assets/f88c574d-ec9b-4e16-a413-62aa00de6c9a">


## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-25 17:26:05 +00:00
Vadim Stepanov
b408248f35
Enable alert group search by default (#4737)
# What this PR does

Enables free-text search on the alert group page by default (sets the
`FEATURE_ALERT_GROUP_SEARCH_ENABLED` feature flag to `True` by default).

## Which issue(s) this PR closes

Related to https://github.com/grafana/oncall/issues/4263 and
https://github.com/grafana/oncall-private/issues/2679

<!--
*Note*: If you want the issue to be auto-closed once the PR is merged,
change "Related to" to "Closes" in the line above.
If you have more than one GitHub issue that this PR closes, be sure to
preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-25 15:53:12 +00:00
Vadim Stepanov
71cdf355db
Force index only on list & stats (#4734)
Following up on https://github.com/grafana/oncall/pull/4731
2024-07-25 13:25:01 +00:00
Matias Bordese
845940d9b3
Update alert group search to force index in MySQL (#4731)
Related to https://github.com/grafana/oncall-private/issues/2679

Confirmed the query rewriting works via MySQL query logs (index is also
forced for the stats queries):

`2024-07-24T19:50:59.482751Z 3977 Query SELECT `alerts_alertgroup`.`id`
FROM `alerts_alertgroup` FORCE INDEX (`alert_group_list_index`) WHERE
(`alerts_alertgroup`.`channel_id` IN (13) AND (1) AND
(`alerts_alertgroup`.`public_primary_key` LIKE 'test' OR
`alerts_alertgroup`.`inside_organization_number` LIKE 'test' OR
`alerts_alertgroup`.`web_title_cache` LIKE '%test%') AND
`alerts_alertgroup`.`root_alert_group_id` IS NULL AND
((`alerts_alertgroup`.`silenced` = ('0') AND
`alerts_alertgroup`.`acknowledged` = ('0') AND
`alerts_alertgroup`.`resolved` = ('0')) OR
(`alerts_alertgroup`.`acknowledged` = ('1') AND
`alerts_alertgroup`.`resolved` = ('0'))) AND
`alerts_alertgroup`.`started_at` >= '2024-06-24 19:50:58' AND
`alerts_alertgroup`.`started_at` <= '2024-07-24 19:50:58') ORDER BY
`alerts_alertgroup`.`started_at` DESC LIMIT 26
`

Rewriting will only be applied to the alert group search queries, when
the feature flags are enabled. Dependency was already listed as a
requirement.
2024-07-25 09:21:32 +00:00
Yulya Artyukhina
1a6d77888e
Fix notification plan builder (#4726)
# What this PR does
Fixes building notification plan if one or more notifications were
bundled

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-24 15:49:03 +00:00
Vadim Stepanov
b27a158eb0
Fix /escalate predefined org (#4723)
Related to https://github.com/grafana/oncall-gateway/issues/276

Co-authored-by: Innokentii Konstantinov <innokenty.konstantinov@grafana.com>
2024-07-24 10:44:47 +00:00
Innokentii Konstantinov
9da5b94455
Fix app redirect (#4725) 2024-07-24 09:59:56 +00:00
Innokentii Konstantinov
94219c25bb
Introduce slash command matcher (#4717)
With the Unified Slack app we now have two ways of calling commands.
1. Legacy one when command invoked directly: /escalate
2. Unified one: /grafana escalate
On top of that we have different slach commands for each environment:
/escalate-local, /escalate-dev, etc. It was leading to a weird command
to escalate via Unified App in dev u need to type: /grafana-dev
escalate-develop.

To support both, I introduced a matcher function for SlashCommandRoutes.
It allows to simplify handling of such cases without complex workarounds
in an EventAPIEndpoint.


# What this PR does

## Which issue(s) this PR closes

Related to [issue link here]

<!--
*Note*: If you want the issue to be auto-closed once the PR is merged,
change "Related to" to "Closes" in the line above.
If you have more than one GitHub issue that this PR closes, be sure to
preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-24 09:53:06 +00:00
Vadim Stepanov
a53f207355
Alert group search feature flags (#4579)
# What this PR does

Adds two feature flags to experiment with the alert group search feature
(on top of the existing `FEATURE_ALERT_GROUP_SEARCH_ENABLED` flag):
* `FEATURE_ALERT_GROUP_SEARCH_CUTOFF_DAYS` - search window size in days
* `ALERT_GROUPS_DISABLE_PREFER_ORDERING_INDEX` - enable a workaround
that effectively forces the `alert_group_list_index` index to be used
for alert group list requests

## Which issue(s) this PR closes

Related to https://github.com/grafana/oncall-private/issues/2679

<!--
*Note*: if you have more than one GitHub issue that this PR closes, be
sure to preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-23 16:12:00 +00:00
Innokentii Konstantinov
1c88107514
Fix slack app redirect (#4714) 2024-07-22 11:04:04 +00:00
Vadim Stepanov
696aca2d80
Make it clear alert groups can't be searched (#4713)
# What this PR does

* Make the filter input say `Filter results...` instead of `Search or
filter results...` on the alert group page; disallow custom input there
so it's only possible to choose among existing filters
* Remove outdated `<page>/filters?search=` functionality from internal
API

## Which issue(s) this PR closes

Related to https://github.com/grafana/oncall-private/issues/2679

<!--
*Note*: If you want the issue to be auto-closed once the PR is merged,
change "Related to" to "Closes" in the line above.
If you have more than one GitHub issue that this PR closes, be sure to
preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-22 10:30:28 +00:00
Michael Derynck
ec360f08dd
Fix bug for incorrect arguments used to invoke cleanup_empty_deleted_integrations (#4707)
# What this PR does
- Fixes a bug where cleanup_empty_deleted_integrations was not being
passed the correct arguments
- Removes start_cleanup_organizations now that it is no longer in use

## Which issue(s) this PR closes

Related to [issue link here]

<!--
*Note*: If you want the issue to be auto-closed once the PR is merged,
change "Related to" to "Closes" in the line above.
If you have more than one GitHub issue that this PR closes, be sure to
preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-19 14:32:22 +00:00
Matias Bordese
ab700fd4a1
Update OrderedModel serializer not to save previously updated order (#4706)
We are noticing some
[issues](https://ops.grafana-ops.net/goto/sQFLv4XSg?orgId=1) when
updating routes via Terraform because when receiving multiple concurrent
requests updating position, the order is updated in a transaction but it
is then tried to save again in the `.save` call, which could lead to
`IntegrityError`s, because the order may have been updated in a
concurrent request meanwhile.

Test run with the reproduced error (before the serializer update):

```
_____________________________ test_ordered_model_swap_all_to_zero_via_serializer _____________________________

    @pytest.mark.django_db(transaction=True)
    def test_ordered_model_swap_all_to_zero_via_serializer():
        THREADS = 300
        exceptions = []
    
        TestOrderedModel.objects.all().delete()  # clear table
        instances = [TestOrderedModel.objects.create(test_field="test") for _ in range(THREADS)]
    
        # generate random non-unique orders
        random.seed(42)
        positions = [random.randint(0, THREADS - 1) for _ in range(THREADS)]
    
        def update_order_to_zero(idx):
            try:
                instance = instances[idx]
                serializer = TestOrderedModelSerializer(
                    instance, data={"order": 0, "extra_field": idx}, partial=True
                )
                serializer.is_valid(raise_exception=True)
                serializer.save()
                instance.swap(positions[idx])
            except Exception as e:
                exceptions.append(e)
    
        threads = [threading.Thread(target=update_order_to_zero, args=(0,)) for _ in range(THREADS)]
        for thread in threads:
            thread.start()
        for thread in threads:
            thread.join()
    
        # can only check that orders are still sequential and that there are no exceptions
        # can't check the exact order because it changes depending on the order of execution
>       assert not exceptions
E       assert not [IntegrityError(1062, "Duplicate entry 'test-0' for key 'base_testorderedmodel.unique_test_field_order'"), IntegrityEr...rder'"), IntegrityError(1062, "Duplicate entry 'test-0' for key 'base_testorderedmodel.unique_test_field_order'"), ...]

THREADS    = 300
exceptions = [IntegrityError(1062, "Duplicate entry 'test-0' for key 'base_testorderedmodel.unique_test_field_order'"), IntegrityEr...rder'"), IntegrityError(1062, "Duplicate entry 'test-0' for key 'base_testorderedmodel.unique_test_field_order'"), ...]
instances  = [<TestOrderedModel: TestOrderedModel object (841)>, <TestOrderedModel: TestOrderedModel object (842)>, <TestOrderedMod...ject (844)>, <TestOrderedModel: TestOrderedModel object (845)>, <TestOrderedModel: TestOrderedModel object (846)>, ...]
positions  = [57, 12, 140, 125, 114, 71, ...]
thread     = <Thread(Thread-302 (update_order_to_zero), stopped 139636013323840)>
threads    = [<Thread(Thread-3 (update_order_to_zero), stopped 139646722418240)>, <Thread(Thread-4 (update_order_to_zero), stopped ...ate_order_to_zero), stopped 139646608590400)>, <Thread(Thread-8 (update_order_to_zero), stopped 139646600197696)>, ...]
update_order_to_zero = <function test_ordered_model_swap_all_to_zero_via_serializer.<locals>.update_order_to_zero at 0x7f02086274c0>

common/tests/test_ordered_model.py:481: AssertionError
```
2024-07-19 11:56:26 +00:00
Matias Bordese
1491e28226
Update regex to jinja route conversion to correctly escape double quotes (#4705)
Related to this
[thread](https://raintank-corp.slack.com/archives/C0229FD3CE9/p1721309907422709).
2024-07-19 11:56:22 +00:00
Vadim Stepanov
87d7982250
Unified Slack app reinstall (#4682)
# What this PR does

Adds a button to reinstall the Slack app to migrate to Unified Slack
App. Also adds backend support for this.

<img width="1204" alt="Screenshot 2024-07-18 at 18 33 08"
src="https://github.com/user-attachments/assets/a326b4a2-fc65-4b88-98c0-2955e3717e3a">


## Which issue(s) this PR closes

Related to https://github.com/grafana/oncall-gateway/issues/252

<!--
*Note*: if you have more than one GitHub issue that this PR closes, be
sure to preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-19 11:53:06 +00:00
Innokentii Konstantinov
1465db36e5
Support stack header from chatops-proxy (#4578)
This PR supports new flow of selecting org to run command in a slack
workspace if several stacks are using it. In this case user selects
default stack to run commands or pass a --stack flag. Both handled by
chatops-proxy which injects selected stack as a header.
On a side note - I found one ScenarioStep with incompatible set of
arguments with parent class. I didn't fixed it, just left TODO
https://github.com/grafana/oncall/pull/4578/files#diff-e323b5f38ed665f73d5da3fa0575958ed54ab587f6521b4cd87e1491b5430f8bR364

Related to https://github.com/grafana/oncall-gateway/issues/256

---------

Co-authored-by: Vadim Stepanov <vadimkerr@gmail.com>
2024-07-19 10:08:52 +00:00
Matias Bordese
1c33964543
Update schedule events internal API to return default priority level (#4697)
No need to change 0 to `None` in priority level when returning schedule
events (related to this
[thread](https://raintank-corp.slack.com/archives/C0229FD3CE9/p1721239227358309?thread_ts=1721148066.857589&cid=C0229FD3CE9))
2024-07-18 14:15:58 +00:00
Matias Bordese
7777a6003a
Handle multiple unpage event logs when getting paged users (#4698)
Related to https://github.com/grafana/oncall-private/issues/2816
2024-07-18 14:15:48 +00:00
Innokentii Konstantinov
dd84aa15c6
Add missing app_type argument to uninstall request (#4700) 2024-07-18 05:14:52 +00:00
Yulya Artyukhina
4e03732fb1
Drop stale metrics cache (#4695)
# What this PR does
based on this PR - https://github.com/grafana/oncall/pull/4517

## Which issue(s) this PR closes

Related to https://github.com/grafana/oncall/issues/4455

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-17 17:01:04 +00:00
Yulya Artyukhina
49d1127698
Fix send_bundled_notification task (#4696)
# What this PR does
Fix scheduling `perform_notification` from `send_bundled_notification`
task - leftover after resolving merge conflict

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-17 17:00:26 +00:00
Yulya Artyukhina
35ddfab0e4
Add method to send notification bundle by SMS (#4624)
# What this PR does
Adds method to render and send notification bundle by sms.

Example of SMS message:
```
Grafana OnCall: Alert groups #1, #2, #3 and 2 more 
from stack: TestOrganization, 
integrations: Grafana Alerting and 1 more.
```

Should be merged with https://github.com/grafana/oncall/pull/4457

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

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-16 14:20:16 +00:00
Michael Derynck
f7e406ca6f
Only run cleanup for integrations deleted recently (#4677)
# What this PR does
Changes operations to cleanup deleted empty integrations so that they
are only performed on organizations that have deleted integrations
recently. The previous task checked everything because we were not
performing the cleanup on a regular basis, now that it has been
scheduled regularly we can operate on recently deleted integrations
instead.

The existing task has been removed from the schedule, the code for it
can be removed after the other tasks have cleared.

## Which issue(s) this PR closes

Closes [issue link here]

<!--
*Note*: if you have more than one GitHub issue that this PR closes, be
sure to preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-16 13:59:08 +00:00
Yulya Artyukhina
191814b25e
User notifications bundle (#4457)
# What this PR does
This PR adds two new models: UserNotificationBundle and
BundledNotification (proposals for naming are welcome).

`UserNotificationBundle` manages the information about last notification
time and scheduled notification task for bundled notifications. It is
unique per user + notification_channel + notification importance.

`BundledNotification` contains notification policy and alert group, that
triggered the notification. The BundledNotification instance is created
in `notify_user_task` for every notification, that should be bundled,
and is attached to UserNotificationBundle by ForeignKey connection.

How it works:
If the user was notified recently (within the last two minutes) by the
current notification channel, and this channel is bundlable,
BundledNotification instance will be created and attached to the
UserNotificationBundle instance, and `send_bundled_notification` task
will be scheduled to execute in 2 min.
In `send_bundled_notification` task we get all BundledNotification
attached to the current UserNotificationBundle instance, check if alert
groups are still active and if there is only one notification - perform
regular notification by calling `perform_notification` task, otherwise
call "notify_by_<channel>_bundle" method for the current notification
channel.

PR with method to send notification bundle by SMS -
https://github.com/grafana/oncall/pull/4624

**This feature is disabled by default by feature flag. Public docs will
be added in a separate PR with enabling this feature.**
## Which issue(s) this PR closes
related to https://github.com/grafana/oncall-private/issues/2712

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-16 11:24:08 +00:00
Rares Mardare
6e3b7774d6
Allow routing via labels on the Integration page (#3850)
# What this PR does

Adds label routing on the UI


![image](https://github.com/user-attachments/assets/f63c11f0-595d-40bf-80be-4e6cbc10a6ea)


![image](https://github.com/user-attachments/assets/2bbdc8b9-0f0d-447d-a4e4-9e9768ed98bf)

## Which issue(s) this PR fixes

Related to https://github.com/grafana/oncall-private/issues/2461

---------

Co-authored-by: Matias Bordese <mbordese@gmail.com>
2024-07-15 07:43:40 +00:00
Ildar Iskhakov
deff52df07
Add slack button to show log report (#4641)
# What this PR does

Add a button to show an alert group log report in Slack. After deployed
we can remove it from the thread as requested in
https://github.com/grafana/oncall/issues/3849

<img width="534" alt="Screenshot 2024-07-09 at 11 29 48 PM"
src="https://github.com/grafana/oncall/assets/2262529/a17cd366-e97b-4e61-bf06-172fb4737d56">
<img width="673" alt="Screenshot 2024-07-09 at 11 29 57 PM"
src="https://github.com/grafana/oncall/assets/2262529/a67dbe49-1972-45e6-a8b1-ce03ffe6951b">




## Which issue(s) this PR closes

Closes [issue link here]

<!--
*Note*: if you have more than one GitHub issue that this PR closes, be
sure to preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-12 09:49:09 +00:00
Vadim Stepanov
b421296e13
Fix start_sync_org_with_chatops_proxy crontab (#4661)
Related to
https://raintank-corp.slack.com/archives/C04JCU51NF8/p1720695995646029
2024-07-11 16:28:21 +00:00
Matias Bordese
e583d5fc52
Handle inbound email integration alert getting multiple recipients (#4655)
Related to https://github.com/grafana/oncall-private/issues/2683
(when using mailgun backend, you can get multiple recipients, keep the
first one matching the domain; other backends seem to just return the
first one)
2024-07-11 12:51:01 +00:00
Ildar Iskhakov
993725d2ee
Show incident button first when alert group is acknowledged (#4642)
# What this PR does

* Move declare incident button to first position when incident is
acknowledged
* Move resolved text above buttons, so buttons remain on the same place
when clicked
<img width="549" alt="Screenshot 2024-07-09 at 11 52 33 PM"
src="https://github.com/grafana/oncall/assets/2262529/68cfb42f-c7ad-42b9-8404-e3400eb70332">
<img width="529" alt="Screenshot 2024-07-09 at 11 52 41 PM"
src="https://github.com/grafana/oncall/assets/2262529/d8e36dec-ddfc-4db6-9918-0fb478c1462f">


## Which issue(s) this PR closes

Closes https://github.com/grafana/oncall/issues/1908

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.

---------

Co-authored-by: Joey Orlando <joseph.t.orlando@gmail.com>
Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2024-07-10 15:01:01 +00:00
dependabot[bot]
611001c094
Bump zipp from 3.17.0 to 3.19.1 in /engine (#4645)
Bumps [zipp](https://github.com/jaraco/zipp) from 3.17.0 to 3.19.1.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/jaraco/zipp/blob/main/NEWS.rst">zipp's
changelog</a>.</em></p>
<blockquote>
<h1>v3.19.1</h1>
<h2>Bugfixes</h2>
<ul>
<li>Improved handling of malformed zip files. (<a
href="https://redirect.github.com/jaraco/zipp/issues/119">#119</a>)</li>
</ul>
<h1>v3.19.0</h1>
<h2>Features</h2>
<ul>
<li>Implement is_symlink. (<a
href="https://redirect.github.com/jaraco/zipp/issues/117">#117</a>)</li>
</ul>
<h1>v3.18.2</h1>
<p>No significant changes.</p>
<h1>v3.18.1</h1>
<p>No significant changes.</p>
<h1>v3.18.0</h1>
<h2>Features</h2>
<ul>
<li>Bypass ZipFile.namelist in glob for better performance. (<a
href="https://redirect.github.com/jaraco/zipp/issues/106">#106</a>)</li>
<li>Refactored glob functionality to support a more generalized solution
with support for platform-specific path separators. (<a
href="https://redirect.github.com/jaraco/zipp/issues/108">#108</a>)</li>
</ul>
<h2>Bugfixes</h2>
<ul>
<li>Add special accounting for pypy when computing the stack level for
text encoding warnings. (<a
href="https://redirect.github.com/jaraco/zipp/issues/114">#114</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="6d1cb72aa5"><code>6d1cb72</code></a>
Finalize</li>
<li><a
href="fd604bd34f"><code>fd604bd</code></a>
Merge pull request <a
href="https://redirect.github.com/jaraco/zipp/issues/120">#120</a> from
jaraco/bugfix/119-malformed-paths</li>
<li><a
href="c18417ed29"><code>c18417e</code></a>
Add news fragment.</li>
<li><a
href="58115d2be9"><code>58115d2</code></a>
Employ SanitizedNames in CompleteDirs. Fixes broken test.</li>
<li><a
href="564fcc10cd"><code>564fcc1</code></a>
Add SanitizedNames mixin.</li>
<li><a
href="79a309fe54"><code>79a309f</code></a>
Add some assertions about malformed paths.</li>
<li><a
href="2d015c2234"><code>2d015c2</code></a>
Merge <a
href="https://github.com/jaraco/skeleton">https://github.com/jaraco/skeleton</a></li>
<li><a
href="a595a0fad0"><code>a595a0f</code></a>
Rename extras to align with core metadata spec.</li>
<li><a
href="608f90a6e7"><code>608f90a</code></a>
Finalize</li>
<li><a
href="3a22d724ac"><code>3a22d72</code></a>
Merge pull request <a
href="https://redirect.github.com/jaraco/zipp/issues/118">#118</a> from
jaraco/feature/is-symlink</li>
<li>Additional commits viewable in <a
href="https://github.com/jaraco/zipp/compare/v3.17.0...v3.19.1">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=zipp&package-manager=pip&previous-version=3.17.0&new-version=3.19.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/grafana/oncall/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-09 22:49:09 +00:00
Joey Orlando
34a90134fb
patch default user notification policy changes + fix failing e2e test (#4635)
# What this PR does

This is a follow-up PR to https://github.com/grafana/oncall/pull/4628.
As @Ferril pointed out, there was a slight issue in
`apps.alerts.tasks.notify_user.perform_notification` method when using a
"fallback"/default user notification policy. This is because the
`log_record_pk` arg passed into `perform_notification` will fetch the
`UserNotificationPolicyLogRecord` object, but that object will have a
`notification_policy` set to `None` (because there's no persistent
`UserNotificationPolicy` object to refer to).

Instead we now pass in a second argument to `perform_notification`,
`use_default_notification_policy_fallback`. If this is true, simply grab
the transient/in-memory `UserNotificationPolicy` and use that inside of
this task

Related to https://github.com/grafana/oncall/issues/4410

## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-09 11:23:53 -04:00
Ildar Iskhakov
9982eca3b6
Remove mention from aler group main slack message (#4637)
# What this PR does
Removes @mention from Alert Slack message
Fixes https://github.com/grafana/oncall/issues/187
## Which issue(s) this PR closes

Closes [issue link here]

<!--
*Note*: if you have more than one GitHub issue that this PR closes, be
sure to preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-09 14:46:01 +00:00
Ildar Iskhakov
6511e439c5
Add tilt button to run pytest, fix local dev config for pytest, minor improvements to til (#3927)
# What this PR does

Fixes for https://github.com/grafana/oncall-private/issues/2423

## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)

---------

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
Co-authored-by: Dominik <dominik.broj@grafana.com>
2024-07-09 01:24:18 +00:00
Michael Derynck
ecd87782a3
Don't retry cleanup tasks (#4633)
# What this PR does
Disable retry on cleanup tasks. Since these will be scheduled to occur
again on a regular interval minimize the tasks left on queue. These are
not critical tasks.

## Which issue(s) this PR closes

Closes [issue link here]

<!--
*Note*: if you have more than one GitHub issue that this PR closes, be
sure to preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
2024-07-08 20:04:46 +00:00
Joey Orlando
af99d62a32
fix failing e2e tests 2024-07-08 13:04:16 -04:00