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

feat(es): 大数据清理机器的flow #8012 #8137

Merged
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions dbm-ui/backend/db_meta/api/cluster/doris/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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 .clear_machine import clear_machine
from .create import create
from .destroy import destroy
from .disable import disable
Expand Down
47 changes: 47 additions & 0 deletions dbm-ui/backend/db_meta/api/cluster/doris/clear_machine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- 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.
"""

import logging
from typing import List, Optional

from django.core.exceptions import ObjectDoesNotExist
from django.db import transaction

from backend.db_meta.models.instance import ProxyInstance, StorageInstance
from backend.db_meta.models.machine import Machine

logger = logging.getLogger("root")


@transaction.atomic
def clear_machine(machines: Optional[List]):
"""
根据machine信息回收机器相关信息for大数据
"""
for m in machines:
try:
machine = Machine.objects.get(ip=m["ip"], bk_cloud_id=m["bk_cloud_id"])
except ObjectDoesNotExist:
logger.warning(f"the machine [{m['bk_cloud_id']}:{m['ip']}] not exist ")
continue

proxys = ProxyInstance.objects.filter(machine=machine)
storages = StorageInstance.objects.filter(machine=machine)

# 清理proxy相关信息
for p in proxys:
p.delete(keep_parents=True)

# 清理storage相关信息
for s in storages:
s.delete(keep_parents=True)

machine.delete(keep_parents=True)
1 change: 1 addition & 0 deletions dbm-ui/backend/db_meta/api/cluster/es/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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 .clear_machine import clear_machine
from .create import create
from .destroy import destroy
from .disable import disable
Expand Down
47 changes: 47 additions & 0 deletions dbm-ui/backend/db_meta/api/cluster/es/clear_machine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- 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.
"""

import logging
from typing import List, Optional

from django.core.exceptions import ObjectDoesNotExist
from django.db import transaction

from backend.db_meta.models.instance import ProxyInstance, StorageInstance
from backend.db_meta.models.machine import Machine

logger = logging.getLogger("root")


@transaction.atomic
def clear_machine(machines: Optional[List]):
"""
根据machine信息回收机器相关信息for大数据
"""
for m in machines:
try:
machine = Machine.objects.get(ip=m["ip"], bk_cloud_id=m["bk_cloud_id"])
except ObjectDoesNotExist:
logger.warning(f"the machine [{m['bk_cloud_id']}:{m['ip']}] not exist ")
continue

proxys = ProxyInstance.objects.filter(machine=machine)
storages = StorageInstance.objects.filter(machine=machine)

# 清理proxy相关信息
for p in proxys:
p.delete(keep_parents=True)

# 清理storage相关信息
for s in storages:
s.delete(keep_parents=True)

machine.delete(keep_parents=True)
1 change: 1 addition & 0 deletions dbm-ui/backend/db_meta/api/cluster/hdfs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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 .clear_machine import clear_machine
from .create import create
from .destroy import destroy
from .disable import disable
Expand Down
47 changes: 47 additions & 0 deletions dbm-ui/backend/db_meta/api/cluster/hdfs/clear_machine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- 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.
"""

import logging
from typing import List, Optional

from django.core.exceptions import ObjectDoesNotExist
from django.db import transaction

from backend.db_meta.models.instance import ProxyInstance, StorageInstance
from backend.db_meta.models.machine import Machine

logger = logging.getLogger("root")


@transaction.atomic
def clear_machine(machines: Optional[List]):
"""
根据machine信息回收机器相关信息for大数据
"""
for m in machines:
try:
machine = Machine.objects.get(ip=m["ip"], bk_cloud_id=m["bk_cloud_id"])
except ObjectDoesNotExist:
logger.warning(f"the machine [{m['bk_cloud_id']}:{m['ip']}] not exist ")
continue

proxys = ProxyInstance.objects.filter(machine=machine)
storages = StorageInstance.objects.filter(machine=machine)

# 清理proxy相关信息
for p in proxys:
p.delete(keep_parents=True)

# 清理storage相关信息
for s in storages:
s.delete(keep_parents=True)

machine.delete(keep_parents=True)
1 change: 1 addition & 0 deletions dbm-ui/backend/db_meta/api/cluster/kafka/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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 .clear_machine import clear_machine
from .create import create
from .destroy import destroy
from .disable import disable
Expand Down
47 changes: 47 additions & 0 deletions dbm-ui/backend/db_meta/api/cluster/kafka/clear_machine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- 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.
"""

import logging
from typing import List, Optional

from django.core.exceptions import ObjectDoesNotExist
from django.db import transaction

from backend.db_meta.models.instance import ProxyInstance, StorageInstance
from backend.db_meta.models.machine import Machine

logger = logging.getLogger("root")


@transaction.atomic
def clear_machine(machines: Optional[List]):
"""
根据machine信息回收机器相关信息for大数据
"""
for m in machines:
try:
machine = Machine.objects.get(ip=m["ip"], bk_cloud_id=m["bk_cloud_id"])
except ObjectDoesNotExist:
logger.warning(f"the machine [{m['bk_cloud_id']}:{m['ip']}] not exist ")
continue

proxys = ProxyInstance.objects.filter(machine=machine)
storages = StorageInstance.objects.filter(machine=machine)

# 清理proxy相关信息
for p in proxys:
p.delete(keep_parents=True)

# 清理storage相关信息
for s in storages:
s.delete(keep_parents=True)

machine.delete(keep_parents=True)
1 change: 1 addition & 0 deletions dbm-ui/backend/db_meta/api/cluster/pulsar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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 .clear_machine import clear_machine
from .create import create
from .destroy import destroy
from .disable import disable
Expand Down
47 changes: 47 additions & 0 deletions dbm-ui/backend/db_meta/api/cluster/pulsar/clear_machine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- 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.
"""

import logging
from typing import List, Optional

from django.core.exceptions import ObjectDoesNotExist
from django.db import transaction

from backend.db_meta.models.instance import ProxyInstance, StorageInstance
from backend.db_meta.models.machine import Machine

logger = logging.getLogger("root")


@transaction.atomic
def clear_machine(machines: Optional[List]):
"""
根据machine信息回收机器相关信息for大数据
"""
for m in machines:
try:
machine = Machine.objects.get(ip=m["ip"], bk_cloud_id=m["bk_cloud_id"])
except ObjectDoesNotExist:
logger.warning(f"the machine [{m['bk_cloud_id']}:{m['ip']}] not exist ")
continue

proxys = ProxyInstance.objects.filter(machine=machine)
storages = StorageInstance.objects.filter(machine=machine)

# 清理proxy相关信息
for p in proxys:
p.delete(keep_parents=True)

# 清理storage相关信息
for s in storages:
s.delete(keep_parents=True)

machine.delete(keep_parents=True)
1 change: 1 addition & 0 deletions dbm-ui/backend/db_meta/api/cluster/vm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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 .clear_machine import clear_machine
from .create import create
from .destroy import destroy
from .disable import disable
Expand Down
47 changes: 47 additions & 0 deletions dbm-ui/backend/db_meta/api/cluster/vm/clear_machine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- 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.
"""

import logging
from typing import List, Optional

from django.core.exceptions import ObjectDoesNotExist
from django.db import transaction

from backend.db_meta.models.instance import ProxyInstance, StorageInstance
from backend.db_meta.models.machine import Machine

logger = logging.getLogger("root")


@transaction.atomic
def clear_machine(machines: Optional[List]):
"""
根据machine信息回收机器相关信息for大数据
"""
for m in machines:
try:
machine = Machine.objects.get(ip=m["ip"], bk_cloud_id=m["bk_cloud_id"])
except ObjectDoesNotExist:
logger.warning(f"the machine [{m['bk_cloud_id']}:{m['ip']}] not exist ")
continue

proxys = ProxyInstance.objects.filter(machine=machine)
storages = StorageInstance.objects.filter(machine=machine)

# 清理proxy相关信息
for p in proxys:
p.delete(keep_parents=True)

# 清理storage相关信息
for s in storages:
s.delete(keep_parents=True)

machine.delete(keep_parents=True)
Loading
Loading