Skip to content

Commit

Permalink
remove comment
Browse files Browse the repository at this point in the history
  • Loading branch information
mwheeler-ep committed Jan 5, 2025
1 parent 03c29f8 commit 6238c72
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 36 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ venv
pnpm.lock
node_modules

test-results
test-results
.pnpm
.pnpm/*
.pnpm-store
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ init: ## build the frontend plugin code then run make start
# this makes sure that it will be available when the grafana container starts up without the need to
# restart the grafana container initially
ifeq ($(findstring $(UI_PROFILE),$(COMPOSE_PROFILES)),$(UI_PROFILE))
$(call run_ui_docker_command,pnpm install && pnpm build:dev)
$(call run_ui_docker_command,pnpm install && pnpm build:dev && pnpm mage:build-dev)
endif

stop: # stop all of the docker containers
Expand Down Expand Up @@ -225,7 +225,7 @@ ui-command: ## run any command, inside of a UI docker container, passing `$CMD`
$(call run_ui_docker_command,$(CMD))

exec-engine: ## exec into engine container's bash
docker exec -it oncall_engine bash
docker exec -it oncallengine bash

_backend-debug-enable: ## enable Django's debug mode and Silk profiling (this is disabled by default for performance reasons)
$(shell ./dev/add_env_var.sh DEBUG True $(DEV_ENV_FILE))
Expand Down
2 changes: 1 addition & 1 deletion dev/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ global:
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ["host.docker.internal:8080"]
- targets: ["oncallengine:8080"]
8 changes: 5 additions & 3 deletions docker-compose-developer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ services:
- oncall_ui

oncall_engine:
container_name: oncall_engine
container_name: oncallengine
labels: *oncall-labels
build: *oncall-build-args
restart: always
Expand Down Expand Up @@ -323,7 +323,7 @@ services:
GF_SECURITY_ADMIN_PASSWORD: oncall
GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: grafana-oncall-app
GF_FEATURE_TOGGLES_ENABLE: externalServiceAccounts
ONCALL_API_URL: http://host.docker.internal:8080
ONCALL_API_URL: http://oncallengine:8080
GF_AUTH_MANAGED_SERVICE_ACCOUNTS_ENABLED: true
env_file:
- ./dev/.env.${DB}.dev
Expand All @@ -341,7 +341,7 @@ services:
- grafanadata_dev:/var/lib/grafana
- ./grafana-plugin:/var/lib/grafana/plugins/grafana-plugin
- ./dev/grafana/provisioning:/etc/grafana/provisioning
- ${GRAFANA_DEV_PROVISIONING:-/dev/null}:/etc/grafana/grafana.ini
- ./dev/grafana/grafana.dev.ini:/etc/grafana/grafana.ini
depends_on:
postgres:
condition: service_healthy
Expand Down Expand Up @@ -370,3 +370,5 @@ networks:
default:
name: oncall_dev
labels: *oncall-labels


Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ def populate_slack_channel(apps, schema_editor):
logger.info("Starting migration to populate slack_channel field.")

sql = f"""
UPDATE {ChannelFilter._meta.db_table} AS cf
JOIN {AlertReceiveChannel._meta.db_table} AS arc ON arc.id = cf.alert_receive_channel_id
JOIN {Organization._meta.db_table} AS org ON org.id = arc.organization_id
JOIN {SlackChannel._meta.db_table} AS sc ON sc.slack_id = cf._slack_channel_id
AND sc.slack_team_identity_id = org.slack_team_identity_id
SET cf.slack_channel_id = sc.id
WHERE cf._slack_channel_id IS NOT NULL
AND org.slack_team_identity_id IS NOT NULL;
with temp as (
SELECT cf_s.slack_channel_id as slack_channel_id, sc.id as id
FROM {ChannelFilter._meta.db_table} AS cf_s
JOIN {AlertReceiveChannel._meta.db_table} AS arc ON arc.id = cf_s.alert_receive_channel_id
JOIN {Organization._meta.db_table} AS org ON org.id = arc.organization_id
JOIN {SlackChannel._meta.db_table} AS sc ON sc.slack_id = cf_s._slack_channel_id
AND sc.slack_team_identity_id = org.slack_team_identity_id
WHERE org.slack_team_identity_id IS NOT NULL and cf_s._slack_channel_id IS NOT NULL
)
UPDATE {ChannelFilter._meta.db_table} as update_cf
SET slack_channel_id = temp.id
FROM temp
where update_cf.slack_channel_id = temp.slack_channel_id
"""

with schema_editor.connection.cursor() as cursor:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,24 @@ def populate_slack_channel(apps, schema_editor):
logger.info("Starting migration to populate slack_channel field.")

sql = f"""
UPDATE {ResolutionNoteSlackMessage._meta.db_table} AS rsm
JOIN {AlertGroup._meta.db_table} AS ag ON ag.id = rsm.alert_group_id
with temp as (
SELECT rsm_t._slack_channel_id as _slack_channel_id, sc.id as id
FROM {ResolutionNoteSlackMessage._meta.db_table} AS rsm_t
JOIN {AlertGroup._meta.db_table} AS ag ON ag.id = rsm_t.alert_group_id
JOIN {AlertReceiveChannel._meta.db_table} AS arc ON arc.id = ag.channel_id
JOIN {Organization._meta.db_table} AS org ON org.id = arc.organization_id
JOIN {SlackChannel._meta.db_table} AS sc ON sc.slack_id = rsm._slack_channel_id
JOIN {SlackChannel._meta.db_table} AS sc ON sc.slack_id = rsm_t._slack_channel_id
AND sc.slack_team_identity_id = org.slack_team_identity_id
SET rsm.slack_channel_id = sc.id
WHERE rsm._slack_channel_id IS NOT NULL
AND org.slack_team_identity_id IS NOT NULL;
WHERE rsm_t._slack_channel_id IS NOT NULL
AND org.slack_team_identity_id IS NOT NULL
)
UPDATE {ResolutionNoteSlackMessage._meta.db_table} AS rsm
SET slack_channel_id = temp.id
FROM temp
WHERE rsm._slack_channel_id = temp._slack_channel_id
"""

with schema_editor.connection.cursor() as cursor:
Expand Down
3 changes: 0 additions & 3 deletions engine/apps/metrics_exporter/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,6 @@ def metrics_bulk_update_team_label_cache(teams_updated_data: dict, organization_

metric_alert_groups_total = cache.get(metric_alert_groups_total_key, {})
metric_alert_groups_response_time = cache.get(metric_alert_groups_response_time_key, {})

# TODO need to work out how to handle team changes... or if we need to.

for team_id, team_data in teams_updated_data.items():
for index in metric_alert_groups_total:
if metric_alert_groups_total[index]["team_id"] == team_id:
Expand Down
20 changes: 14 additions & 6 deletions engine/apps/schedules/migrations/0019_auto_20241021_1735.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ def populate_slack_channel(apps, schema_editor):
logger.info("Starting migration to populate slack_channel field.")

sql = f"""
with temp as (
SELECT ocs_t.slack_channel_id as slack_channel_id, sc.id as id
FROM {OnCallSchedule._meta.db_table} AS ocs_t
JOIN {Organization._meta.db_table} AS org ON org.id = ocs_t.organization_id
JOIN {SlackChannel._meta.db_table} AS sc ON sc.slack_id = ocs_t.channel
AND sc.slack_team_identity_id = org.slack_team_identity_id
WHERE ocs_t.channel IS NOT NULL
AND org.slack_team_identity_id IS NOT NULL
)
UPDATE {OnCallSchedule._meta.db_table} AS ocs
JOIN {Organization._meta.db_table} AS org ON org.id = ocs.organization_id
JOIN {SlackChannel._meta.db_table} AS sc ON sc.slack_id = ocs.channel
AND sc.slack_team_identity_id = org.slack_team_identity_id
SET ocs.slack_channel_id = sc.id
WHERE ocs.channel IS NOT NULL
AND org.slack_team_identity_id IS NOT NULL;
SET slack_channel_id = temp.id
FROM temp
WHERE ocs.slack_channel_id = temp.slack_channel_id
"""

with schema_editor.connection.cursor() as cursor:
Expand Down
18 changes: 13 additions & 5 deletions engine/apps/user_management/migrations/0026_auto_20241017_1919.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@ def populate_default_slack_channel(apps, schema_editor):
logger.info("Starting migration to populate default_slack_channel field.")

sql = f"""
with temp as (
SELECT org_t.default_slack_channel_id as default_slack_channel_id, sc.id as id
FROM {Organization._meta.db_table} AS org_t
JOIN {SlackChannel._meta.db_table} AS sc ON sc.slack_id = org_t.general_log_channel_id
AND sc.slack_team_identity_id = org_t.slack_team_identity_id
WHERE org_t.general_log_channel_id IS NOT NULL
AND org_t.slack_team_identity_id IS NOT NULL
)
UPDATE {Organization._meta.db_table} AS org
JOIN {SlackChannel._meta.db_table} AS sc ON sc.slack_id = org.general_log_channel_id
AND sc.slack_team_identity_id = org.slack_team_identity_id
SET org.default_slack_channel_id = sc.id
WHERE org.general_log_channel_id IS NOT NULL
AND org.slack_team_identity_id IS NOT NULL;
SET default_slack_channel_id = temp.id
FROM temp
WHERE org.default_slack_channel_id = temp.default_slack_channel_id
"""

with schema_editor.connection.cursor() as cursor:
Expand Down
5 changes: 5 additions & 0 deletions grafana-plugin/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ FROM node:20.15.1-alpine

WORKDIR /etc/app
ENV PATH /etc/app/node_modules/.bin:$PATH
RUN npm install -g pnpm
RUN apk add go git && git clone https://github.com/magefile/mage && \
cd mage && mkdir /root/go/ && \
go run bootstrap.go

ENV PATH="/root/go/bin/:$PATH"
CMD ["pnpm", "start"]
2 changes: 1 addition & 1 deletion grafana-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"serve": "serve -p 3001 ./dist",
"dev:serve": "concurrently --names \"serve,dev\" --prefix-colors \"blue,green\" \"pnpm serve\" \"pnpm dev\"",
"sign": "npx --yes @grafana/sign-plugin@latest",
"start": "pnpm watch",
"start": "pnpm mage:build-dev; pnpm dev:serve",
"setversion": "setversion",
"type-check": "tsc --noEmit",
"type-check:watch": "pnpm type-check --watch --preserveWatchOutput false",
Expand Down
1 change: 1 addition & 0 deletions grafana-plugin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"include": ["src", "e2e-tests", "playwright.config.ts"],
"types": ["node", "@emotion/core"],
"compilerOptions": {
"jsx": "react",
"composite": true,
"declaration": true,
"rootDir": "",
Expand Down

0 comments on commit 6238c72

Please sign in to comment.