diff --git a/frontend/src/views/grading-admin/components/render-instance-table.vue b/frontend/src/views/grading-admin/components/render-instance-table.vue index d8fc1843b..7a02477fe 100644 --- a/frontend/src/views/grading-admin/components/render-instance-table.vue +++ b/frontend/src/views/grading-admin/components/render-instance-table.vue @@ -427,6 +427,7 @@ && !item.isAggregate && relatedActions.includes(item.id) && curData.system_id === item.system_id + && item.resource_groups[this.curGroupIndex] && !item.resource_groups[this.curGroupIndex].related_resource_types.every(sub => sub.empty); })); if (relatedList.length > 0) { @@ -471,6 +472,7 @@ } payload.forEach(item => { const curIndex = this.tableList.findIndex(sub => sub.id === item.id + && item.resource_groups[this.curGroupIndex] && sub.system_id === item.resource_groups[this.curGroupIndex] .related_resource_types[0].system_id && !sub.isExpiredAtDisabled); if (curIndex > -1) { diff --git a/release.md b/release.md index c48ac825b..b4c59cc21 100644 --- a/release.md +++ b/release.md @@ -1,3 +1,12 @@ +# V1.7.11 + +### 缺陷修复 +* 修复分级管理员申请单ITSM展示问题 +* 修复前端合并选择实例问题 + +### 功能优化 +* sentry sdk切换 + # V1.7.10 ### 缺陷修复 diff --git a/saas/VERSION b/saas/VERSION index a412349ef..8f8b3f72a 100644 --- a/saas/VERSION +++ b/saas/VERSION @@ -1 +1 @@ -1.7.10 +1.7.11 diff --git a/saas/backend/common/middlewares.py b/saas/backend/common/middlewares.py index 906a0ff60..d89f58ed1 100644 --- a/saas/backend/common/middlewares.py +++ b/saas/backend/common/middlewares.py @@ -16,12 +16,7 @@ from django.http import Http404, JsonResponse from django.utils.deprecation import MiddlewareMixin from pyinstrument.middleware import ProfilerMiddleware - -try: - from raven.contrib.django.raven_compat.models import sentry_exception_handler -# 兼容未有安装sentry的情况 -except ImportError: - sentry_exception_handler = None +from sentry_sdk import capture_exception from backend.common.local import local @@ -109,8 +104,7 @@ def process_exception(self, request, exception): response.status_code = 500 # notify sentry - if sentry_exception_handler is not None: - sentry_exception_handler(request=request) + capture_exception(exception) return response diff --git a/saas/backend/plugins/application_ticket/itsm/ticket_content.py b/saas/backend/plugins/application_ticket/itsm/ticket_content.py index de51f2ff1..cdaece9c6 100644 --- a/saas/backend/plugins/application_ticket/itsm/ticket_content.py +++ b/saas/backend/plugins/application_ticket/itsm/ticket_content.py @@ -421,18 +421,15 @@ class AuthScopeActionColumnValue(BaseModel): """权限表格每一列的值""" action: BaseDictStrValue - related_resource_types: ActionRelatedResourceTypeInfo + resource_groups: ResourceGroupInfo @classmethod def from_policy(cls, policy: ApplicationPolicyInfo): if len(policy.resource_groups) == 0: - related_resource_types = ActionRelatedResourceTypeInfo(value=[BaseDictStrValue(value="无需关联实例")]) + resource_groups = ResourceGroupInfo(value=[BaseDictStrValue(value="无需关联实例")]) else: - # NOTE: 当前默认只有一组 - related_resource_types = ActionRelatedResourceTypeInfo.from_resource_types( - policy.resource_groups[0].related_resource_types - ) - return cls(action=BaseDictStrValue(value=policy.name), related_resource_types=related_resource_types) + resource_groups = ResourceGroupInfo.from_resource_groups(policy.resource_groups) + return cls(action=BaseDictStrValue(value=policy.name), resource_groups=resource_groups) class AuthScopeActionTable(BaseModel): diff --git a/saas/backend/tracing/apps.py b/saas/backend/tracing/apps.py index 5835fec1a..f46754015 100644 --- a/saas/backend/tracing/apps.py +++ b/saas/backend/tracing/apps.py @@ -12,6 +12,7 @@ from celery.signals import worker_process_init from django.apps import AppConfig +from .sentry import init_sentry_sdk from .setup import setup_by_settings @@ -21,8 +22,14 @@ class TracingConfig(AppConfig): def ready(self): setup_by_settings() # from .celery import worker_process_init_otel_trace_setup # noqa + init_sentry_sdk() @worker_process_init.connect(weak=False) def worker_process_init_otel_trace_setup(*args, **kwargs): setup_by_settings() + + +@worker_process_init.connect(weak=False) +def worker_process_init_sentry_setup(*args, **kwargs): + init_sentry_sdk() diff --git a/saas/backend/tracing/sentry.py b/saas/backend/tracing/sentry.py new file mode 100644 index 000000000..5a4f1d62f --- /dev/null +++ b/saas/backend/tracing/sentry.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +""" +TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-权限中心(BlueKing-IAM) available. +Copyright (C) 2017-2021 THL A29 Limited, a Tencent company. All rights reserved. +Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. +You may obtain a copy of the License at http://opensource.org/licenses/MIT +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. +""" +import os + +import sentry_sdk +from sentry_sdk.integrations.celery import CeleryIntegration +from sentry_sdk.integrations.django import DjangoIntegration +from sentry_sdk.integrations.redis import RedisIntegration + + +def init_sentry_sdk(): + """Register celery error events to sentry""" + from django.conf import settings + + if settings.SENTRY_DSN: + # 初始化 sentry_sdk + sentry_sdk.init( + # debug=True, + dsn=settings.SENTRY_DSN, + integrations=[DjangoIntegration(), CeleryIntegration(), RedisIntegration()], + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for performance monitoring. + # We recommend adjusting this value in production, + traces_sample_rate=1.0, + # If you wish to associate users to errors (assuming you are using + # django.contrib.auth) you may enable sending PII data. + send_default_pii=True, + # By default the SDK will try to use the SENTRY_RELEASE + # environment variable, or infer a git commit + # SHA as release, however you may want to set + # something more human-readable. + # release="myapp@1.0.0", + # Can export the environment + # environment="production", + ) + # set global tag + sentry_sdk.set_tag("service_name", "bk-iam-%s" % os.getenv("BKPAAS_PROCESS_TYPE", "unknown")) diff --git a/saas/build/v3/requirements.txt b/saas/build/v3/requirements.txt index 9fef38c46..4cd221c35 100644 --- a/saas/build/v3/requirements.txt +++ b/saas/build/v3/requirements.txt @@ -1,6 +1,3 @@ # for deploy on paas v3 gunicorn==19.6.0 gevent==20.9.0 - -# for sentry -raven==6.5.0 diff --git a/saas/config/default.py b/saas/config/default.py index 505a0cb7b..0b189338e 100644 --- a/saas/config/default.py +++ b/saas/config/default.py @@ -66,6 +66,8 @@ "backend.apps.mgmt", ] +# 登录中间件 +_LOGIN_MIDDLEWARE = os.getenv("BKAPP_LOGIN_MIDDLEWARE", "backend.account.middlewares.LoginMiddleware") MIDDLEWARE = [ "backend.common.middlewares.CustomProfilerMiddleware", @@ -79,7 +81,7 @@ "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.security.SecurityMiddleware", "whitenoise.middleware.WhiteNoiseMiddleware", - "backend.account.middlewares.LoginMiddleware", + _LOGIN_MIDDLEWARE, "backend.account.middlewares.TimezoneMiddleware", "backend.account.middlewares.RoleAuthenticationMiddleware", "django_prometheus.middleware.PrometheusAfterMiddleware", @@ -114,7 +116,7 @@ # Password validation # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators -AUTHENTICATION_BACKENDS = ("backend.account.backends.TokenBackend",) +AUTHENTICATION_BACKENDS = (os.getenv("BKAPP_AUTHENTICATION_BACKEND", "backend.account.backends.TokenBackend"),) AUTH_USER_MODEL = "account.User" @@ -286,16 +288,10 @@ djcelery.setup_loader() -# sentry support -if os.getenv("SENTRY_DSN"): - INSTALLED_APPS += ("raven.contrib.django.raven_compat",) - MIDDLEWARE += ("raven.contrib.django.raven_compat.middleware.Sentry404CatchMiddleware",) - RAVEN_CONFIG = { - "dsn": os.getenv("SENTRY_DSN"), - } +# tracing: sentry support +SENTRY_DSN = os.getenv("SENTRY_DSN") - -# tracing 相关配置 +# tracing: otel 相关配置 # if enable, default false ENABLE_OTEL_TRACE = os.getenv("BKAPP_ENABLE_OTEL_TRACE", "False").lower() == "true" BKAPP_OTEL_INSTRUMENT_DB_API = os.getenv("BKAPP_OTEL_INSTRUMENT_DB_API", "True").lower() == "true" @@ -304,7 +300,7 @@ BKAPP_OTEL_BK_DATA_ID = int(os.getenv("BKAPP_OTEL_BK_DATA_ID", "-1")) BKAPP_OTEL_GRPC_HOST = os.getenv("BKAPP_OTEL_GRPC_HOST") -if ENABLE_OTEL_TRACE: +if ENABLE_OTEL_TRACE or SENTRY_DSN: INSTALLED_APPS += ("backend.tracing",) @@ -377,13 +373,6 @@ # 最长已过期权限删除期限 MAX_EXPIRED_POLICY_DELETE_TIME = 365 * 24 * 60 * 60 # 1年 -# 前端页面功能开关 -ENABLE_FRONT_END_FEATURES = { - "enable_model_build": os.getenv("BKAPP_ENABLE_FRONT_END_MODEL_BUILD", "False").lower() == "true", - "enable_permission_handover": os.getenv("BKAPP_ENABLE_FRONT_END_PERMISSION_HANDOVER", "False").lower() == "true", -} - - # 用于发布订阅的Redis PUB_SUB_REDIS_HOST = os.getenv("BKAPP_PUB_SUB_REDIS_HOST") PUB_SUB_REDIS_PORT = os.getenv("BKAPP_PUB_SUB_REDIS_PORT") diff --git a/saas/poetry.lock b/saas/poetry.lock index 777270818..ced34ad31 100644 --- a/saas/poetry.lock +++ b/saas/poetry.lock @@ -1333,6 +1333,36 @@ category = "main" optional = false python-versions = ">=3.5" +[[package]] +name = "sentry-sdk" +version = "1.5.6" +description = "Python client for Sentry (https://sentry.io)" +category = "main" +optional = false +python-versions = "*" + +[package.dependencies] +certifi = "*" +urllib3 = ">=1.10.0" + +[package.extras] +aiohttp = ["aiohttp (>=3.5)"] +beam = ["apache-beam (>=2.12)"] +bottle = ["bottle (>=0.12.13)"] +celery = ["celery (>=3)"] +chalice = ["chalice (>=1.16.0)"] +django = ["django (>=1.8)"] +falcon = ["falcon (>=1.4)"] +flask = ["flask (>=0.11)", "blinker (>=1.1)"] +httpx = ["httpx (>=0.16.0)"] +pure_eval = ["pure-eval", "executing", "asttokens"] +pyspark = ["pyspark (>=2.4.4)"] +quart = ["quart (>=0.16.1)", "blinker (>=1.1)"] +rq = ["rq (>=0.6)"] +sanic = ["sanic (>=0.8)"] +sqlalchemy = ["sqlalchemy (>=1.2)"] +tornado = ["tornado (>=5)"] + [[package]] name = "six" version = "1.15.0" @@ -1504,7 +1534,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytes [metadata] lock-version = "1.1" python-versions = "3.6.6" -content-hash = "e2f942dc506ba5563d95b8e842708174109bd57895ee8fc5120e67be0d2a4304" +content-hash = "819f8fe00a3e058bd7ae67629b7db5b146fcc5f9a1b6917523604f8ae546ed72" [metadata.files] aenum = [ @@ -2355,6 +2385,10 @@ requests = [ {file = "ruamel.yaml.clib-0.2.6-cp39-cp39-win_amd64.whl", hash = "sha256:825d5fccef6da42f3c8eccd4281af399f21c02b32d98e113dbc631ea6a6ecbc7"}, {file = "ruamel.yaml.clib-0.2.6.tar.gz", hash = "sha256:4ff604ce439abb20794f05613c374759ce10e3595d1867764dd1ae675b85acbd"}, ] +sentry-sdk = [ + {file = "sentry-sdk-1.5.6.tar.gz", hash = "sha256:ac2a50128409d57655279817aedcb7800cace1f76b266f3dd62055d5afd6e098"}, + {file = "sentry_sdk-1.5.6-py2.py3-none-any.whl", hash = "sha256:1ab34e3851a34aeb3d1af1a0f77cec73978c4e9698e5210d050e4932953cb241"}, +] six = [ {file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"}, {file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"}, diff --git a/saas/pyproject.toml b/saas/pyproject.toml index ebfb23dfa..f1dbb1af5 100644 --- a/saas/pyproject.toml +++ b/saas/pyproject.toml @@ -112,6 +112,7 @@ opentelemetry-instrumentation-celery = "^0.26b1" opentelemetry-instrumentation-logging = "^0.26b1" opentelemetry-exporter-jaeger = "1.7.1" openpyxl = "^3.0.9" +sentry-sdk = "^1.5.6" [tool.poetry.dev-dependencies] # For flake8 support pyproject.toml diff --git a/saas/requirements.txt b/saas/requirements.txt index 7c6e1732c..4d875499e 100644 --- a/saas/requirements.txt +++ b/saas/requirements.txt @@ -81,12 +81,13 @@ redis==2.10.6 requests==2.26.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0") ruamel.yaml.clib==0.2.6; platform_python_implementation == "CPython" and python_version < "3.10" and python_version >= "3.6" ruamel.yaml==0.17.10; python_version >= "3.6" +sentry-sdk==1.5.6 six==1.15.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.3.0") sqlparse==0.4.2; python_version >= "3.6" thrift==0.15.0; python_version >= "3.6" typing-extensions==3.7.4.3 uritemplate==3.0.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6" -urllib3==1.26.6; python_full_version >= "3.6.1" and python_version < "4" and python_full_version < "4.0.0" and python_version >= "3.6" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6") +urllib3==1.26.6; python_full_version >= "3.6.1" and python_version < "4" and python_full_version < "4.0.0" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version < "4") and python_version >= "3.6" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6") werkzeug==1.0.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") whitenoise==5.1.0; python_version >= "3.5" and python_version < "4" wrapt==1.13.3; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" diff --git a/saas/requirements_dev.txt b/saas/requirements_dev.txt index ac42834f1..f8ff35f31 100644 --- a/saas/requirements_dev.txt +++ b/saas/requirements_dev.txt @@ -109,6 +109,7 @@ regex==2021.8.3; python_full_version >= "3.6.2" requests==2.26.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0") ruamel.yaml.clib==0.2.6; platform_python_implementation == "CPython" and python_version < "3.10" and python_version >= "3.6" ruamel.yaml==0.17.10; python_version >= "3.6" +sentry-sdk==1.5.6 six==1.15.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.3.0") sqlparse==0.4.2; python_version >= "3.6" thrift==0.15.0; python_version >= "3.6" @@ -122,7 +123,7 @@ types-requests==2.25.6 types-six==0.1.9 typing-extensions==3.7.4.3 uritemplate==3.0.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6" -urllib3==1.26.6; python_full_version >= "3.6.1" and python_version < "4" and python_full_version < "4.0.0" and python_version >= "3.6" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6") +urllib3==1.26.6; python_full_version >= "3.6.1" and python_version < "4" and python_full_version < "4.0.0" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version < "4") and python_version >= "3.6" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6") werkzeug==1.0.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0") whitenoise==5.1.0; python_version >= "3.5" and python_version < "4" wrapt==1.13.3; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6" diff --git a/saas/resources/version_log/V1.7.11_2022-04-07.md b/saas/resources/version_log/V1.7.11_2022-04-07.md new file mode 100644 index 000000000..dc1794a64 --- /dev/null +++ b/saas/resources/version_log/V1.7.11_2022-04-07.md @@ -0,0 +1,8 @@ +# V1.7.11 版本更新日志 + +### 缺陷修复 +* 修复分级管理员申请单ITSM展示问题 +* 修复前端合并选择实例问题 + +### 功能优化 +* sentry sdk切换 diff --git a/saas/resources/version_log/V1.7.11_2022-04-07_en.md b/saas/resources/version_log/V1.7.11_2022-04-07_en.md new file mode 100644 index 000000000..7e2efeb56 --- /dev/null +++ b/saas/resources/version_log/V1.7.11_2022-04-07_en.md @@ -0,0 +1,8 @@ +# V1.7.11 ChangeLog + +### Bug Fixes +* Fixed the ITSM display problem of the application form for grading administrators +* Fix front-end merge selection instance problem + +### Optimization Updates +* sentry sdk switch