Skip to content

Commit

Permalink
Merge pull request #925 from TencentBlueKing/develop
Browse files Browse the repository at this point in the history
v1.7.11
  • Loading branch information
zhu327 authored Apr 7, 2022
2 parents d38287e + 36cc00c commit f9b3cd8
Show file tree
Hide file tree
Showing 15 changed files with 134 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions release.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# V1.7.11

### 缺陷修复
* 修复分级管理员申请单ITSM展示问题
* 修复前端合并选择实例问题

### 功能优化
* sentry sdk切换

# V1.7.10

### 缺陷修复
Expand Down
2 changes: 1 addition & 1 deletion saas/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.10
1.7.11
10 changes: 2 additions & 8 deletions saas/backend/common/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
11 changes: 4 additions & 7 deletions saas/backend/plugins/application_ticket/itsm/ticket_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 7 additions & 0 deletions saas/backend/tracing/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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()
45 changes: 45 additions & 0 deletions saas/backend/tracing/sentry.py
Original file line number Diff line number Diff line change
@@ -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="[email protected]",
# Can export the environment
# environment="production",
)
# set global tag
sentry_sdk.set_tag("service_name", "bk-iam-%s" % os.getenv("BKPAAS_PROCESS_TYPE", "unknown"))
3 changes: 0 additions & 3 deletions saas/build/v3/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# for deploy on paas v3
gunicorn==19.6.0
gevent==20.9.0

# for sentry
raven==6.5.0
27 changes: 8 additions & 19 deletions saas/config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
"backend.apps.mgmt",
]

# 登录中间件
_LOGIN_MIDDLEWARE = os.getenv("BKAPP_LOGIN_MIDDLEWARE", "backend.account.middlewares.LoginMiddleware")

MIDDLEWARE = [
"backend.common.middlewares.CustomProfilerMiddleware",
Expand All @@ -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",
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"
Expand All @@ -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",)


Expand Down Expand Up @@ -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")
Expand Down
36 changes: 35 additions & 1 deletion saas/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions saas/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion saas/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 2 additions & 1 deletion saas/requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions saas/resources/version_log/V1.7.11_2022-04-07.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# V1.7.11 版本更新日志

### 缺陷修复
* 修复分级管理员申请单ITSM展示问题
* 修复前端合并选择实例问题

### 功能优化
* sentry sdk切换
8 changes: 8 additions & 0 deletions saas/resources/version_log/V1.7.11_2022-04-07_en.md
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f9b3cd8

Please sign in to comment.