-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
678 additions
and
187 deletions.
There are no files selected for viewing
73 changes: 0 additions & 73 deletions
73
dbm-ui/backend/db_periodic_task/local_tasks/db_meta/db_meta_check/check_cluster_topo.py
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
dbm-ui/backend/db_periodic_task/local_tasks/db_meta/db_meta_check/check_instance_belong.py
This file was deleted.
Oops, something went wrong.
63 changes: 0 additions & 63 deletions
63
dbm-ui/backend/db_periodic_task/local_tasks/db_meta/db_meta_check/check_replicate_role.py
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...backend/db_periodic_task/local_tasks/db_meta/db_meta_check/mysql_cluster_topo/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. | ||
Copyright (C) 2017-2023 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 https://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. | ||
""" |
26 changes: 26 additions & 0 deletions
26
...d/db_periodic_task/local_tasks/db_meta/db_meta_check/mysql_cluster_topo/check_response.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. | ||
Copyright (C) 2017-2023 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 https://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. | ||
""" | ||
from typing import Optional, Union | ||
|
||
from backend.db_meta.models import ProxyInstance, StorageInstance | ||
from backend.db_report.enums import MetaCheckSubType | ||
|
||
|
||
class CheckResponse: | ||
def __init__( | ||
self, | ||
msg: str, | ||
check_subtype: MetaCheckSubType, | ||
instance: Optional[Union[StorageInstance, ProxyInstance]] = None, | ||
): | ||
self.msg = msg | ||
self.check_subtype = check_subtype | ||
self.instance = instance |
51 changes: 51 additions & 0 deletions
51
...ackend/db_periodic_task/local_tasks/db_meta/db_meta_check/mysql_cluster_topo/decorator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. | ||
Copyright (C) 2017-2023 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 https://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. | ||
""" | ||
from typing import List | ||
|
||
from backend.db_meta.models import Cluster | ||
from backend.db_periodic_task.local_tasks.db_meta.db_meta_check.mysql_cluster_topo.check_response import CheckResponse | ||
from backend.db_report.models import MetaCheckReport | ||
|
||
|
||
def checker_wrapper(checker): | ||
def wrapper(c: Cluster) -> List[MetaCheckReport]: | ||
out_reports = [] | ||
check_response: List[CheckResponse] = checker(c) | ||
if not check_response: | ||
return out_reports | ||
|
||
for cr in check_response: | ||
out_report = MetaCheckReport( | ||
subtype=cr.check_subtype, | ||
bk_biz_id=c.bk_biz_id, | ||
bk_cloud_id=c.bk_cloud_id, | ||
status=False, | ||
msg=cr.msg, | ||
cluster=c.immute_domain, | ||
cluster_type=c.cluster_type, | ||
creator="system", | ||
updater="system", | ||
# create_at=timezone.localtime(timezone.now()), | ||
# update_at=timezone.localtime(timezone.now()), | ||
ip="0.0.0.0", | ||
port=0, | ||
machine_type="", | ||
) | ||
if cr.instance: | ||
out_report.ip = cr.instance.machine.ip | ||
out_report.port = cr.instance.port | ||
out_report.machine_type = cr.instance.machine_type | ||
|
||
out_reports.append(out_report) | ||
|
||
return out_reports | ||
|
||
return wrapper |
11 changes: 11 additions & 0 deletions
11
...db_periodic_task/local_tasks/db_meta/db_meta_check/mysql_cluster_topo/tendbha/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. | ||
Copyright (C) 2017-2023 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 https://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. | ||
""" | ||
from .check import health_check |
41 changes: 41 additions & 0 deletions
41
...riodic_task/local_tasks/db_meta/db_meta_check/mysql_cluster_topo/tendbha/access_relate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. | ||
Copyright (C) 2017-2023 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 https://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. | ||
""" | ||
from typing import List | ||
|
||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
from backend.db_meta.enums import InstanceInnerRole | ||
from backend.db_meta.models import Cluster | ||
from backend.db_periodic_task.local_tasks.db_meta.db_meta_check.mysql_cluster_topo.check_response import CheckResponse | ||
from backend.db_periodic_task.local_tasks.db_meta.db_meta_check.mysql_cluster_topo.decorator import checker_wrapper | ||
from backend.db_report.enums import MetaCheckSubType | ||
|
||
|
||
@checker_wrapper | ||
def _cluster_proxy_access_master( | ||
c: Cluster, | ||
) -> List[CheckResponse]: | ||
""" | ||
proxy 必须且只能关联到 master | ||
""" | ||
bad = [] | ||
for pi in c.proxyinstance_set.all(): | ||
for si in pi.storageinstance.all(): | ||
if si.instance_inner_role != InstanceInnerRole.MASTER: | ||
bad.append( | ||
CheckResponse( | ||
msg=_("proxy 关联到 {}: {}".format(si.instance_inner_role, si.ip_port)), | ||
check_subtype=MetaCheckSubType.ClusterTopo, | ||
instance=pi, | ||
) | ||
) | ||
|
||
return bad |
Oops, something went wrong.