From 7c407f39513f2db29f7df2621ff6a8ca73c6b0c4 Mon Sep 17 00:00:00 2001 From: Roey Berman Date: Mon, 23 Dec 2024 10:45:54 -0800 Subject: [PATCH 1/4] Bump server to 1.26.2, enable HTTP by default --- go.mod | 2 +- go.sum | 4 ++-- temporalcli/commands.gen.go | 2 +- temporalcli/commands.server.go | 1 + temporalcli/commands_test.go | 1 - temporalcli/commandsgen/commands.yml | 7 +++---- temporalcli/devserver/server.go | 1 - 7 files changed, 8 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 9e7ae0a1..13331ee2 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/temporalio/ui-server/v2 v2.31.2 go.temporal.io/api v1.43.0 go.temporal.io/sdk v1.31.0 - go.temporal.io/server v1.26.2-rc.0 + go.temporal.io/server v1.26.2 google.golang.org/grpc v1.67.1 google.golang.org/protobuf v1.35.1 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index e88688ca..104acfd9 100644 --- a/go.sum +++ b/go.sum @@ -358,8 +358,8 @@ go.temporal.io/api v1.43.0 h1:lBhq+u5qFJqGMXwWsmg/i8qn1UA/3LCwVc88l2xUMHg= go.temporal.io/api v1.43.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis= go.temporal.io/sdk v1.31.0 h1:CLYiP0R5Sdj0gq8LyYKDDz4ccGOdJPR8wNGJU0JGwj8= go.temporal.io/sdk v1.31.0/go.mod h1:8U8H7rF9u4Hyb4Ry9yiEls5716DHPNvVITPNkgWUwE8= -go.temporal.io/server v1.26.2-rc.0 h1:jsWR2UzhPQ+UgDfqNHT6h6ZjzGTcw72i9KNkSNS0jN8= -go.temporal.io/server v1.26.2-rc.0/go.mod h1:tgY+4z/PuIdqs6ouV1bT90RWSWfEioWkzmrNrLYLUrk= +go.temporal.io/server v1.26.2 h1:vDW11lxslYPlGDbQklWi/tqbkVZ2ExtRO1jNjvZmUUI= +go.temporal.io/server v1.26.2/go.mod h1:tgY+4z/PuIdqs6ouV1bT90RWSWfEioWkzmrNrLYLUrk= go.temporal.io/version v0.3.0 h1:dMrei9l9NyHt8nG6EB8vAwDLLTwx2SvRyucCSumAiig= go.temporal.io/version v0.3.0/go.mod h1:UA9S8/1LaKYae6TyD9NaPMJTZb911JcbqghI2CBSP78= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= diff --git a/temporalcli/commands.gen.go b/temporalcli/commands.gen.go index fb14d057..8fc2cb11 100644 --- a/temporalcli/commands.gen.go +++ b/temporalcli/commands.gen.go @@ -1830,7 +1830,7 @@ func NewTemporalServerStartDevCommand(cctx *CommandContext, parent *TemporalServ s.Command.Flags().StringVarP(&s.DbFilename, "db-filename", "f", "", "Path to file for persistent Temporal state store. By default, Workflow Executions are lost when the server process dies.") s.Command.Flags().StringArrayVarP(&s.Namespace, "namespace", "n", nil, "Namespaces to be created at launch. The \"default\" Namespace is always created automatically.") s.Command.Flags().IntVarP(&s.Port, "port", "p", 7233, "Port for the front-end gRPC Service.") - s.Command.Flags().IntVar(&s.HttpPort, "http-port", 0, "Port for the HTTP API service. Default is off.") + s.Command.Flags().IntVar(&s.HttpPort, "http-port", 7243, "Port for the HTTP API service.") s.Command.Flags().IntVar(&s.MetricsPort, "metrics-port", 0, "Port for '/metrics'. Default is off.") s.Command.Flags().IntVar(&s.UiPort, "ui-port", 0, "Port for the Web UI. Default is '--port' value + 1000.") s.Command.Flags().BoolVar(&s.Headless, "headless", false, "Disable the Web UI.") diff --git a/temporalcli/commands.server.go b/temporalcli/commands.server.go index dc268aaa..a626a9af 100644 --- a/temporalcli/commands.server.go +++ b/temporalcli/commands.server.go @@ -152,6 +152,7 @@ func (t *TemporalServerStartDevCommand) run(cctx *CommandContext, args []string) cctx.Printer.Printlnf("CLI %v\n", VersionString()) cctx.Printer.Printlnf("%-8s %v:%v", "Server:", toFriendlyIp(opts.FrontendIP), opts.FrontendPort) + cctx.Printer.Printlnf("%-8s %v:%v", "HTTP:", toFriendlyIp(opts.FrontendIP), opts.FrontendHTTPPort) if !t.Headless { cctx.Printer.Printlnf("%-8s http://%v:%v%v", "UI:", toFriendlyIp(opts.UIIP), opts.UIPort, opts.PublicPath) } diff --git a/temporalcli/commands_test.go b/temporalcli/commands_test.go index 7158bc02..28933e5e 100644 --- a/temporalcli/commands_test.go +++ b/temporalcli/commands_test.go @@ -371,7 +371,6 @@ func StartDevServer(t *testing.T, options DevServerOptions) *DevServer { d.Options.DynamicConfigValues["frontend.workerVersioningWorkflowAPIs"] = true d.Options.DynamicConfigValues["worker.buildIdScavengerEnabled"] = true d.Options.DynamicConfigValues["frontend.enableUpdateWorkflowExecution"] = true - d.Options.DynamicConfigValues["system.enableNexus"] = true d.Options.DynamicConfigValues["frontend.MaxConcurrentBatchOperationPerNamespace"] = 1000 d.Options.DynamicConfigValues["frontend.namespaceRPS.visibility"] = 100 d.Options.DynamicConfigValues["system.clusterMetadataRefreshInterval"] = 100 * time.Millisecond diff --git a/temporalcli/commandsgen/commands.yml b/temporalcli/commandsgen/commands.yml index df220da6..064fdbed 100644 --- a/temporalcli/commandsgen/commands.yml +++ b/temporalcli/commandsgen/commands.yml @@ -1647,9 +1647,8 @@ commands: default: 7233 - name: http-port type: int - description: | - Port for the HTTP API service. - Default is off. + description: Port for the HTTP API service. + default: 7243 - name: metrics-port type: int description: | @@ -3502,4 +3501,4 @@ option-sets: description: | An external Nexus Endpoint that receives forwarded Nexus requests. May be used as an alternative to `--target-namespace` and - `--target-task-queue`. \ No newline at end of file + `--target-task-queue`. diff --git a/temporalcli/devserver/server.go b/temporalcli/devserver/server.go index 8ea5db1c..ff0fa527 100644 --- a/temporalcli/devserver/server.go +++ b/temporalcli/devserver/server.go @@ -227,7 +227,6 @@ func (s *StartOptions) buildServerOptions() ([]temporal.ServerOption, error) { dynConf[dynamicconfig.HistoryCacheHostLevelMaxSize.Key()] = 8096 // Up default visibility RPS dynConf[dynamicconfig.FrontendMaxNamespaceVisibilityRPSPerInstance.Key()] = 100 - // This doesn't enable Nexus but it is required for Nexus to work and simplifies the experience. // NOTE that the URL scheme is fixed to HTTP since the dev server doesn't support TLS at the time of writing. dynConf[nexusoperations.CallbackURLTemplate.Key()] = fmt.Sprintf( "http://%s:%d/namespaces/{{.NamespaceName}}/nexus/callback", MaybeEscapeIPv6(s.FrontendIP), s.FrontendHTTPPort) From 17b126d2663c1581e2ce9c4d49e336a449b93600 Mon Sep 17 00:00:00 2001 From: Roey Berman Date: Mon, 23 Dec 2024 13:39:12 -0800 Subject: [PATCH 2/4] --http-port for tests --- temporalcli/commands.server_test.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/temporalcli/commands.server_test.go b/temporalcli/commands.server_test.go index 40ca8962..e1b4586d 100644 --- a/temporalcli/commands.server_test.go +++ b/temporalcli/commands.server_test.go @@ -25,26 +25,29 @@ import ( func TestServer_StartDev_Simple(t *testing.T) { port := strconv.Itoa(devserver.MustGetFreePort("127.0.0.1")) + httpPort := strconv.Itoa(devserver.MustGetFreePort("127.0.0.1")) startDevServerAndRunSimpleTest( t, // TODO(cretz): Remove --headless when // https://github.com/temporalio/ui/issues/1773 fixed - []string{"server", "start-dev", "-p", port, "--headless"}, + []string{"server", "start-dev", "-p", port, "--http-port", httpPort, "--headless"}, "127.0.0.1:"+port, ) } func TestServer_StartDev_IPv4Unspecified(t *testing.T) { port := strconv.Itoa(devserver.MustGetFreePort("0.0.0.0")) + httpPort := strconv.Itoa(devserver.MustGetFreePort("127.0.0.1")) startDevServerAndRunSimpleTest( t, - []string{"server", "start-dev", "--ip", "0.0.0.0", "-p", port, "--headless"}, + []string{"server", "start-dev", "--ip", "0.0.0.0", "-p", port, "--http-port", httpPort, "--headless"}, "0.0.0.0:"+port, ) } func TestServer_StartDev_SQLitePragma(t *testing.T) { port := strconv.Itoa(devserver.MustGetFreePort("0.0.0.0")) + httpPort := strconv.Itoa(devserver.MustGetFreePort("127.0.0.1")) dbFilename := filepath.Join(os.TempDir(), "devserver-sqlite-pragma.sqlite") defer func() { _ = os.Remove(dbFilename) @@ -55,7 +58,9 @@ func TestServer_StartDev_SQLitePragma(t *testing.T) { t, []string{ "server", "start-dev", - "-p", port, "--headless", + "-p", port, + "--http-port", httpPort, + "--headless", "--db-filename", dbFilename, "--sqlite-pragma", "journal_mode=WAL", "--sqlite-pragma", "synchronous=NORMAL", @@ -76,12 +81,14 @@ func TestServer_StartDev_IPv6Unspecified(t *testing.T) { } port := strconv.Itoa(devserver.MustGetFreePort("::")) + httpPort := strconv.Itoa(devserver.MustGetFreePort("::")) startDevServerAndRunSimpleTest( t, []string{ "server", "start-dev", "--ip", "::", "--ui-ip", "::1", "-p", port, + "--http-port", httpPort, "--ui-port", strconv.Itoa(devserver.MustGetFreePort("::")), "--http-port", strconv.Itoa(devserver.MustGetFreePort("::")), "--metrics-port", strconv.Itoa(devserver.MustGetFreePort("::"))}, @@ -138,9 +145,10 @@ func TestServer_StartDev_ConcurrentStarts(t *testing.T) { // Start in background, then wait for client to be able to connect port := strconv.Itoa(devserver.MustGetFreePort("127.0.0.1")) + httpPort := strconv.Itoa(devserver.MustGetFreePort("127.0.0.1")) resCh := make(chan *CommandResult, 1) go func() { - resCh <- h.Execute("server", "start-dev", "-p", port, "--headless", "--log-level", "never") + resCh <- h.Execute("server", "start-dev", "-p", port, "--http-port", httpPort, "--headless", "--log-level", "never") }() // Try to connect for a bit while checking for error @@ -191,11 +199,13 @@ func TestServer_StartDev_WithSearchAttributes(t *testing.T) { // Start in background, then wait for client to be able to connect port := strconv.Itoa(devserver.MustGetFreePort("127.0.0.1")) + httpPort := strconv.Itoa(devserver.MustGetFreePort("127.0.0.1")) resCh := make(chan *CommandResult, 1) go func() { resCh <- h.Execute( "server", "start-dev", "-p", port, + "--http-port", httpPort, "--headless", "--search-attribute", "search-attr-1=Int", "--search-attribute", "search-attr-2=kEyWoRdLiSt", From 3aaf3a2623ea7fae5cd3010e8d6e80ed9a065475 Mon Sep 17 00:00:00 2001 From: Roey Berman Date: Mon, 6 Jan 2025 21:16:07 -0800 Subject: [PATCH 3/4] Make HTTP port random by default --- temporalcli/commands.gen.go | 2 +- temporalcli/commands.server.go | 10 ++++++++-- temporalcli/commandsgen/commands.yml | 4 ++-- temporalcli/devserver/server.go | 4 +--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/temporalcli/commands.gen.go b/temporalcli/commands.gen.go index 8fc2cb11..e8272eab 100644 --- a/temporalcli/commands.gen.go +++ b/temporalcli/commands.gen.go @@ -1830,7 +1830,7 @@ func NewTemporalServerStartDevCommand(cctx *CommandContext, parent *TemporalServ s.Command.Flags().StringVarP(&s.DbFilename, "db-filename", "f", "", "Path to file for persistent Temporal state store. By default, Workflow Executions are lost when the server process dies.") s.Command.Flags().StringArrayVarP(&s.Namespace, "namespace", "n", nil, "Namespaces to be created at launch. The \"default\" Namespace is always created automatically.") s.Command.Flags().IntVarP(&s.Port, "port", "p", 7233, "Port for the front-end gRPC Service.") - s.Command.Flags().IntVar(&s.HttpPort, "http-port", 7243, "Port for the HTTP API service.") + s.Command.Flags().IntVar(&s.HttpPort, "http-port", 0, "Port for the HTTP API service. Defaults to a random free port.") s.Command.Flags().IntVar(&s.MetricsPort, "metrics-port", 0, "Port for '/metrics'. Default is off.") s.Command.Flags().IntVar(&s.UiPort, "ui-port", 0, "Port for the Web UI. Default is '--port' value + 1000.") s.Command.Flags().BoolVar(&s.Headless, "headless", false, "Disable the Web UI.") diff --git a/temporalcli/commands.server.go b/temporalcli/commands.server.go index a626a9af..8235768c 100644 --- a/temporalcli/commands.server.go +++ b/temporalcli/commands.server.go @@ -59,8 +59,14 @@ func (t *TemporalServerStartDevCommand) run(cctx *CommandContext, args []string) if err := devserver.CheckPortFree(opts.FrontendIP, opts.FrontendPort); err != nil { return fmt.Errorf("can't set frontend port %d: %w", opts.FrontendPort, err) } - if err := devserver.CheckPortFree(opts.FrontendIP, opts.FrontendHTTPPort); err != nil { - return fmt.Errorf("can't set frontend HTTP port %d: %w", opts.FrontendHTTPPort, err) + + // Grab a free port for HTTP ahead-of-time so we know what port is selected + if opts.FrontendHTTPPort == 0 { + opts.FrontendHTTPPort = devserver.MustGetFreePort(opts.FrontendIP) + } else { + if err := devserver.CheckPortFree(opts.FrontendIP, opts.FrontendHTTPPort); err != nil { + return fmt.Errorf("can't set frontend HTTP port %d: %w", opts.FrontendHTTPPort, err) + } } // Setup UI if !t.Headless { diff --git a/temporalcli/commandsgen/commands.yml b/temporalcli/commandsgen/commands.yml index 064fdbed..83456949 100644 --- a/temporalcli/commandsgen/commands.yml +++ b/temporalcli/commandsgen/commands.yml @@ -1647,8 +1647,8 @@ commands: default: 7233 - name: http-port type: int - description: Port for the HTTP API service. - default: 7243 + description: Port for the HTTP API service. Defaults to a random free port. + default: 0 - name: metrics-port type: int description: | diff --git a/temporalcli/devserver/server.go b/temporalcli/devserver/server.go index ff0fa527..077aefaf 100644 --- a/temporalcli/devserver/server.go +++ b/temporalcli/devserver/server.go @@ -358,9 +358,7 @@ func (s *StartOptions) buildServiceConfig(frontend bool) config.Service { if frontend { conf.RPC.GRPCPort = s.FrontendPort conf.RPC.BindOnIP = s.FrontendIP - if s.FrontendHTTPPort > 0 { - conf.RPC.HTTPPort = s.FrontendHTTPPort - } + conf.RPC.HTTPPort = s.FrontendHTTPPort } else { conf.RPC.GRPCPort = MustGetFreePort(s.FrontendIP) conf.RPC.BindOnIP = s.FrontendIP From de52ee3ceac01fa1ff63193367b7d8ca460b9ecc Mon Sep 17 00:00:00 2001 From: Roey Berman Date: Tue, 7 Jan 2025 16:33:53 -0800 Subject: [PATCH 4/4] Only print HTTP port if explicitly set --- temporalcli/commands.server.go | 10 +++++----- temporalcli/devserver/server.go | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/temporalcli/commands.server.go b/temporalcli/commands.server.go index 8235768c..3edaef80 100644 --- a/temporalcli/commands.server.go +++ b/temporalcli/commands.server.go @@ -60,10 +60,7 @@ func (t *TemporalServerStartDevCommand) run(cctx *CommandContext, args []string) return fmt.Errorf("can't set frontend port %d: %w", opts.FrontendPort, err) } - // Grab a free port for HTTP ahead-of-time so we know what port is selected - if opts.FrontendHTTPPort == 0 { - opts.FrontendHTTPPort = devserver.MustGetFreePort(opts.FrontendIP) - } else { + if opts.FrontendHTTPPort > 0 { if err := devserver.CheckPortFree(opts.FrontendIP, opts.FrontendHTTPPort); err != nil { return fmt.Errorf("can't set frontend HTTP port %d: %w", opts.FrontendHTTPPort, err) } @@ -158,7 +155,10 @@ func (t *TemporalServerStartDevCommand) run(cctx *CommandContext, args []string) cctx.Printer.Printlnf("CLI %v\n", VersionString()) cctx.Printer.Printlnf("%-8s %v:%v", "Server:", toFriendlyIp(opts.FrontendIP), opts.FrontendPort) - cctx.Printer.Printlnf("%-8s %v:%v", "HTTP:", toFriendlyIp(opts.FrontendIP), opts.FrontendHTTPPort) + // Only print HTTP port if explicitly provided to avoid promoting the unstable HTTP API. + if opts.FrontendHTTPPort > 0 { + cctx.Printer.Printlnf("%-8s %v:%v", "HTTP:", toFriendlyIp(opts.FrontendIP), opts.FrontendHTTPPort) + } if !t.Headless { cctx.Printer.Printlnf("%-8s http://%v:%v%v", "UI:", toFriendlyIp(opts.UIIP), opts.UIPort, opts.PublicPath) } diff --git a/temporalcli/devserver/server.go b/temporalcli/devserver/server.go index 077aefaf..230107cf 100644 --- a/temporalcli/devserver/server.go +++ b/temporalcli/devserver/server.go @@ -117,6 +117,10 @@ func Start(options StartOptions) (*Server, error) { return nil, fmt.Errorf("missing initial failover version") } + if options.FrontendHTTPPort == 0 { + options.FrontendHTTPPort = MustGetFreePort(options.FrontendIP) + } + // Build servers var ui *uiserver.Server if options.UIIP != "" {