Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
8 changes: 4 additions & 4 deletions mkdocs/docs/concepts/gateways.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ The example-gateway doesn't exist. Create it? [y/n]: y
Provisioning...
---> 100%

BACKEND REGION NAME HOSTNAME DOMAIN DEFAULT STATUS
aws eu-west-1 example-gateway example.com ✓ submitted
NAME BACKEND HOSTNAME DOMAIN DEFAULT STATUS
example-gateway aws (eu-west-1) 34.244.128.46 example.com ✓ running
```

</div>
Expand Down Expand Up @@ -211,8 +211,8 @@ To balance requests between gateway replicas, add DNS records for each replica o
$ dstack gateway list
NAME BACKEND HOSTNAME DOMAIN DEFAULT STATUS
example-gateway example.com ✓ running
replica=0 aws (eu-west-1) 34.244.128.46
replica=1 aws (eu-west-1) 18.201.201.174
replica=0 aws (eu-west-1) 34.244.128.46 running
replica=1 aws (eu-west-1) 18.201.201.174 running
```

</div>
Expand Down
6 changes: 6 additions & 0 deletions src/dstack/_internal/cli/utils/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ def get_gateways_table(
gateway.replicas[0].backend, gateway.replicas[0].region
)
gateway_row["HOSTNAME"] = gateway_row.get("HOSTNAME", gateway.replicas[0].hostname)
gateway_row["STATUS"] = gateway.replicas[0].status or gateway.status
gateway_row["ERROR"] = ". ".join(
m for m in [gateway.status_message, gateway.replicas[0].status_message] if m
)
add_row_from_dict(table, gateway_row)

if len(gateway.replicas) > 1:
Expand All @@ -126,7 +130,9 @@ def get_gateways_table(
"NAME": f" replica={replica.replica_num}",
"BACKEND": format_backend(replica.backend, replica.region),
"HOSTNAME": replica.hostname,
"STATUS": replica.status,
"CREATED": format_date(replica.created_at),
"ERROR": replica.status_message,
}
add_row_from_dict(table, replica_row, style="secondary")

Expand Down
17 changes: 14 additions & 3 deletions src/dstack/_internal/core/models/gateways.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ class GatewayStatus(str, Enum):
FAILED = "failed"


class GatewayReplicaStatus(str, Enum):
SUBMITTED = "submitted"
PROVISIONING = "provisioning"
RUNNING = "running"
TERMINATING = "terminating"
TERMINATED = "terminated"


class LetsEncryptGatewayCertificate(CoreModel):
type: Annotated[
Literal["lets-encrypt"], Field(description="Automatic certificates by Let's Encrypt")
Expand Down Expand Up @@ -119,11 +127,14 @@ class GatewaySpec(CoreModel):


class GatewayReplica(CoreModel):
hostname: str
hostname: Optional[str] = None
replica_num: int
backend: BackendType
region: str
backend: Optional[BackendType] = None
region: Optional[str] = None
created_at: datetime.datetime
status: Optional[GatewayReplicaStatus] = None
"""`status` is only optional on the client side for compatibility with 0.20.25 servers"""
status_message: Optional[str] = None


class Gateway(CoreModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from dstack._internal.server.background.pipeline_tasks.base import Pipeline
from dstack._internal.server.background.pipeline_tasks.compute_groups import ComputeGroupPipeline
from dstack._internal.server.background.pipeline_tasks.fleets import FleetPipeline
from dstack._internal.server.background.pipeline_tasks.gateway_replicas import (
GatewayReplicaPipeline,
)
from dstack._internal.server.background.pipeline_tasks.gateways import GatewayPipeline
from dstack._internal.server.background.pipeline_tasks.instances import InstancePipeline
from dstack._internal.server.background.pipeline_tasks.jobs_running import JobRunningPipeline
Expand Down Expand Up @@ -33,6 +36,7 @@ def __init__(self) -> None:
ComputeGroupPipeline(pipeline_hinter=self._hinter),
FleetPipeline(pipeline_hinter=self._hinter),
GatewayPipeline(pipeline_hinter=self._hinter),
GatewayReplicaPipeline(pipeline_hinter=self._hinter),
JobSubmittedPipeline(pipeline_hinter=self._hinter),
JobRunningPipeline(pipeline_hinter=self._hinter),
JobTerminatingPipeline(pipeline_hinter=self._hinter),
Expand Down
Loading
Loading