Skip to content

Commit

Permalink
cli: fix bug in missing-flag warning
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
miraradeva committed Jun 1, 2023
1 parent fdf0690 commit ab8b458
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions pkg/cli/interactive_tests/test_flags.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit ab8b458

Please sign in to comment.