From ab8b4582abef3b6ac7fa93db76d82ff5aebb99d4 Mon Sep 17 00:00:00 2001 From: Mira Radeva Date: Tue, 30 May 2023 15:02:34 -0400 Subject: [PATCH] cli: fix bug in missing-flag warning When the server starts, the user is supposed to see a warning if neither --listen-addr nor --advertise-addr flags are specified. Currently, even if --advertise-addr is specified, the warning is displayed. This patch fixes the small bug causing this behavior. Fixes: #103897 Epic: CRDB-28249 Release note (bug fix): Warning message for missing --advertise-addr flag is no longer displayed when the flag is specified upon server start. --- pkg/cli/interactive_tests/test_flags.tcl | 13 +++++++++++++ pkg/cli/start.go | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/cli/interactive_tests/test_flags.tcl b/pkg/cli/interactive_tests/test_flags.tcl index 7691fdb9ca39..525468f72952 100644 --- a/pkg/cli/interactive_tests/test_flags.tcl +++ b/pkg/cli/interactive_tests/test_flags.tcl @@ -46,6 +46,19 @@ interrupt eexpect ":/# " end_test +start_test "Check that using --advertise-addr does not cause a user warning." +send "$argv start-single-node --insecure --advertise-addr=172.31.11.189\r" +expect { + "WARNING: neither --listen-addr nor --advertise-addr was specified" { + report "unexpected WARNING: neither --listen-addr nor --advertise-addr was specified" + exit 1 + } +} +eexpect "node starting" +interrupt +eexpect ":/# " +end_test + start_test "Check that --listening-url-file gets created with the right data" send "$argv start-single-node --insecure --listening-url-file=foourl\r" eexpect "node starting" diff --git a/pkg/cli/start.go b/pkg/cli/start.go index 51c4bca7d101..226cb31a6044 100644 --- a/pkg/cli/start.go +++ b/pkg/cli/start.go @@ -1264,7 +1264,7 @@ func hintServerCmdFlags(ctx context.Context, cmd *cobra.Command) { } changed := func(flagName string) bool { - fl := pf.Lookup(cliflags.ListenAddr.Name) + fl := pf.Lookup(flagName) return fl != nil && fl.Changed }