oncall-engine/engine/common
Joey Orlando 2582a1b1dc
Refactor how RBAC enabled/disabled status is determined for Grafana Cloud stacks (#4279)
# What this PR does

In cloud we are currently (somewhat) improperly determining whether or
not a Grafana stack had the `accessControlOnCall` feature flag enabled.
At first things worked fine. We would enable this feature toggle via the
Grafana Admin UI, and then the OnCall backend would read this value from
GCOM's `GET /instance/<stack_id>` endpoint (via
`config.feature_toggles`), and everything worked as expected.

There was a recent change made in `grafana/deployment_tools` to set this
feature flag to True for all stacks. However, for some reason, the GCOM
endpoint above doesn't return the `accessControlOnCall` feature toggle
value in `config.feature_toggles` if it is set in this manner (it only
returns the value if it is set via the Grafana Admin UI).

So what we should instead be doing is such instead of asking GCOM for
this feature toggle, infer whether RBAC is enabled on the stack by doing
a `HEAD /api/access-control/users/permissions/search` (this endpoint _is
only_ available on a Grafana stack if `accessControlOnCall` is enabled).

**Few caveats to this ☝️**
1. we first have to make sure that the cloud stack is in an `active`
state (ie. not paused). This is because, no matter if the
`accessControlOnCall` is enabled or not, if the stack is in a `paused`
state it will ALWAYS return `HTTP 200` which can be misleading and lead
to bugs (this feels like a bug on the Grafana API, will follow up with
core grafana team)
2. Once we roll out this change we will effectively **actually** be
enabling RBAC for OnCall for all orgs. The Identity Access team would
prefer a progressive rollout, which is why I decided to introduce the
concept of
[`settings.CLOUD_RBAC_ROLLOUT_PERCENTAGE`](https://github.com/grafana/oncall/pull/4279/files#diff-3383aef931e41e44d95829ad971641eeb98fe001be2f5da92217446d300ea1b3R918)
(see also [`Organization.
should_be_considered_for_rbac_permissioning`](https://github.com/grafana/oncall/pull/4279/files#diff-2ca9917f4f56349be39545ee8abd459be5076295d02ca3a7ec545152fcddccdfR348-R362))

## Which issue(s) this PR closes

Related to https://github.com/grafana/identity-access-team/issues/667

## 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-05-14 16:30:16 +00:00
..
api_helpers Display human readable time ranges in AG filters (#4288) 2024-05-02 14:23:33 +00:00
cloud_auth_api update mobile app proxy's usage of the Cloud Auth API (#4194) 2024-04-11 14:45:21 +00:00
constants remove all references to deprecated AlertGroup.is_restricted field (#3228) 2023-10-31 20:10:45 +00:00
custom_celery_tasks chore: fix some comments (#4055) 2024-03-14 15:36:00 +00:00
exceptions Add integration status_options endpoint listing backsync possible statuses (#4061) 2024-03-18 12:11:40 +00:00
insight_log Enable flake8-bugbear, fix issues (#3454) 2023-11-29 15:04:48 +00:00
jinja_templater Add datetimeparse Jinja2 template helper filter function (#4312) 2024-05-13 17:16:38 +00:00
migrations Add instruction on removing nullable fields from Django models (#2659) 2023-08-08 12:46:18 +00:00
oncall_gateway Handle 400 status codes from Chatops Proxy (#3886) 2024-02-13 14:36:49 +08:00
ordered_model Update OrderedModel.swap to retry on IntegrityError (#3940) 2024-02-22 20:51:05 +00:00
recaptcha Add validation of hostname for recapctha (#1445) 2023-03-06 08:59:48 +00:00
tests Add datetimeparse Jinja2 template helper filter function (#4312) 2024-05-13 17:16:38 +00:00
__init__.py World, meet OnCall! 2022-06-03 08:09:47 -06:00
cache.py patch redis cluster multi-key operations (#3496) 2023-12-04 13:08:57 -05:00
database.py Fix Grafana teams sync (#1652) 2023-03-28 18:26:24 +00:00
l10n.py add user locale field to mobile app user settings table + change going on call push notification text (#2131) 2023-06-14 12:19:58 -04:00
public_primary_keys.py Re-enable a few mypy rules + fix existing errors (#2725) 2023-08-03 09:43:03 +00:00
timezones.py shift swap requests model + CRUD endpoints (#2597) 2023-07-21 19:35:19 +00:00
utils.py Refactor how RBAC enabled/disabled status is determined for Grafana Cloud stacks (#4279) 2024-05-14 16:30:16 +00:00