-
Notifications
You must be signed in to change notification settings - Fork 63
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: record service instance which is unbound and recycle later #1775
Open
songzxc789
wants to merge
12
commits into
TencentBlueKing:main
Choose a base branch
from
songzxc789:feat-unbound-svc-instance
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
628952d
feat: record service instance which is unbound and recycle later
songzxc789 58d7bdf
fix: retrive remote instance check http status 404
songzxc789 d16b36d
fix: mark unbound if prefer_async_delete
songzxc789 60167ad
Merge remote-tracking branch 'upstream/main' into feat-unbound-svc-in…
songzxc789 2e0d57d
Merge remote-tracking branch 'upstream/main' into feat-unbound-svc-in…
songzxc789 0d2b57e
fix: use mix_service_mgr to get unbound instance list
songzxc789 0bf8cac
fix: migrations
songzxc789 8d69111
fix: check if remote recycled unbound instance
songzxc789 cc6e3f1
fix: minor
songzxc789 a9484cd
fix: minor
songzxc789 c56ce05
fix: unit test
songzxc789 4f2a70c
Merge remote-tracking branch 'upstream/main' into feat-unbound-svc-in…
songzxc789 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
33 changes: 33 additions & 0 deletions
33
...paasng/paasng/accessories/servicehub/management/commands/check_unbound_remote_instance.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,33 @@ | ||
# -*- coding: utf-8 -*- | ||
# TencentBlueKing is pleased to support the open source community by making | ||
# 蓝鲸智云 - PaaS 平台 (BlueKing - PaaS System) available. | ||
# Copyright (C) 2017 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. | ||
# | ||
# We undertake not to change the open source license (MIT license) applicable | ||
# to the current version of the project delivered to anyone in the future. | ||
|
||
import logging | ||
|
||
from django.core.management.base import BaseCommand | ||
|
||
from paasng.accessories.servicehub.tasks import check_is_unbound_remote_service_instance_recycled | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Check if unbound remote service instance is recycled, if it is recycled, delete object in database." | ||
|
||
def handle(self, *args, **options): | ||
print("Start to check if remote unbound service instance recycled") | ||
check_is_unbound_remote_service_instance_recycled() | ||
print("Complete check if remote unbound service instance recycled") |
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
55 changes: 55 additions & 0 deletions
55
...asng/accessories/servicehub/migrations/0005_unboundserviceengineappattachment_and_more.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,55 @@ | ||
# Generated by Django 4.2.16 on 2024-12-11 07:40 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import paasng.utils.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('services', '0006_alter_servicecategory_name_en'), | ||
('engine', '0023_remove_deployment_hooks_remove_deployment_procfile'), | ||
('servicehub', '0004_auto_20240412_1723'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='UnboundServiceEngineAppAttachment', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('region', models.CharField(help_text='部署区域', max_length=32)), | ||
('created', models.DateTimeField(auto_now_add=True)), | ||
('updated', models.DateTimeField(auto_now=True)), | ||
('owner', paasng.utils.models.BkUserField(blank=True, db_index=True, max_length=64, null=True)), | ||
('credentials_enabled', models.BooleanField(default=True, verbose_name='是否使用凭证')), | ||
('engine_app', models.ForeignKey(db_constraint=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='engine.engineapp', verbose_name='蓝鲸引擎应用')), | ||
('plan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='services.plan')), | ||
('service', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='services.service', verbose_name='增强服务')), | ||
('service_instance', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='services.serviceinstance', verbose_name='增强服务实例')), | ||
], | ||
options={ | ||
'verbose_name': '本地已解绑增强服务', | ||
'unique_together': {('service', 'engine_app')}, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='UnboundRemoteServiceEngineAppAttachment', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('region', models.CharField(help_text='部署区域', max_length=32)), | ||
('created', models.DateTimeField(auto_now_add=True)), | ||
('updated', models.DateTimeField(auto_now=True)), | ||
('owner', paasng.utils.models.BkUserField(blank=True, db_index=True, max_length=64, null=True)), | ||
('service_id', models.UUIDField(verbose_name='远程增强服务 ID')), | ||
('plan_id', models.UUIDField(verbose_name='远程增强服务 Plan ID')), | ||
('service_instance_id', models.UUIDField(null=True, verbose_name='远程增强服务实例 ID')), | ||
('credentials_enabled', models.BooleanField(default=True, verbose_name='是否使用凭证')), | ||
('engine_app', models.ForeignKey(db_constraint=False, on_delete=django.db.models.deletion.CASCADE, related_name='unbound_remote_service_attachment', to='engine.engineapp', verbose_name='蓝鲸引擎应用')), | ||
], | ||
options={ | ||
'verbose_name': '远程已解绑增强服务', | ||
'unique_together': {('service_id', 'engine_app')}, | ||
}, | ||
), | ||
] |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
解绑过程需要加逻辑 而不是在回收逻辑里面
你需要先在开发者中心试一下解绑服务是由那个接口或者入口触发的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
由这个接口触发,
DELETE make_app_pattern(f"/services/{SERVICE_UUID}/$", include_envs=False),
,会触发 ModuleCleaner.delete_services(),传入 service_id。 删除module时也会解绑增强服务,也会触发ModuleCleaner.delete_services(),不传service_id。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
远程增强服务也需要有
self.db_obj.service.prefer_async_delete
类似的判断逻辑