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: update apiserver django to 4.2.16 #1675

Merged
merged 14 commits into from
Oct 29, 2024
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
2 changes: 0 additions & 2 deletions apiserver/paasng/paas_wl/bk_app/applications/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@
#
# 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.

default_app_config = "paas_wl.bk_app.applications.apps.ApplicationsAppConfig"
3 changes: 2 additions & 1 deletion apiserver/paasng/paas_wl/bk_app/cnative/specs/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
from django.dispatch import Signal

# 云原生应用部署完成后触发的信号,会执行操作记录等后续步骤
post_cnative_env_deploy = Signal(providing_args=["deploy"])
# providing_args: [deploy: AppModelDeploy]
post_cnative_env_deploy = Signal()
6 changes: 2 additions & 4 deletions apiserver/paasng/paas_wl/bk_app/cnative/specs/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# 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.

from django.conf.urls import url

from paasng.utils.basic import make_app_pattern, re_path

from . import views
Expand Down Expand Up @@ -46,12 +44,12 @@
views.VolumeMountViewSet.as_view({"put": "update", "delete": "destroy"}),
name="api.mres.volume_mount.detail",
),
url(
re_path(
r"api/bkapps/applications/(?P<code>[^/]+)/mres/mount_sources/$",
views.MountSourceViewSet.as_view({"get": "list", "post": "create", "delete": "destroy", "put": "update"}),
name="api.mres.mount_source",
),
url(
re_path(
r"api/bkapps/applications/(?P<code>[^/]+)/mres/storage_class/$",
views.StorageClassViewSet.as_view({"get": "check"}),
name="api.mres.storage_class",
Expand Down
2 changes: 0 additions & 2 deletions apiserver/paasng/paas_wl/bk_app/deploy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@
#
# 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.

default_app_config = "paas_wl.bk_app.deploy.apps.DeployAppConfig"
2 changes: 0 additions & 2 deletions apiserver/paasng/paas_wl/bk_app/processes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@
#
# 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.

default_app_config = "paas_wl.bk_app.processes.apps.ProcessesConfig"
14 changes: 5 additions & 9 deletions apiserver/paasng/paas_wl/bk_app/processes/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from typing import Dict, List, NamedTuple, Optional, Protocol, Type

from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from paas_wl.bk_app.applications.constants import WlAppType
from paas_wl.bk_app.applications.models import Release, WlApp
Expand Down Expand Up @@ -125,23 +125,19 @@ def list_processes(env: ModuleEnvironment) -> ProcessesInfo:
class ProcController(Protocol):
"""Control app's processes"""

def __init__(self, env: ModuleEnvironment):
...
def __init__(self, env: ModuleEnvironment): ...

def start(self, proc_type: str):
...
def start(self, proc_type: str): ...

def stop(self, proc_type: str):
...
def stop(self, proc_type: str): ...

def scale(
self,
proc_type: str,
autoscaling: bool = False,
target_replicas: Optional[int] = None,
scaling_config: Optional[AutoscalingConfig] = None,
):
...
): ...


class ProcControllerHub:
Expand Down
8 changes: 5 additions & 3 deletions apiserver/paasng/paas_wl/bk_app/processes/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
# to the current version of the project delivered to anyone in the future.

"""Custom exceptions for processes module"""

import re
from typing import Optional

from django.utils.encoding import force_text
from django.utils.encoding import force_str
from kubernetes.dynamic.exceptions import NotFoundError

from paas_wl.infras.resources.kube_res.exceptions import AppEntityDeserializeError
Expand Down Expand Up @@ -60,10 +61,11 @@ def __init__(

def caused_by_not_found(self) -> bool:
"""Check if the error was caused by missing namespace."""
if isinstance(self.exception, NotFoundError) and re.search(
r"namespaces .* not found", force_text(self.exception.summary())
if isinstance(self.exception, NotFoundError) and re.search( # noqa: SIM103
r"namespaces .* not found", force_str(self.exception.summary())
):
return True

return False


Expand Down
3 changes: 2 additions & 1 deletion apiserver/paasng/paas_wl/bk_app/processes/kres_slzs.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ def deserialize(self, app: WlApp, kube_data: ResourceInstance) -> "Instance":
envs[name] = value

if app.type == WlAppType.DEFAULT:
version = int(pod.metadata.labels.get("release_version", 0))
labels = pod.metadata.labels or {}
version = int(labels.get("release_version", 0))
else:
annotations = pod.metadata.annotations or {}
version = int(annotations.get(BKPAAS_DEPLOY_ID_ANNO_KEY, 0))
Expand Down
2 changes: 1 addition & 1 deletion apiserver/paasng/paas_wl/bk_app/processes/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import arrow
import cattr
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from kubernetes.utils.quantity import parse_quantity
from rest_framework import serializers
from rest_framework.serializers import ValidationError
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- 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.

# Generated by Django 3.2.25 on 2024-10-23 02:53

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("cluster", "0009_encrypt_cluster_in_db"),
]

operations = [
migrations.AlterField(
model_name="cluster",
name="is_default",
field=models.BooleanField(default=False, help_text="是否为默认集群", null=True),
),
]
8 changes: 5 additions & 3 deletions apiserver/paasng/paas_wl/infras/cluster/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,13 @@ def switch_default_cluster(self, region: str, cluster_name: str) -> "Cluster":


class Cluster(UuidAuditedModel):
def __str__(self):
return f"{self.__class__.__name__}(name={self.name}, default={self.is_default})"
"""应用集群"""

region = models.CharField(max_length=32, db_index=True)
name = models.CharField(max_length=32, help_text="name of the cluster", unique=True)
type = models.CharField(max_length=32, help_text="cluster type", default=ClusterType.NORMAL)
description = models.TextField(help_text="描述信息", blank=True)
is_default = models.NullBooleanField(default=False)
is_default = models.BooleanField(default=False, null=True, help_text="是否为默认集群")

ingress_config: IngressConfig = IngressConfigField()
annotations = JSONField(default={}, help_text="Annotations are used to add metadata to describe the cluster.")
Expand All @@ -261,6 +260,9 @@ def __str__(self):

objects = ClusterManager()

def __str__(self):
return f"{self.__class__.__name__}(name={self.name}, default={self.is_default})"

@property
def bcs_cluster_id(self) -> Optional[str]:
"""集群在 bcs 中注册的集群 ID,若没有配置,则返回 None"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@
#
# 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.

default_app_config = "paas_wl.infras.resources.generation.apps.GenerationConfig"
2 changes: 0 additions & 2 deletions apiserver/paasng/paas_wl/workloads/images/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@
#
# 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.

default_app_config = "paas_wl.workloads.images.apps.ImagesConfig"
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@
#
# 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.

default_app_config = "paas_wl.workloads.networking.egress.apps.EgressAppConfig"
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@
- ProcessService: for internal communications (Kubernetes Service)
- ProcessIngress: for external communications (Kubernetes Ingress)
"""
default_app_config = "paas_wl.workloads.networking.ingress.apps.IngressConfig"
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- 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.

# Generated by Django 3.2.25 on 2024-10-23 02:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("ingress", "0007_encrypt_appdominsharedcert_in_db"),
]

operations = [
migrations.AlterField(
model_name="domain",
name="https_enabled",
field=models.BooleanField(default=False, help_text="该域名是否开启 https", null=True),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class Domain(TimestampedModel):
path_prefix = models.CharField(max_length=64, default="/", help_text="the accessable path for current domain")
module_id = models.UUIDField(help_text="关联的模块 ID", null=False)
environment_id = models.BigIntegerField(help_text="关联的环境 ID", null=False)
https_enabled = models.NullBooleanField(default=False, help_text="该域名是否开启 https.")
https_enabled = models.BooleanField(default=False, null=True, help_text="该域名是否开启 https")

module = ModuleAttrFromID()
environment = ModuleEnvAttrFromID()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
from django.dispatch import Signal

# Triggered when the custom domains of a cloud-native app have been updated
cnative_custom_domain_updated = Signal(providing_args=["env"])
# providing_args: [env: ModuleEnvironment]
cnative_custom_domain_updated = Signal()
2 changes: 0 additions & 2 deletions apiserver/paasng/paas_wl/workloads/tracing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@
#
# 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.

default_app_config = "paas_wl.workloads.tracing.apps.TracingConfig"
13 changes: 6 additions & 7 deletions apiserver/paasng/paasng/accessories/app_secret/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,32 @@
# 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.

from django.conf.urls import url

from paasng.accessories.app_secret import views
from paasng.utils.basic import re_path

urlpatterns = [
url(
re_path(
r"^api/bkapps/applications/(?P<code>[^/]+)/secrets/$",
views.BkAuthSecretViewSet.as_view({"get": "list", "post": "create"}),
name="api.app_secret.secrets",
),
url(
re_path(
r"^api/bkapps/applications/(?P<code>[^/]+)/secrets/(?P<bk_app_secret_id>\d+)/$",
views.BkAuthSecretViewSet.as_view({"post": "toggle", "delete": "delete"}),
name="api.app_secret.secret",
),
# 验证验证码查看密钥详情
url(
re_path(
r"^api/bkapps/applications/(?P<code>[^/]+)/secret_verification/(?P<bk_app_secret_id>\d+)/$",
views.BkAuthSecretViewSet.as_view({"post": "view_secret_detail"}),
name="api.app_secret.secret_verification",
),
url(
re_path(
r"^api/bkapps/applications/(?P<code>[^/]+)/default_secret/$",
views.BkAppSecretInEnvVaViewSet.as_view({"get": "get_default_secret", "post": "rotate_default_secret"}),
name="api.app_secret.default_secret",
),
url(
re_path(
r"^api/bkapps/applications/(?P<code>[^/]+)/deployed_secret/$",
views.BkAppSecretInEnvVaViewSet.as_view(
{
Expand Down
2 changes: 0 additions & 2 deletions apiserver/paasng/paasng/accessories/ci/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@
#
# 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.

default_app_config = "paasng.accessories.ci.apps.CIAppConfig"
7 changes: 2 additions & 5 deletions apiserver/paasng/paasng/accessories/log/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
#
# 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.

from django.conf.urls import url

from paasng.utils.basic import make_app_pattern, re_path

from .views import config
Expand Down Expand Up @@ -110,7 +107,7 @@
name="api.logs.ingress.aggregate_fields_filters.legacy",
),
# System APIs
url(
re_path(
r"sys/api/log/applications/(?P<code>[^/]+)/modules/(?P<module_name>[^/]+)/"
r"envs/(?P<environment>stag|prod)/structured/list/$",
logs_views.SysStructuredLogAPIView.as_view({"post": "query_logs"}),
Expand Down Expand Up @@ -147,7 +144,7 @@
legacy_views.V1StdoutLogAPIView.as_view({"get": "query_logs_scroll_with_get", "post": "query_logs_scroll"}),
name="api.logs.standard.list.deprecated",
),
url(
re_path(
r"sys/api/log/applications/(?P<code>[^/]+)/modules/(?P<module_name>[^/]+)/structured/list/$",
legacy_views.V1SysStructuredLogAPIView.as_view({"post": "query_logs", "get": "query_logs_get"}),
name="sys.api.logs.structured.deprecated",
Expand Down
2 changes: 0 additions & 2 deletions apiserver/paasng/paasng/accessories/paas_analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@
#
# 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.

default_app_config = "paasng.accessories.paas_analysis.apps.PaasAnalysisConfig"
Loading