Commit graph

1569 commits

Author SHA1 Message Date
Vadim Stepanov
59f2c293e7
Move FCM relay logic into a celery task (#1137) 2023-01-13 19:28:34 +00:00
Matias Bordese
0d38fe2a7f
Web schedules overrides are the higher priority level (#1115)
Related to https://github.com/grafana/oncall-private/issues/1550
2023-01-13 08:58:35 -03:00
Innokentii Konstantinov
9a3b53ff34
Delete slack_connector on org soft-delete (#1127) 2023-01-12 17:37:05 +08:00
Joey Orlando
babacf4da8
refactor the is_rbac_permissions_enabled check to be more robust (#1099)
# What this PR does
Checks the `is_rbac_permissions_enabled` flag differently based on
whether we are dealing with an open-source, or cloud installation:
- for open-source installations, simply continue making a `HEAD` request
to the list RBAC permissions Grafana API endpoint.
- for cloud installations, use the `config` object returned from `GET
/instances/{instance_id}?config=true` and check whether
`instance_info["config"]["feature_toggles"]["accessControlOnCall"] ==
"true"`

## Which issue(s) this PR fixes
Resolves the issue in hosted grafana where when a stack is inactive, the
hosted grafana gateway, returns 200 to the `HEAD` request (which
erroneously sets the `is_rbac_permissions_enabled` flag to `true`)

## Checklist

- [x] Tests updated (N/A)
- [ ] Documentation added
- [x] `CHANGELOG.md` updated
2023-01-11 12:48:30 +01:00
Vadim Stepanov
231c0f45a3
Re-implement FCM relay after introducing firebase (#1121)
This PR changes how `FCMRelayView` handles push notifications from OSS
instances, also changing how the mobile app backend sends push
notifications.
2023-01-11 11:42:01 +00:00
Innokentii Konstantinov
fa6906a606
Simplify and speed up slack rendering (#1105)
Simplify and speed up slack rendering.
2023-01-10 15:41:38 +08:00
Matias Bordese
abbb5a8381
Update schedules query not to defer ical fields used for on-call check (#1114)
Do not defer cached ical fields which are later needed for calculating
on-call users listed in the schedules list page.
2023-01-09 14:10:23 -03:00
Matias Bordese
87fad5eec1
Add select_related to fetch schedules user group information (#1109) 2023-01-09 13:15:27 -03:00
Vadim Stepanov
a1e4f72280
remove send_link_to_channel_message_or_fallback_to_full_incident 2023-01-06 11:34:11 +00:00
Salvatore Giordano
a3dbe95d5a
fix: update android notification payload (#1090) 2023-01-05 17:36:07 +01:00
Joey Orlando
802e3964e9
update mobile app push notification text + make telegram alert verbage consistent ("Firing" instead of "Alerting") (#1089) 2023-01-05 16:16:43 +01:00
Innokentii Konstantinov
8abbcee050
Org soft-delete (#1073)
# What this PR does
It introduces soft-delete of organization, since grafana stacks are
soft-deleted too. Also, we had a problem with deleting orgs with large
amounts of alerts, so soft-deletion will fix this problem. I think, that
problem of cleaning alerts of deleted orgs should be solved as a part of
alert retention
2023-01-05 12:42:55 +08:00
Vadim Stepanov
0d4701bd81
Change wording from "incident" to "alert group" in the Telegram app (#1052)
# What this PR does
Makes Telegram integration consistent with the rest of the system so it
uses the word "alert group" instead of "incident" when referring to
alert groups.

## Checklist

- [x] Tests updated
- [ ] Documentation added (N/A)
- [x] `CHANGELOG.md` updated
2023-01-04 17:44:01 +00:00
Vadim Stepanov
7a1f176cb5
Schedule score backend (#338)
This PR adds an endpoint returning a schedule quality score, overloaded
users and comments on the existing issues (e.g. balance issues or gaps).

## Limitations
- Since working hours editor is not implemented yet, there are only two
scores taken into account: balance score and a score representing the
ratio of time when someone is on-call to the whole time period.
- Time period is now set to be constant (90 days from today), so **in
some cases the results will be inaccurate** (when rotations don't align
with the time period)
- It only takes primary rotations into account (overrides are ignored)

## Usage
`GET /api/internal/v1/schedules/<pk>/quality?date=<TOMORROW_DATE>`

Note that `date` should be tomorrow date, because we can only be sure
about changing tomorrow's shifts (some of the shifts for current day
could be "deleted" but still show up in the UI).

## Example response
```json
{
  "total_score": 90,
  "comments": ["Schedule has no gaps", "Schedule is well-balanced, but still can be improved"],
  "overloaded_users": ["USSZ5WRH2CUA9", "U74XJZSSQGBIH"]
}
```

Issue: #118
2023-01-04 16:49:58 +00:00
Michael Derynck
7c26eb559b
Improve handling of template exceptions during group data creation (#1068)
# What this PR does
With the addition of tighter controls on jinja templates handle
exceptions while rendering group data as follows:
- Title will cache error message as title and display to user and the
error will be logged
- Group distinction will be left as None and the error will be logged
- Is resolve signal will be treated as False and the error will be
logged
- Is acknowledge signal will be treated as False and the error will be
logged

## Which issue(s) this PR fixes
https://github.com/grafana/oncall-private/issues/1542
2023-01-03 12:30:59 -07:00
Vadim Stepanov
cd770e85ea
Catch DoesNotExist in post_slack_rate_limit_message (#1067) 2023-01-03 17:44:56 +00:00
Matias Bordese
05524ab698
Merge pull request #1059 from grafana/matiasb/truncate-slack-title-block
Truncate slack alert group title block below max size
2023-01-03 08:50:57 -03:00
Matias Bordese
0a3c96d3c3
Merge pull request #1058 from grafana/matias/fix-schedule-no-start-byday
Handle no start date when calculating by day ical shift events
2023-01-03 08:50:27 -03:00
Ildar Iskhakov
1ff0a7da99
1.1.5.5 -> dev (#1060)
# What this PR does

## Which issue(s) this PR fixes

## Checklist

- [ ] Tests updated
- [ ] Documentation added
- [ ] `CHANGELOG.md` updated

Co-authored-by: Vadim Stepanov <vadimkerr@gmail.com>
Co-authored-by: Julia <ferril.darkdiver@gmail.com>
Co-authored-by: Innokentii Konstantinov <innokenty.konstantinov@grafana.com>
Co-authored-by: Matias Bordese <mbordese@gmail.com>
2023-01-03 11:57:16 +08:00
Innokentii Konstantinov
5e297847ae Speedup alert group search 2023-01-03 11:04:16 +08:00
Matias Bordese
374f32f489 Handle no start date when calculating by day ical shift events 2023-01-02 11:53:49 -03:00
Matias Bordese
75aaeef3f2 Truncate slack alert group title block below max size 2023-01-02 10:07:53 -03:00
Ildar Iskhakov
282e58db7b
Don't render logs for too big telegram dm (#1051)
# What this PR does

## Which issue(s) this PR fixes

## Checklist

- [ ] Tests updated
- [ ] Documentation added
- [ ] `CHANGELOG.md` updated
2022-12-29 13:22:15 +00:00
Joey Orlando
7ebc9cbbf7
modify push notification settings + use fcm-django library (#998)
- swaps out `django-push-notifications` for
[`fcm-django`](https://github.com/grafana/fcm-django). Again.. this is a
fork of the parent repo for exactly the same reason.. the migrations
point to `auth_user` without letting us use our own user model, this has
been patched in the `grafana` fork. The reason why we are using
`fcm-django` vs `django-push-notifications` is that the latter does not
support the new FCM API, only the "legacy" API. The legacy FCM API does
not support certain push notification settings that we would like to
use.
- modifies the iOS/Android specific push notification settings
- adds a `flower` pod in the `docker-compose-developer.yml`, useful for
debugging tasks locally
- sets the mobile app verification token TTL to 5 minutes when
developing locally. The default of 1 minute makes working with device
emulators really tricky..

This PR also swaps out the base image in `engine/Dockerfile` from
`python:3.9-alpine3.16` to `python:3.9-slim-buster`.

As to why.. in short, with the introduction of the `fcm-django` library
there is now a peer-dependency on
[`grpcio`](https://github.com/grpc/grpc) (which is used by
`firebase_admin`.. which I am using in this PR to interact directly with
Firebase Cloud Messaging (FCM)). `grpcio` does not publish wheels (read:
compiled binaries) for the Alpine distro. It does publish wheels for
Debian and hence `pip install -r requirements.txt` does not need to
build this library from the source distribution.

This is a [known
"issue"](https://github.com/grpc/grpc/issues/22815#issuecomment-1107874367)
and the recommended solution in the community is to.. not use alpine.

These were the numbers, when building the image locally, in terms of
image size and build time:

| | Local image size (uncompressed | Build time (may differ based on
your network speed) |
| ------------------------- | -------------------------------------- |
---------- |
| `python:3.9-alpine3.16`   | 785MB  | 320s |
| `python:3.9-slim-buster` | 1.05GB  | 90s   |

Co-authored-by: Salvatore Giordano <salvatoregiordanoo@gmail.com>
2022-12-20 12:41:34 +01:00
Innokentii Konstantinov
7bb4fdfe43
Merge pull request #1017 from grafana/fix_ag_filtering
Speedup search alertgroup to group alert
2022-12-19 10:59:24 +08:00
Innokentii Konstantinov
41f886b31e Speedup seach alertgroup 2022-12-17 19:34:13 +08:00
Joey Orlando
66b2ed5c64
add more logging to push notification celery task (#986) 2022-12-13 14:06:56 +01:00
Joey Orlando
5967d5af63
remove apns + fix django-push-notifications migrations (#984)
- removes APNS support
- changes the `django-push-notification` library from the `iskhakov`
fork to the [`grafana`
fork](https://github.com/grafana/django-push-notifications). This new
fork basically just patches an issue which affected the database
migrations of this django app (previously the library would not respect
the `USER_MODEL` setting when creating its tables and would instead
reference the `auth_user` table.. which we don't want)
- add `--no-cache` flag to the `make build` command

**NOTE**
A migration should be applied as follows:
```bash
# remove the four push_notifications tables, which have improper foreign key references
python manage.py migrate push_notifications zero

# recreate the tables with the proper foreign key references
python manage.py migrate
```
2022-12-13 13:00:59 +01:00
Matias Bordese
9931105cc2 Add additional logging info for slack API event endpoint requests 2022-12-12 15:41:48 -03:00
Joey Orlando
b66dd1a30c
fix sync.. again (#978) 2022-12-12 18:48:26 +01:00
Joey Orlando
3625b75791
fix cloud sync related issue (#977)
this PR reverts [this
change](9e598385f4 (diff-a74aa8f07a8fdc31af66559390f0fc77b66692d43e6d3c5f94311ef7eed5efabL19-L55))
and removes the `str` casting that was done on the `orgId` field
returned from the Grafana COM API
2022-12-12 18:25:56 +01:00
Joey Orlando
8c0eba46b9
remove is_rbac_permissions_enabled logic from check_gcom_permission function (#976)
this field will be addressed in a subsequent sync call it is not
necessary here
2022-12-12 17:05:44 +01:00
Michael Derynck
52d6009c2a
Remove unused parameter from gcom call (#975)
# What this PR does
Remove unused parameter from gcom call

## Which issue(s) this PR fixes

## Checklist

- [ ] Tests updated
- [ ] Documentation added
- [ ] `CHANGELOG.md` updated
2022-12-12 08:40:32 -07:00
Matias Bordese
67ac47ff32 Update SCHEDULES_WRITE fallback role to EDITOR 2022-12-09 12:56:35 -03:00
Innokentii Konstantinov
28dedcd109
Shorten telegram callback data (#959)
Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2022-12-07 23:54:29 +08:00
Innokentii Konstantinov
c31ac3b977 Fix create_oncall_connector 2022-12-07 12:03:50 +08:00
Innokentii Konstantinov
4f18be927a Fix migration 2022-12-07 00:20:54 +08:00
Innokentii Konstantinov
7341641b3f
Introduce org uuid (#947)
* Introduce org uuid

* Rename uuid_with_org_id to uuid_with_org_uuid

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2022-12-06 22:42:58 +08:00
Joey Orlando
f8c8ceb2f6
only grant admins read/write access to public api keys (#952) 2022-12-06 13:02:53 +01:00
Joey Orlando
ffda80ae34
add permalinks.web attribute to alert group internal/public api response (#953) 2022-12-06 11:06:05 +01:00
Michael Derynck
ad3cd8f5dd
Remove unused call for checking gcom api keys (#931) 2022-12-01 10:35:53 -07:00
Vadim Stepanov
1878b7e596
Mobile app FCM support (#923)
* Add ability to configure FCM_API_KEY and FCM_POST_URL

* Delete APNSDevice and GCMDevice instances when unlinking the mobile app backend

* Add a simple FCM relay endpoint

* GCM -> FCM

* comment
2022-12-01 15:17:01 +00:00
Joey Orlando
9a7b8acd5a
centralize timezone validation + add serializer validation for on call shifts and schedules (#924)
* Centralize timezone validation into one spot + add serializer validation
for schedules and oncall shifts (both public and internal API)

* add engine-manage make command
2022-12-01 14:13:39 +01:00
Matias Bordese
3e8417e000 Update final schedule to consider priority level for overrides 2022-11-30 10:26:33 -03:00
Matias Bordese
1f49c6e44a Do not include event repetitions terminated before start (until rrule) 2022-11-30 08:56:19 -03:00
Joey Orlando
a9ac7e82df
update grafana API RBAC permissions endpoint 2022-11-30 09:03:10 +01:00
Matias Bordese
706aef10f2
Merge pull request #827 from grafana/matiasb/fix-filtering-events-from-deleted-schedule
Handle error when updating ical cache from deleted web schedule
2022-11-29 09:12:48 -03:00
Joey Orlando
9e598385f4
Add RBAC Support (#777)
* Modify plugin.json to support RBAC role registration

* defines 26 new custom roles in plugin.json. The main roles are:

- Admin: read/write access to everything in OnCall
- Reader: read access to everything in OnCall
- OnCaller : read access to everything in OnCall + edit access to Alert Groups and Schedules
- <object-type> Editor: read/write access to everything related to <object-type>
- <object-type> Reader: read access for <object-type>
- User Settings Admin: read/write access to all user's settings, not just own settings. This is in comparison to User Settings Editor which can only read/write own settings

* update changelog and documentation (#686)

* implement RBAC for OnCall backend

This commit refactors backend authorization. It trys to use RBAC authorization if the org's grafana instance supports it, otherwise it falls back to basic role authorization.

* update RBAC backend tests

* add tests for RBAC changes
- run backend tests as matrix where RBAC is enabled/disabled. When RBAC is enabled, the permissions granted are read from the role grants in the frontend's plugin.json file (instead of relying what we specify in RBACPermission.Permissions)
- remove --reuse-db --nomigrations flags from engine/tox.ini
- minor autoformatting changes to docker-compose-developer.yml

* remove --ds=settings.ci-test from pytest CI command

DJANGO_SETTINGS_MODULE is already specified as an env var so this is just unecessary duplication

* update gitignore

* update github action job name for "test"

* RBAC frontend changes

* refactors the use of basic roles (ex. Viewer, Editor, Admin) use RBAC permissions (when supported), or falling back to basic roles when RBAC is not supported.

- updates the UserAction enum in grafana-plugin/src/state/userAction.ts. Previously this was hardcoded to a list of strings that were being returned by the OnCall API. Now the values here correspond to the permissions in plugin.json (plus a fallback role)

* changes per Gabriel's comments:
- get rid of group attribute in rbac roles
- remove displayName role attribute
- remove hidden role attribute
- add back role to includes section

* don't try to update user timezone if they don't have permission
2022-11-29 09:41:56 +01:00
Joey Orlando
eb97797d43
Merge pull request #880 from grafana/jorlando/mobile-app-qr-code
Fetch/Display Mobile App QR Code
2022-11-28 18:54:05 +01:00
Joey Orlando
5a4fc90fa4
fetch/render mobile app QR code in user settings modal 2022-11-28 18:47:59 +01:00