Skip to content

Commit

Permalink
Merge pull request #3150 from grafana/dev
Browse files Browse the repository at this point in the history
Dev to main
  • Loading branch information
mderynck authored Oct 16, 2023
2 parents 6347594 + 1871106 commit 0e41125
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/update-make-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ name: Update `make docs` procedure
- cron: "0 7 * * 1-5"
jobs:
main:
if: github.repository == 'grafana/oncall'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Update procedure
if: github.repository != 'grafana/writers-toolkit'
run: |
curl -s -Lo docs/docs.mk https://raw.githubusercontent.com/grafana/writers-toolkit/main/docs/docs.mk
curl -s -Lo docs/make-docs https://raw.githubusercontent.com/grafana/writers-toolkit/main/docs/make-docs
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## v1.3.44 (2023-10-16)

### Added

- Update plugin OnCaller role permissions ([#3145](https://github.com/grafana/oncall/pull/3145))

### Fixed

- Fix plugin status to always return URL with trailing / @mderynck ([#3122](https://github.com/grafana/oncall/pull/3122))

## v1.3.43 (2023-10-05)

Expand Down
6 changes: 6 additions & 0 deletions docs/make-docs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
# [Semantic versioning](https://semver.org/) is used to help the reader identify the significance of changes.
# Changes are relevant to this script and the support docs.mk GNU Make interface.

# ## 4.2.2 (2023-10-05)

# - Added support for Jira data source and MongoDB data source plugins repositories.

# ## 4.2.1 (2023-09-13)

# ## Fixed
Expand Down Expand Up @@ -213,6 +217,8 @@ SOURCES_grafana_cloud_frontend_observability_faro_web_sdk='faro-web-sdk'
SOURCES_helm_charts_mimir_distributed='mimir'
SOURCES_helm_charts_tempo_distributed='tempo'
SOURCES_opentelemetry='opentelemetry-docs'
SOURCES_plugins_grafana_jira_datasource='jira-datasource'
SOURCES_plugins_grafana_mongodb_datasource='mongodb-datasource'
SOURCES_plugins_grafana_splunk_datasource='splunk-datasource'

VERSIONS_as_code='UNVERSIONED'
Expand Down
6 changes: 4 additions & 2 deletions engine/apps/alerts/tasks/acknowledge_reminder.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from functools import partial

from django.conf import settings
from django.db import transaction

Expand Down Expand Up @@ -60,7 +62,7 @@ def acknowledge_reminder_task(alert_group_pk: int, unacknowledge_process_id: str
log_record = alert_group.log_records.create(
type=AlertGroupLogRecord.TYPE_ACK_REMINDER_TRIGGERED, author=alert_group.acknowledged_by_user
)
transaction.on_commit(lambda: send_alert_group_signal.delay(log_record.pk))
transaction.on_commit(partial(send_alert_group_signal.delay, log_record.pk))


@shared_dedicated_queue_retry_task(autoretry_for=(Exception,), retry_backoff=True, max_retries=MAX_RETRIES)
Expand Down Expand Up @@ -108,6 +110,6 @@ def unacknowledge_timeout_task(alert_group_pk: int, unacknowledge_process_id: st
log_record = alert_group.log_records.create(
type=AlertGroupLogRecord.TYPE_AUTO_UN_ACK, author=alert_group.acknowledged_by_user
)
transaction.on_commit(lambda: send_alert_group_signal.delay(log_record.pk))
transaction.on_commit(partial(send_alert_group_signal.delay, log_record.pk))
alert_group.unacknowledge()
alert_group.start_escalation_if_needed()
19 changes: 18 additions & 1 deletion engine/apps/grafana_plugin/tests/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
GRAFANA_URL = "hello.com"
LICENSE = "asdfasdf"
VERSION = "asdfasdfasdf"
BASE_URL = "http://asdasdqweqweqw.com/oncall"
BASE_URL = "http://asdasdqweqweqw.com/oncall/"
BASE_URL_NO_TRAILING_SLASH = "http://asdasdqweqweqw.com/oncall"
GRAFANA_CONTEXT_DATA = {"IsAnonymous": False}
SETTINGS = {"LICENSE": LICENSE, "VERSION": VERSION, "BASE_URL": BASE_URL}
SETTINGS_ALT = SETTINGS | {"BASE_URL": BASE_URL_NO_TRAILING_SLASH}


def _check_status_response(auth_headers, client):
Expand Down Expand Up @@ -86,3 +88,18 @@ def test_status_mobile_app_auth_token(

auth_headers = {"HTTP_AUTHORIZATION": f"{auth_token}"}
_check_status_response(auth_headers, client)


@pytest.mark.django_db
@override_settings(**SETTINGS_ALT)
def test_status_base_url_trailing_slash(make_organization_and_user_with_plugin_token, make_user_auth_headers):
organization, user, token = make_organization_and_user_with_plugin_token()
organization.grafana_url = GRAFANA_URL
organization.api_token_status = Organization.API_TOKEN_STATUS_OK
organization.save(update_fields=["grafana_url", "api_token_status"])

client = APIClient()
auth_headers = make_user_auth_headers(
user, token, grafana_token=GRAFANA_TOKEN, grafana_context_data=GRAFANA_CONTEXT_DATA
)
_check_status_response(auth_headers, client)
5 changes: 3 additions & 2 deletions engine/apps/grafana_plugin/views/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from apps.mobile_app.auth import MobileAppAuthTokenAuthentication
from apps.user_management.models import Organization
from common.api_helpers.mixins import GrafanaHeadersMixin
from common.api_helpers.utils import create_engine_url


class StatusView(GrafanaHeadersMixin, APIView):
Expand All @@ -35,14 +36,14 @@ def post(self, request: Request) -> Response:
is_installed = False
token_ok = False
allow_signup = True
api_url = settings.BASE_URL
api_url = create_engine_url("")

# Check if organization is in OnCall database
if organization:
is_installed = True
token_ok = organization.api_token_status == Organization.API_TOKEN_STATUS_OK
if organization.is_moved:
api_url = organization.migration_destination.oncall_backend_url
api_url = create_engine_url("", override_base=organization.migration_destination.oncall_backend_url)
else:
allow_signup = DynamicSetting.objects.get_or_create(
name="allow_plugin_organization_signup", defaults={"boolean_value": True}
Expand Down
4 changes: 3 additions & 1 deletion grafana-plugin/src/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,13 @@
{
"role": {
"name": "OnCaller",
"description": "Grants read access to everything in OnCall. In addition, grants edit access to Alert Groups and Schedules",
"description": "Grants read access to everything in OnCall. In addition, grants edit access to Alert Groups, Schedules and own settings",
"permissions": [
{ "action": "plugins.app:access", "scope": "plugins:id:grafana-oncall-app" },

{ "action": "grafana-oncall-app.alert-groups:read" },
{ "action": "grafana-oncall-app.alert-groups:write" },
{ "action": "grafana-oncall-app.alert-groups:direct-paging" },

{ "action": "grafana-oncall-app.integrations:read" },
{ "action": "grafana-oncall-app.escalation-chains:read" },
Expand All @@ -336,6 +337,7 @@
{ "action": "grafana-oncall-app.notifications:read" },
{ "action": "grafana-oncall-app.notification-settings:read" },
{ "action": "grafana-oncall-app.user-settings:read" },
{ "action": "grafana-oncall-app.user-settings:write" },
{ "action": "grafana-oncall-app.other-settings:read" }
]
},
Expand Down

0 comments on commit 0e41125

Please sign in to comment.