From 40c0fd41d54271e2d5d6f7a34b455945d4dec4c3 Mon Sep 17 00:00:00 2001 From: Tianxin Dong Date: Thu, 18 Jul 2024 18:07:16 +0800 Subject: [PATCH] fix: delete cluster and ns if it is first cluster (#4869) * fix: delete cluster and ns if it is first cluster Signed-off-by: FogDong * add default value * fix: add kw_only to ClusterFullSchema Signed-off-by: Frost Ming --------- Signed-off-by: FogDong Signed-off-by: Frost Ming Co-authored-by: Frost Ming Co-authored-by: Frost Ming --- src/bentoml/_internal/cloud/deployment.py | 5 ++++- src/bentoml/_internal/cloud/schemas/schemasv1.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bentoml/_internal/cloud/deployment.py b/src/bentoml/_internal/cloud/deployment.py index 6beb7738e72..2728c2afbeb 100644 --- a/src/bentoml/_internal/cloud/deployment.py +++ b/src/bentoml/_internal/cloud/deployment.py @@ -742,9 +742,12 @@ def _generate_deployment_info_( context: str | None, res: DeploymentSchema, urls: list[str] | None = None ) -> DeploymentInfo: client = get_rest_api_client(context) + admin_console = f"{client.v1.endpoint}/deployments/{res.name}" + if res.cluster.is_first is False: + admin_console = f"{client.v1.endpoint}/deployments/{res.name}?cluster={res.cluster.name}&namespace={res.kube_namespace}" return DeploymentInfo( name=res.name, - admin_console=f"{client.v1.endpoint}/deployments/{res.name}?cluster={res.cluster.name}&namespace={res.kube_namespace}", + admin_console=admin_console, created_at=res.created_at.strftime("%Y-%m-%d %H:%M:%S"), created_by=res.creator.name, cluster=res.cluster.name, diff --git a/src/bentoml/_internal/cloud/schemas/schemasv1.py b/src/bentoml/_internal/cloud/schemas/schemasv1.py index 0de5e56857d..2b4819873c9 100644 --- a/src/bentoml/_internal/cloud/schemas/schemasv1.py +++ b/src/bentoml/_internal/cloud/schemas/schemasv1.py @@ -64,6 +64,7 @@ class ClusterSchema(ResourceSchema): description: str organization_name: str creator: UserSchema + is_first: t.Optional[bool] = None @attr.define @@ -279,7 +280,7 @@ class ResourceInstanceSchema(ResourceSchema): config: ResourceInstanceConfigSchema -@attr.define +@attr.define(kw_only=True) class ClusterFullSchema(ClusterSchema): __omit_if_default__ = True __forbid_extra_keys__ = False