Commit graph

991 commits

Author SHA1 Message Date
Matias Bordese
848bd1277f
Handle None role when syncing users from Grafana (#3147)
Fixes https://github.com/grafana/oncall-private/issues/2201
2023-10-19 17:39:08 +00:00
Matias Bordese
a539e3646d
Update shifts public API to improve web shifts support (#3165) 2023-10-19 17:30:12 +00:00
Matias Bordese
35620028cc
Add user TZ information to next shifts per user endpoint (#3157) 2023-10-18 17:14:56 +00:00
Matias Bordese
5c85ced4a9
Update ical schedule creation/update to trigger final schedule refresh (#3156)
Otherwise iCal schedules only refresh their cached final representation
once a day (via periodic task).
Related to https://github.com/grafana/oncall/issues/3154
2023-10-18 16:41:25 +00:00
Michael Derynck
f40e0463d2
Fix inconsistency with API URL returned by plugin status (#3122)
# What this PR does
Change status to return backend URL in the same way (trailing /) that is
used to build URLs throughout by using create_engine_url utility
function.

## Which issue(s) this PR fixes

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-16 17:38:08 +00:00
Matias Bordese
88f9f118a3
Use partial instead of lambda when queuing ack task (#3134)
Prefer partial since it is the what the [docs
suggests](https://docs.djangoproject.com/en/4.2/topics/db/transactions/#performing-actions-after-commit).
Also because partial is evaluated immediately while lambda is evaluated
at runtime (which may be causing some issues):

```
>>> from functools import partial
>>> def foo(a, b, c):
...   print(a, b, c)
... 
>>> x = 10
>>> bar_partial = partial(foo, 1, 2, x)
>>> bar_lambda = lambda: foo(1, 2, x)
>>> x = 20
>>> bar_partial()
1 2 10
>>> bar_lambda()
1 2 20
```
2023-10-06 18:31:11 +00:00
Vadim Stepanov
1acb7018d0
Improve alert group deletion API (#3124)
# What this PR does

- Invalidate alert group cache on wipe
- Improve public API docs on alert group deletion
- Add / improve tests

## Which issue(s) this PR fixes

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

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-05 14:32:40 +01:00
Vadim Stepanov
a727450d49
Public API: Acknowledge & Resolve actions (#3108)
# What this PR does

Makes it possible to acknowledge/unacknowledge and resolve/unresolve
alert groups via public API, and makes sure these actions are reflected
properly in the alert group timeline.

## Demo

```bash
curl --request POST \
     --header "Authorization: TOKEN" \
     http://localhost:8080/api/v1/alert_groups/IQMHLV8INB24N/resolve
```

<img width="651" alt="Screenshot 2023-10-04 at 16 05 27"
src="https://github.com/grafana/oncall/assets/20116910/d4e66868-0132-4b6b-95c7-8424fced7c0b">

## Which issue(s) this PR fixes

https://github.com/grafana/oncall/issues/3051

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-05 09:46:48 +01:00
Matias Bordese
abc0f17c70
Update schedule filter events endpoint to return additional shift info (#3110)
Related to https://github.com/grafana/oncall-private/issues/2191

This will also allow plugin to get shift name and type from the
filter_events API, without needing to get details for each involved
shift in the user's on-call summary timeline.
2023-10-04 16:47:27 +00:00
Joey Orlando
b0e0f646d8
add new 'Alert Groups Direct Paging' RBAC role (#3107)
# What this PR does

Closes #3095

https://www.loom.com/share/6c1a3e9970814f7c83d5cbd72cb5e6b5

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-03 19:28:26 -04:00
Michael Derynck
d604fa1d06
Fix action/webhook API not accepting empty/null user (#3094)
# What this PR does
Fix update calls made by terraform when user field is empty or not
present.
Should have been part of: https://github.com/grafana/oncall/pull/3053

## Which issue(s) this PR fixes
https://github.com/grafana/terraform-provider-grafana/issues/1025

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-03 14:33:05 +00:00
Matias Bordese
29eae9b2c6
Fix slack notification for shift end affected by taken swap (#3092)
Related to https://github.com/grafana/oncall/issues/3096
2023-10-02 12:56:07 +00:00
Ildar Iskhakov
5768decdbf
Direct paging improvements (hotfix) (#3079)
# What this PR does

Fixes https://github.com/grafana/oncall/pull/3064

## 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)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-28 13:54:30 +08:00
Ildar Iskhakov
51014735aa
WIP: Direct paging improvements (#3064)
# What this PR does
* Create Direct Paging integration (with default route) when team is
created with bulk_update
* Create notification policies when user is created with bulk_update
* If user notification policies are empty change it to Email
* Minor markup and wording improvements
* Add grafana queue to helm chart
* Remove disabled commands for redis helm chart
* Improve Dockerfile caching

## 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)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-28 03:57:49 +00:00
Michael Derynck
ab56e53fe8
Allow deletion for removed presets (#3072)
If a webhook preset is removed from configuration while there are still
existing webhooks referencing it they will have the following behavior:

- Webhook can be viewed
- Webhook can be deleted
- Webhook cannot be modified
- Webhook will not execute

Removing a preset from configuration effectively disables all existing
webhooks referencing it while retaining their data.
2023-09-27 10:21:55 -06:00
Michael Derynck
b5a8b8b168
Add webhook presets (#2996)
# What this PR does
Add a system similar to how we select integrations when creating
webhooks so that the user has a description of what webhookds do and
does not have to write complex templates for common webhook use cases.
Presets allow us to create the contents of the webhooks in code and
define which fields are controlled by the preset. Some specifics:

- Newly created webhooks must choose between Simple, Advanced or another
predefined system
- Simple is always an escalation step and will post the entire payload
to the given URL
- Advanced is the same as no preset which is our current view where all
fields are available
- There are no changes for all existing webhooks with empty preset
fields
- Once a webhook is created with a preset the preset cannot be changed
- Fields in the webhook that are populated by code will give a
validation error if they are modified
- In the public API webhooks with presets are returned for viewing but
cannot be created or modified. This restriction is in place because the
Web UI provides the context for which fields to use with a preset. The
public API is for interacting with webhooks where all fields are
defined.

To define a preset create a file with metadata and an override function.
The metadata drives validation and what to display in the UI. There are
two functions one is connected to the pre_save hook of the Webhook model
for persistent changes, the other replaces parameters at execution time
for ephemeral changes. See the simple and advanced presets as an
example. The file must be listed in settings in
`INSTALLED_WEBHOOK_PRESETS` to be enabled at runtime..

## Which issue(s) this PR fixes

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

---------

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2023-09-27 07:22:52 -06:00
Matias Bordese
bba6eb333e
Add db indexes to user table (#3067)
Add composite indexes based on existing queries/usage, ensuring partial
index prefixes are useful too.

- `is_active` filtering is set in the default `User` manager
- most of our user queries are per `organization`
- multiple cases filter by `username` or `email` (most notably schedule
related queries, given the low-level backend ical representation)

Also rework how users are fetched from DB when getting users from
schedules ical representation (which was particularly slow when regex
filtering by required permission).

Related to https://github.com/grafana/oncall-private/issues/2163
2023-09-27 12:35:52 +00:00
Matvey Kukuy
a898835eb4 Fixing ratelimit texts 2023-09-27 14:18:00 +03:00
Matias Bordese
9ead70a4ed
Add schedules enable_web_overrides option to public API (#3062)
Related updates (to be merged afterwards):
- https://github.com/grafana/amixr-api-go-client/pull/14
- https://github.com/grafana/terraform-provider-grafana/pull/1056
2023-09-26 14:04:53 -03:00
Vadim Stepanov
cc337d1473
Add mobile app auth on integration & escalation chain endpoints (#3056) 2023-09-26 16:31:26 +01:00
Michael Derynck
2f1cc43b0e
Fix public actions endpoint to handle empty user field (#3053)
# What this PR does
Fixes a regression that was introduced when actions were remapped to new
webhooks. Validation in the serializer was making the user field no
longer accept blank and None values. This PR makes those values accepted
again.

## Which issue(s) this PR fixes
https://github.com/grafana/terraform-provider-grafana/issues/1025

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-26 14:54:41 +00:00
Matias Bordese
6896d267fb
Refactoring/optimizing some bits in schedule views (#3039)
Related to https://github.com/grafana/oncall-private/issues/2163
2023-09-20 11:49:58 +00:00
Vadim Stepanov
6caacf4048
Handle Slack ratelimit on alert group deletion (#3038)
# What this PR does

- gracefully retry
`apps.alerts.tasks.delete_alert_group.delete_alert_group` when hitting
Slack ratelimits
- remove Slack messages from the DB as soon as they are deleted from
Slack, so the tasks are not retrying perpetually

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-19 08:41:47 +00:00
Matias Bordese
78849d2e43
Fix returned shift PK in current user events endpoint (#3036) 2023-09-18 17:49:21 +00:00
Linhua Tan
0c7281a255
Fix Slack access token length issue (#3016)
# What this PR does

fix the following error caused by too short varchar length of database
fields `access_token` and `bot_access_token` in table
`slack_slackteamidentity`

```
2023-09-12 18:34:07.448 | django.db.utils.DataError: value too long for type character varying(100) |  
-- | -- | --
  |   | 2023-09-12 18:34:07.448 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.448 | return self.cursor.execute(sql, params) |  
  |   | 2023-09-12 18:34:07.448 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute |  
  |   | 2023-09-12 18:34:07.448 | raise dj_exc_value.with_traceback(traceback) from exc_value |  
  |   | 2023-09-12 18:34:07.448 | File "/usr/local/lib/python3.11/site-packages/django/db/utils.py", line 90, in __exit__ |  
  |   | 2023-09-12 18:34:07.448 | with self.db.wrap_database_errors: |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 79, in _execute |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return executor(sql, params, many, context) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 66, in execute |  
  |   | 2023-09-12 18:34:07.447 | cursor.execute(sql, params) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 1175, in execute_sql |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | cursor = super().execute_sql(result_type) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 1559, in execute_sql |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return query.get_compiler(self.db).execute_sql(CURSOR) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 802, in _update |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return filtered._update(values) > 0 |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/db/models/base.py", line 912, in _do_update |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | updated = self._do_update(base_qs, using, pk_val, values, update_fields, |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/db/models/base.py", line 858, in _save_table |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | updated = self._save_table( |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/db/models/base.py", line 776, in save_base |  
  |   | 2023-09-12 18:34:07.447 | self.save_base(using=using, force_insert=force_insert, |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/db/models/base.py", line 739, in save |  
  |   | 2023-09-12 18:34:07.447 | self.save() |  
  |   | 2023-09-12 18:34:07.447 | File "/etc/app/apps/slack/models/slack_team_identity.py", line 72, in update_oauth_fields |  
  |   | 2023-09-12 18:34:07.447 | slack_team_identity.update_oauth_fields(user, organization, response) |  
  |   | 2023-09-12 18:34:07.447 | File "/etc/app/apps/social_auth/pipeline.py", line 102, in populate_slack_identities |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | result = func(*args, **out) or {} |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/social_core/backends/base.py", line 118, in run_pipeline |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | out = self.run_pipeline(pipeline, pipeline_index, *args, **kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/social_core/backends/base.py", line 86, in pipeline |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return self.pipeline(pipeline, *args, **kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/social_core/backends/base.py", line 83, in authenticate |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | user = backend.authenticate(request, **credentials) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/contrib/auth/__init__.py", line 76, in authenticate |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return func(*func_args, **func_kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/views/decorators/debug.py", line 42, in sensitive_variables_wrapper |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return authenticate(*args, **kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/social_django/strategy.py", line 105, in authenticate |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return self.strategy.authenticate(*args, **kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/etc/app/apps/social_auth/backends.py", line 100, in do_auth |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return func(*args, **kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/social_core/utils.py", line 253, in wrapper |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return self.do_auth(access_token, response=response, *args, **kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/etc/app/apps/social_auth/backends.py", line 88, in auth_complete |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return func(*args, **kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/social_core/utils.py", line 253, in wrapper |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return self.auth_complete(*args, **kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/social_core/backends/base.py", line 39, in complete |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | user = backend.complete(user=user, *args, **kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/social_core/actions.py", line 49, in do_complete |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | result = do_complete( |  
  |   | 2023-09-12 18:34:07.447 | File "/etc/app/apps/api/views/auth.py", line 52, in overridden_complete_slack_auth |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return func(request, backend, *args, **kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/social_django/utils.py", line 46, in wrapper |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return view_func(*args, **kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | response = view_func(request, *args, **kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return func(*args, **kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/rest_framework/decorators.py", line 50, in handler |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | response = handler(request, *args, **kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch |  
  |   | 2023-09-12 18:34:07.447 | raise exc |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception |  
  |   | 2023-09-12 18:34:07.447 | self.raise_uncaught_exception(exc) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 469, in handle_exception |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | response = self.handle_exception(exc) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 509, in dispatch |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return self.dispatch(request, *args, **kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/views/generic/base.py", line 70, in view |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return view_func(*args, **kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | response = wrapped_callback(request, *callback_args, **callback_kwargs) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/core/handlers/base.py", line 181, in _get_response |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | response = get_response(request) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 47, in inner |  
  |   | 2023-09-12 18:34:07.447 | Traceback (most recent call last): |  
  |   | 2023-09-12 18:34:07.447 |   |  
  |   | 2023-09-12 18:34:07.447 | The above exception was the direct cause of the following exception: |  
  |   | 2023-09-12 18:34:07.447 |   |  
  |   | 2023-09-12 18:34:07.447 |   |  
  |   | 2023-09-12 18:34:07.447 | psycopg2.errors.StringDataRightTruncation: value too long for type character varying(100) |  
  |   | 2023-09-12 18:34:07.447 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |  
  |   | 2023-09-12 18:34:07.447 | return self.cursor.execute(sql, params) |  
  |   | 2023-09-12 18:34:07.447 | File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute |  
  |   | 2023-09-12 18:34:07.447 | Traceback (most recent call last): |  
  |   | 2023-09-12 18:34:07.447 | 2023-09-12 10:34:07 source=engine:app google_trace_id=50a15245db9b828e0ab33e8d115dd10a/3838538413005063100 logger=django.request Internal Server Error: /api/internal/v1/complete/slack-install-free/
```

---------

Co-authored-by: Vadim Stepanov <vadimkerr@gmail.com>
2023-09-13 11:53:17 +01:00
Vadim Stepanov
bd0009fcea
Fix "Replied message not found" Telegram bug (#3013)
# What this PR does

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

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-12 15:55:13 +00:00
Matias Bordese
7c52c11543
Add render_for_web information to alert group incident API (#3005)
Include alert group render_for_web details in the API response.

Related to https://github.com/grafana/oncall-private/issues/2159
2023-09-12 12:02:42 +00:00
Vadim Stepanov
8b2212c7dc
Improve Slack error handling (#3000)
# What this PR does

- Rename `SlackClientWithErrorHandling` to just `SlackClient`
- Add more error classes + improve the way errors are raised based on
the Slack error code
- Add API call retries on Slack server errors (e.g. when Slack returns
`5xx` errors)
- Refactor some methods working with Slack API + add tests

## Which issue(s) this PR fixes

- https://github.com/grafana/oncall-private/issues/1837
- https://github.com/grafana/oncall-private/issues/1840
- https://github.com/grafana/oncall-private/issues/1842

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-12 09:49:16 +00:00
Matias Bordese
14c32a74bf
Trigger alert group signal after transaction commit (#3001)
See
https://docs.djangoproject.com/en/4.2/topics/db/transactions/#performing-actions-after-commit

Related to https://github.com/grafana/oncall-private/issues/2015
2023-09-11 14:28:37 +00:00
Matias Bordese
9c3979a712
Update escalation policies public API to handle new webhooks (#2999)
Support new webhooks when creating or updating.
Return existing information if still using previous custom button
actions.

Fixed  #2998
2023-09-11 10:50:18 -03:00
Matias Bordese
971384b50e
Update internal alert group details API docs (#2995)
Related to https://github.com/grafana/oncall/issues/2982
2023-09-11 13:25:00 +00:00
Joey Orlando
4b0bb86ce4
Notify user when their shift swap request is taken (#2992)
# What this PR does

Closes #2868

**Slack thread message**
<img width="442" alt="Screenshot 2023-09-07 at 15 47 30"
src="https://github.com/grafana/oncall/assets/9406895/f8f39341-4d18-4a43-88be-066993275fcd">

**Push notification**
Clicking on the push notification goes to the SSR detail view

<img width="423" alt="Screenshot 2023-09-07 at 15 48 59"
src="https://github.com/grafana/oncall/assets/9406895/5bb0fbf3-3e55-47e3-bf24-9cb5690dc17c">


## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-07 14:59:54 +00:00
Matias Bordese
bf4d948449
Update slack schedule shift change notification (#2949)
Related to https://github.com/grafana/oncall/issues/2916

Updated notification:

![slack-shift-notification](https://github.com/grafana/oncall/assets/260710/825fda59-6636-44c1-9740-8976e7c109a7)
2023-09-07 13:00:12 +00:00
Matias Bordese
afc3b193f6
Update insight logs for shift swaps requests (#2987) 2023-09-07 11:49:33 +00:00
Vadim Stepanov
0d7352a17b
Fix handling Slack rate limits (#2991)
## Which issue(s) this PR fixes

https://github.com/grafana/oncall-private/issues/2156

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-07 11:25:29 +00:00
Vadim Stepanov
d90cf0f593
Fix Slack integration leftovers after disconnecting (#2986)
# What this PR does

Improve Slack disconnect cleanup:
- Reset Slack user group for schedules
- Reset Slack user identity for deleted users

## Which issue(s) this PR fixes

https://github.com/grafana/oncall-private/issues/1962

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-07 08:42:30 +00:00
Vadim Stepanov
31759fdf80
Don't update Slack user groups for deleted organizations (#2985)
# What this PR does

Make sure that Slack user groups are not getting updated for deleted
orgs.
Without this change, there could be issues with backends in multiple
clusters trying to update a single Slack user group after migrating an
org to another cluster (organizations get soft deleted from the original
cluster after migration).

## Which issue(s) this PR fixes

https://github.com/grafana/support-escalations/issues/6936

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-06 16:02:01 +00:00
Matias Bordese
5b052afb36
Handle slack resolution note errors consistently (#2976) 2023-09-06 12:15:28 +00:00
Joey Orlando
0d30a9ee67
Merge branch 'dev' of github.com:grafana/oncall into dev 2023-09-05 14:32:34 +02:00
Joey Orlando
3f9d392be9
address another slack-sdk issue 2023-09-05 14:32:28 +02:00
Joey Orlando
293eff2325
fix slack-sdk issue (#2969)
<img width="1488" alt="Screenshot 2023-09-05 at 12 59 16"
src="https://github.com/grafana/oncall/assets/9406895/61518425-da47-4363-8400-fc46b043f64f">


[logs](https://ops.grafana-ops.net/explore?panes=%7B%22FZ0%22:%7B%22datasource%22:%22000000193%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%7Bcluster%3D~%5C%22%28prod-us-central-0%7Cprod-eu-west-0%7Cops-us-east-0%29%5C%22,%20namespace%3D~%5C%22amixr-%28staging%7Cprod%29%5C%22%7D%20%7C%3D%20%60KeyError%28%27cursor%27%60%22,%22queryType%22:%22range%22,%22datasource%22:%7B%22type%22:%22loki%22,%22uid%22:%22000000193%22%7D,%22editorMode%22:%22code%22%7D%5D,%22range%22:%7B%22from%22:%22now-6h%22,%22to%22:%22now%22%7D%7D%7D&schemaVersion=1&orgId=1)
2023-09-05 13:06:22 +02:00
Yulya Artyukhina
6ff61ad172
Fix escalation step "Notify if num alerts in time window" (#2965)
# What this PR does
Fix escalation step "Notify if num alerts in time window" when
escalation policy was deleted during the escalation

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

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-05 10:32:59 +00:00
Joey Orlando
395977d934
fix issue with slack_sdk call update (#2966)
# What this PR does

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-05 12:25:11 +02:00
Joey Orlando
a9155130df
update slack_sdk dependency to latest version (#2947)
# What this PR does

- update `slackclient` dependency to latest version. The version we were
using was 5 years old 😲
- first followed the v2 migration guide
[here](https://github.com/slackapi/python-slack-sdk/wiki/Migrating-to-2.x)
followed by the v3 migration guide
[here](https://slack.dev/python-slack-sdk/v3-migration/). The main
changes were:
    - The PyPI project was renamed from `slackclient` to `slack_sdk`
- it is discouraged/harder to call `api_call` and encouraged to call the
helper methods (ex. `chat_postMessage`;
[note](https://github.com/slackapi/python-slack-sdk/wiki/Migrating-to-2.x#web-client-api-changes)
in migration guide docs)
- In 1.x, a failed api call would return the error payload to you and
have you handle the error. In 2.x, a failed api call will throw an
exception. To handle this in your code, you will have to wrap api calls
with a try except block. Since we overload `WebClient.api_call` this was
an easy change and only required a one line change
- remove `apps.slack.slack_client.slack_server.SlackClientServer` class.
The new version of `slack_sdk` handles the case that we needed to
overload for in the first place.
- merged `apps/slack/slack_client/slack_client.py` and
`apps/slack/slack_client/exceptions.py` into `apps/slack/client.py`

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-05 11:31:59 +02:00
Matias Bordese
0dea5661c4
Reject file uploads when posting to an integration endpoint (#2958)
Related to https://github.com/grafana/oncall-private/issues/2145

---------

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2023-09-05 10:01:50 +02:00
Yulya Artyukhina
ecb4ba0057
Add endpoint for getting schedules events for current user (#2928)
# What this PR does

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

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-05 07:22:08 +00:00
Vadim Stepanov
a2851d3f81
Refactor AlertGroup.slack_message (#2957)
# What this PR does

Refactors the foreign key relationship between `AlertGroup` and
`SlackMessage` models (see
https://github.com/grafana/oncall-private/issues/1867 for more info).

## Which issue(s) this PR fixes

https://github.com/grafana/oncall-private/issues/1867

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-04 18:03:18 +00:00
Yulya Artyukhina
cc92c53f84
Fix build escalation snapshot (#2954)
# What this PR does
Fix escalation snapshot building if last notified user in escalation
step "Notify users one by one (round-robin)" was deleted
 
## Which issue(s) this PR fixes
https://github.com/grafana/oncall-private/issues/2148

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-04 11:10:28 +00:00
Vadim Stepanov
f7bdcf3d36
Fix SlackMessage._alert_group issue (#2945)
# What this PR does

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

## 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] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-01 14:47:10 +00:00
Yulya Artyukhina
e472b03e1d
Remove deprecated alerting integration tasks (#2944)
# What this PR does
These celery tasks have not been used for more than one week (since
[v1.3.25](https://github.com/grafana/oncall/releases/tag/v1.3.25) which
released an improvement for Grafana Alerting integration)

## 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)
2023-09-01 13:11:02 +00:00