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: Support cluster name flags in all non-sql client commands #48000

Merged
merged 1 commit into from
Apr 24, 2020

Conversation

a-robinson
Copy link
Contributor

@a-robinson a-robinson commented Apr 24, 2020

Unless I'm missing something, the cluster-name functionality is pretty
broken without the ability to use all the various client commands on
clusters that have a name. I was trying out some new features today and
couldn't figure out any supported way to do basic operations on a node
that was using a cluster-name. It seemed easy enough to fix, so here we
are.

I'm not at all tied to to including both the --cluster-name and
--disable-cluster-name-verification flags, but at first glance it seemed
useful to include both.

I didn't include any error cases in the tcl test because I didn't want
to have to figure out the correct tcl for dealing with the fact that the
commands hang in a seemingly infinite retry loop when the cluster-name
is missing/incorrect.

Fixes #40437

Release note (cli change): Client commands such as init and quit now
support the --cluster-name and --disable-cluster-name-verification flags
in order to support running them on clusters that have been configured
to use a cluster name. Previously it was impossible to run such
commands against nodes configured with the --cluster-name flag.


Hi @knz!

This seems like a strong cherry-pick candidate for a 20.1.x patch release (and maybe even a 19.2.x release) since the --cluster-name flag is a basically a trap for anyone trying to use it without this fix, but I'd also wager that it's not considered particularly urgent for 20.1.0 given that @rolandcrosby's ticket has gone unfixed since last September.

@a-robinson a-robinson requested a review from knz April 24, 2020 01:50
@a-robinson a-robinson requested a review from a team as a code owner April 24, 2020 01:50
@blathers-crl
Copy link

blathers-crl bot commented Apr 24, 2020

Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR.

My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@cockroach-teamcity
Copy link
Member

cockroach-teamcity commented Apr 24, 2020

CLA assistant check
All committers have signed the CLA.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@knz
Copy link
Contributor

knz commented Apr 24, 2020

Thanks Alex! Happy to hear from you :-)

The functionality was intending to have clients call GRPCUnvalidatedDial which disables both cluster ID and name check. I am surprised this didn't work / wasn't tested. I'll review your PR shortly.

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I understand what's going on and actually yes this was intended to work the way you fix it. Sorry this part of the functionality slipped under the radar.

:lgtm: modulo the default fix

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @a-robinson)


pkg/cli/flags.go, line 625 at r1 (raw file):

		VarFlag(f, urlParser{cmd, &cliCtx, true /* strictSSL */}, cliflags.URL)
		VarFlag(f, clusterNameSetter{&baseCfg.ClusterName}, cliflags.ClusterName)
		BoolFlag(f, &baseCfg.DisableClusterNameVerification, cliflags.DisableClusterNameVerification, false)

try this:

BoolFlag(f, &baseCfg.DisableClusterNameVerification, cliflags.DisableClusterNameVerification, baseCfg.DisableClusterNameVerification)

Then initialize baseCfg.DisableClusterNameVerification in context.go.

@knz
Copy link
Contributor

knz commented Apr 24, 2020

This seems like a strong cherry-pick candidate for a 20.1.x patch release (and maybe even a 19.2.x release)

Fully agreed. Feel free to issue the backport PRs (but I can also do it if you prefer)

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @a-robinson)


pkg/cli/flags.go, line 625 at r1 (raw file):

Previously, knz (kena) wrote…

try this:

BoolFlag(f, &baseCfg.DisableClusterNameVerification, cliflags.DisableClusterNameVerification, baseCfg.DisableClusterNameVerification)

Then initialize baseCfg.DisableClusterNameVerification in context.go.

oh actually the default is already set in baseCfg.InitiDefaults() so no need to change anything in context.go. But still change the last argument to BoolFlag, we don't want defaults expressed in multiple places.

Unless I'm missing something, the cluster-name functionality is pretty
broken without the ability to use all the various client commands on
clusters that have a name. I was trying out some new features today and
couldn't figure out any supported way to do basic operations on a node
that was using a cluster-name. It seemed easy enough to fix, so here we
are.

I'm not at all tied to to including both the --cluster-name and
--disable-cluster-name-verification flags, but at first glance it seemed
useful to include both.

I didn't include any error cases in the tcl test because I didn't want
to have to figure out the correct tcl for dealing with the fact that the
commands hang in a seemingly infinite retry loop when the cluster-name
is missing/incorrect.

Fixes cockroachdb#40437

Release note (cli change): Client commands such as init and quit now
support the --cluster-name and --disable-cluster-name-verification flags
in order to support running them on clusters that have been configured
to use a cluster name. Previously it was impossible to run such
commands against nodes configured with the --cluster-name flag.
@blathers-crl
Copy link

blathers-crl bot commented Apr 24, 2020

Thank you for updating your pull request.

My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

Copy link
Contributor Author

@a-robinson a-robinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @knz)


pkg/cli/flags.go, line 625 at r1 (raw file):

Previously, knz (kena) wrote…

oh actually the default is already set in baseCfg.InitiDefaults() so no need to change anything in context.go. But still change the last argument to BoolFlag, we don't want defaults expressed in multiple places.

No problem, done. I changed the existing start/start-single-node flag to use it as well.

@a-robinson
Copy link
Contributor Author

Fully agreed. Feel free to issue the backport PRs (but I can also do it if you prefer)

#48016 and #48017, although I had to make them manually since go getting the backport tool was failing on a dependency version issue that I didn't want to look into, so sorry about the cockroachdb/release team not being tagged properly -- github wouldn't let me.

@a-robinson
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Apr 24, 2020

Build succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cli: cockroach quit doesn't work when cluster name is specified
3 participants