Skip to content

Commit

Permalink
fix(lang): expose host port (#832)
Browse files Browse the repository at this point in the history
* fix(lang): expose host port

Signed-off-by: Keming <kemingyang@tensorchord.ai>

* update doc

Signed-off-by: Keming <kemingyang@tensorchord.ai>

Signed-off-by: Keming <kemingyang@tensorchord.ai>
  • Loading branch information
kemingy committed Aug 31, 2022
1 parent 404de31 commit be02a70
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions envd/api/runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def expose(envd_port: str, host_port: Optional[str], service: Optional[str]):
Args:
envd_port (str): port in `envd` container
host_port (Optional[str]): port in the host, if not provided, `envd` will
randomly choose a free port
host_port (Optional[str]): port in the host, if not provided or
`host_port=0`, `envd` will randomly choose a free port
service (Optional[str]): service name
"""

Expand Down
6 changes: 3 additions & 3 deletions pkg/lang/frontend/starlark/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func ruleFuncExpose(thread *starlark.Thread, _ *starlark.Builtin,
args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var (
envdPort starlark.Int
hostPort = starlark.MakeInt(0)
hostPort = starlark.MakeInt(0) // 0 means envd can randomly choose a free port
serviceName = starlark.String("")
)

Expand All @@ -108,8 +108,8 @@ func ruleFuncExpose(thread *starlark.Thread, _ *starlark.Builtin,
return nil, errors.New("envd_port must be a positive integer less than 65535")
}
hostPortInt, ok := hostPort.Int64()
if !ok || hostPortInt < 1 || hostPortInt > 65535 {
return nil, errors.New("envd_port must be a positive integer less than 65535")
if !ok || hostPortInt < 0 || hostPortInt > 65535 {
return nil, errors.New("host_port must be a positive integer less than 65535")
}
serviceNameStr := serviceName.GoString()

Expand Down

0 comments on commit be02a70

Please sign in to comment.