Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 新业务偶发grafana初始化缺少admin用户权限 --bug=132687483 #3516

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bkmonitor/packages/monitor_web/grafana/provisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from blueapps.conf import settings

from bk_dataview.api import get_or_create_user, sync_user_role
from bk_dataview.provisioning import Dashboard, SimpleProvisioning
from bkmonitor.commons.tools import is_ipv6_biz
from monitor_web.grafana.utils import patch_home_panels
Expand Down Expand Up @@ -45,6 +46,12 @@ def upsert_dashboards(cls, org_id, org_name, dashboard_mapping):
)
)
not_created = dashboard_keys - created

if not_created:
# 确保admin用户存在
user = get_or_create_user("admin")
sync_user_role(org_id, user["id"], "Admin")

for i in not_created:
# 不存在则进行创建
if cls.create_default_dashboard(org_id, f"{dashboard_mapping[i]}.json", bk_biz_id=org_name):
Expand Down