From f9bf9fe9cc1c98427ff401471babd5c9f5fbbee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Va=C5=A1ek?= Date: Tue, 1 Jul 2025 03:58:53 +0200 Subject: [PATCH] fix: pass LISTEN_ADDRESS to runner (#2901) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matej VaĊĦek --- pkg/functions/runner.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/pkg/functions/runner.go b/pkg/functions/runner.go index c71ec1bbe..f0dedf2bd 100644 --- a/pkg/functions/runner.go +++ b/pkg/functions/runner.go @@ -171,17 +171,12 @@ func runGo(ctx context.Context, job *Job) (err error) { cmd.Stderr = os.Stderr // cmd.Cancel = stop // TODO: use when we upgrade to go 1.20 - // TODO: Update the functions go runtime to accept LISTEN_ADDRESS rather - // than just port in able to allow listening on other interfaces - // (keeping the default localhost only) - if job.Host != "127.0.0.1" { - fmt.Fprintf(os.Stderr, "Warning: the Go functions runtime currently only supports localhost '127.0.0.1'. Requested listen interface '%v' will be ignored.", job.Host) - } + // See the 1.19 [release notes](https://tip.golang.org/doc/go1.19) which state: // A Cmd with a non-empty Dir field and nil Env now implicitly sets the PWD environment variable for the subprocess to match Dir. // The new method Cmd.Environ reports the environment that would be used to run the command, including the implicitly set PWD variable. // cmd.Env = append(cmd.Environ(), "PORT="+job.Port) // requires go 1.19 - cmd.Env = append(cmd.Env, "PORT="+job.Port, "PWD="+cmd.Dir) + cmd.Env = append(cmd.Env, "LISTEN_ADDRESS="+net.JoinHostPort(job.Host, job.Port), "PWD="+cmd.Dir) // Running asynchronously allows for the client Run method to return // metadata about the running function such as its chosen port. @@ -274,7 +269,7 @@ func runPython(ctx context.Context, job *Job) (err error) { func waitFor(ctx context.Context, job *Job, timeout time.Duration) error { var ( - uri = fmt.Sprintf("http://%s:%s%s", job.Host, job.Port, readinessEndpoint) + uri = fmt.Sprintf("http://%s%s", net.JoinHostPort(job.Host, job.Port), readinessEndpoint) interval = 500 * time.Millisecond )