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

cli/conn+config: ux annoyance: ui shows "host:port"; cli takes --host, --port separately #23277

Closed
Amruta-Ranade opened this issue Mar 1, 2018 · 11 comments
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) S-3-ux-surprise Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.
Milestone

Comments

@Amruta-Ranade
Copy link
Contributor

Amruta-Ranade commented Mar 1, 2018

While trying to decommission a dead node following the instructions in the Remove nodes doc, the ./cockroach node decommission 4 --wait=live --insecure --host=localhost:26257 command gave the following error even though localhost:26257 is a live node:

Error: unable to connect or connection lost.
Please check the address and credentials such as certificates (if attempting to
communicate with a secure cluster).
Failed to connect to the node: initial connection heartbeat failed: rpc error: code = Unavailable desc = all SubConns are in TransientFailure
Failed running "node" 

Whereas ./cockroach node decommission 4 --wait=live --insecure did decommission the node.

@Amruta-Ranade Amruta-Ranade added this to the 2.0 milestone Mar 1, 2018
@vilterp
Copy link
Contributor

vilterp commented Mar 1, 2018

Looks like you're supposed to split out --host and --port: cockroach node decommission 4 --wait=live --insecure --host=localhost --port=26257.

This could use a better error message; something like "couldn't connect to localhost:26257:26257", which is probably what it tried…

@vilterp vilterp changed the title Decommissioning node command worked without the --host flag but not with the flag cli: confusing error message when host:port specified in --host flag Mar 1, 2018
@Amruta-Ranade
Copy link
Contributor Author

Interesting. Wouldn't the user go to the Admin UI, check the hostname, and use that in the command though? In any case, we need to make the syntax clearer in the Docs then.

@vilterp
Copy link
Contributor

vilterp commented Mar 1, 2018

Hm yeah the commands in the docs say --host <address of live node>. They should probably say --host <host of live node> --port <port of live node>. Filing a docs issue is in order I think.

@vilterp
Copy link
Contributor

vilterp commented Mar 1, 2018

But yes, it's annoying that you can't just copy/paste the host:port from the UI into the command.

  • We don't want to change the UI, since host:port is nice and compact and easy to read.
  • Could change the command, e.g. to take --address <host:port> instead of --host <host> --port <port>, but we'd have to make the change backwards compatible (to avoid breaking scripts that use the old flags). Could have both forms, but having two sets of flags that specify the same information seems bad.

@bdarnell
Copy link
Contributor

bdarnell commented Mar 1, 2018

The UI could hide the port if it's the default.

We could also encourage the use of the --url flag which incorporates all the client flags (host, port, insecure, etc). We already have two sets of flags that specify the same information.

@vilterp vilterp added the S-3-ux-surprise Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption. label Mar 1, 2018
@vilterp
Copy link
Contributor

vilterp commented Mar 1, 2018

Maybe a little "copy to clipboard" icon next to the host:port in the UI which copies the URL to your clipboard would be useful. Then you can paste that into CLI commands for the --url flag.

@vilterp vilterp changed the title cli: confusing error message when host:port specified in --host flag cli/ui: ux annoyance: ui shows "host:port"; cli takes --host, --port separately Mar 1, 2018
@vivekmenezes vivekmenezes modified the milestones: 2.0, 2.1 Mar 2, 2018
@couchand
Copy link
Contributor

couchand commented Mar 5, 2018

I did not even know --url was a thing. We should definitely encourage that for most commands. There doesn't seem to be much of a reason to advertise separate flags. In fact, can we just deprecate them? Is there a use case that the more general --url flag doesn't solve?

I'm not keen on the other suggestions here, mostly because they wouldn't really address this issue.

@a-robinson
Copy link
Contributor

In fact, can we just deprecate them? Is there a use case that the more general --url flag doesn't solve?

Having the same flags on the client commands as on cockroach start makes them easier to use for newcomers, since they can just specify the same flags for e.g. cockroach sql that they did for cockroach start.

There's also the issue that the URLs are confusing, at least for secure mode. Every time I want to run kv against a secure cluster I have to spend a couple minutes figuring out the right incantations for including each certificate file in the URL and then another minute or two painstakingly typing out the paths to each file. If I'm lucky, I can find it in my bash history, otherwise I have to come up with something like postgres://root@localhost:26257/?sslmode=verify-ca&sslrootcert=/Users/alex/.cockroach-certs/ca.crt&sslcert=/Users/alex/.cockroach-certs/client.root.crt&sslkey=/Users/alex/.cockroach-certs/client.root.key.

@couchand
Copy link
Contributor

couchand commented Mar 5, 2018

Oh that's unfortunate. I had hoped that the URL flag would just be shorthand for the host and port flags, where you could omit defaulted fields, like:

  • set host and port --url=foobar:26258
  • set just host, default port --url=foobar
  • set just port, default host --url=*:26258?

But now that I think about it, of course it's the connection string-style URLs. That's unfortunate.

@bdarnell
Copy link
Contributor

#24628 points out that we use the host:port format in the --join flag too, so the requirement to use separate --host and --port flags (or the completely different --url flag) for client commands is unexpected.

I think it's probably best to allow --host to contain a host:port pair when --port is unspecified, as long as this is unambiguous with IPv6 literals. I think that's true (IPv6 literals always contain at least two colons, right?) but we should double-check.

@knz
Copy link
Contributor

knz commented Apr 10, 2018

So I worked on the --url flag to make most parts of it optional, so --url=postgres://foobar:26258 would be valid.

However some of the cockroach commands do not yet recognize --url, because --url is currently only used for the commands that use a SQL connection.

This is trivial to extend to non-SQL cli commands, by having those extract what they need from the URL.

@knz knz changed the title cli/ui: ux annoyance: ui shows "host:port"; cli takes --host, --port separately cli/conn+config: ux annoyance: ui shows "host:port"; cli takes --host, --port separately Apr 11, 2018
@knz knz added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Apr 27, 2018
craig bot pushed a commit that referenced this issue Aug 9, 2018
28373: cli: make --host/--{listen,advertise,http}-addr recognize port numbers r=knz a=knz

cc @jseldess @Amruta-Ranade 
Fixes #23277.
Needed for #5816.

Prior to this patch, the various `cockroach` sub-commands would take
separate flags to specify an address/hostanme and to specify a port
number.

Meanwhile:

1. `--join` would recognize the syntax `host:port`.
2. the web UI, docs and other places often refer to a "server address"
   as the pair hostname:portnr.

For user convenience, it is thus important to make the interface more
straightforward/regular. This patch achieves this as follows:

- the flags
  `--listen-addr`/`--advertise-addr`/`--http-addr` (server-side) and
  `--host` (client-side) now recognize the syntax `host/addr:port`.
- the server-side `--port` flags are still recognized for backward
  compatibility but are marked as deprecated.
  The client-side `--port` is still recognized and not
  deprecated for now, but hidden from the contextual help.

As a side-effect of recognizing the port number inside the same flag,
the syntax with square brackets for IPv6 addresses now becomes
necessary when specifying also a port number. The syntax without
square brackets (and without port number) is temporarily still
recognized for backward compatibility, but is also marked as
deprecated.

Release note (cli change): the server-side command line flag
`--listen-addr`, which replaces the previous `--host` flag, is now
equipped to recognize both a hostname/address and port number. The
`--port` flag is deprecated as a result.

Release note (cli change): the server-side command line flag
`--http-addr`, which replaces the previous `--http-host` flag, is now
equipped to recognize both a hostname/address and port number. The
`--http-port` flag is deprecated as a result.

Release note (cli change): the server-side command line flag
`--advertise-addr`, which replaces the previous `--advertise-host`
flag, is now equipped to recognize both a hostname/address and
port number. The `--advertise-port` flag is deprecated as a result.

Release note (cli change): the client-side command line flag `--host`
is now equipped to recognize both a hostname/address and port
number. The client-side `--port` flag is still recognized,
but not documented any more; `--host` is now preferred.

Release note (cli change): the environment variable COCKROACH_PORT
that specifies the port number to use for client commands is now
deprecated. The port number can be placed in the COCKROACH_HOST
environment variable instead.

Release note (cli change): The syntax to specify IPv6 addresses with
the client-side command line flag `--host` is changed to use square
brackets, for example `--host=[::1]` instead of just `--host=::1`
previously. The previous syntax is still recognized for backward
compatibility but is deprecated.

Release note (cli change): the flag `--listen-port` which was
introduced in a recent change is now removed. (DOCS NOTE: remove both
this release note and the previous one that introduced --listen-port)

Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
@craig craig bot closed this as completed in #28373 Aug 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) S-3-ux-surprise Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.
Projects
None yet
Development

No branches or pull requests

7 participants