Skip to content

Commit

Permalink
fix: delete cluster and ns if it is first cluster (#4869)
Browse files Browse the repository at this point in the history
* fix: delete cluster and ns if it is first cluster

Signed-off-by: FogDong <fog@bentoml.com>

* add default value

* fix: add kw_only to ClusterFullSchema

Signed-off-by: Frost Ming <me@frostming.com>

---------

Signed-off-by: FogDong <fog@bentoml.com>
Signed-off-by: Frost Ming <me@frostming.com>
Co-authored-by: Frost Ming <mianghong@gmail.com>
Co-authored-by: Frost Ming <me@frostming.com>
  • Loading branch information
3 people authored Jul 18, 2024
1 parent b11cdbf commit 40c0fd4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/bentoml/_internal/cloud/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/bentoml/_internal/cloud/schemas/schemasv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ClusterSchema(ResourceSchema):
description: str
organization_name: str
creator: UserSchema
is_first: t.Optional[bool] = None


@attr.define
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 40c0fd4

Please sign in to comment.