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

fix(lang): expose host port #832

Merged
merged 2 commits into from
Aug 31, 2022
Merged

Conversation

kemingy
Copy link
Member

@kemingy kemingy commented Aug 31, 2022

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

cc @aseaday

Signed-off-by: Keming <kemingyang@tensorchord.ai>
Signed-off-by: Keming <kemingyang@tensorchord.ai>
@kemingy kemingy marked this pull request as ready for review August 31, 2022 07:28
@kemingy kemingy requested a review from aseaday as a code owner August 31, 2022 07:28
Copy link
Member

@aseaday aseaday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@muniu-bot
Copy link

muniu-bot bot commented Aug 31, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aseaday, kemingy

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does envd randomly choose a port?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If host_port is not specified, it will use the default value 0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So 0 is the default value for the host port (if users do not set it) instead of an indicator of a randomly assigned value for the host port. Do I understand it correctly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 0 is the default value
  • if it's 0, envd will randomly choose a free port, user can check the host port with envd env describe --env <name>

    envd/pkg/docker/docker.go

    Lines 514 to 519 in 404de31

    if item.HostPort == 0 {
    item.HostPort, err = netutil.GetFreePort()
    if err != nil {
    return "", "", errors.Wrap(err, "failed to get a free port")
    }
    }

@kemingy kemingy merged commit be02a70 into tensorchord:main Aug 31, 2022
@kemingy kemingy deleted the fix_expose_host_port branch August 31, 2022 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants