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

roachtest: update mixedversion to always use secure clusters #105454

Merged
merged 3 commits into from
Jun 29, 2023

Conversation

renatolabs
Copy link
Contributor

Secure clusters are closer to production deployments and also allow
us to tests features that we couldn't before, like creating new users
with passwords during a test, and then performing SQL operations with
those users.

In the process of getting this to work, there were a few bugs that needed
to be fixed (first commit), and the cluster interface needed a small update
as well (second commit).

Epic: CRDB-19321

Release note: None

@renatolabs renatolabs requested a review from a team as a code owner June 23, 2023 19:21
@renatolabs renatolabs requested review from srosenberg and smg260 and removed request for a team June 23, 2023 19:21
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@renatolabs renatolabs force-pushed the rc/mixedversion-secure-clusters branch 2 times, most recently from 899ca1a to 80030d6 Compare June 23, 2023 20:49
@renatolabs renatolabs force-pushed the rc/mixedversion-secure-clusters branch from 80030d6 to 9fd2a46 Compare June 28, 2023 13:42
@renatolabs
Copy link
Contributor Author

Rebased and fixed conflicts.

@renatolabs renatolabs force-pushed the rc/mixedversion-secure-clusters branch from 9fd2a46 to cf171a6 Compare June 28, 2023 14:07
Copy link
Member

@srosenberg srosenberg left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 3 files at r1, 23 of 23 files at r2, 7 of 7 files at r3, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @renatolabs and @smg260)


pkg/cmd/roachtest/cluster.go line 1506 at r3 (raw file):

				Flag("exclude-files", fmt.Sprintf("'%s'", excludeFiles)).
				Flag("url", fmt.Sprintf("{pgurl:%d}", i)).
				MaybeFlag(c.IsSecure(), "certs-dir", "certs").

Nice!


pkg/cmd/roachtest/cluster.go line 2100 at r3 (raw file):

	}
	// If the test failed (indicated by a canceled ctx), short-circuit.
	if ctx.Err() != nil {

How could we miss this dead code in PR review(s)?! It's also interesting that it's not flagged by any of the linters, including staticcheck's unused. (None of them perform a control-flow sensitive analysis.) 🤷‍♂️


pkg/cmd/roachtest/roachtestutil/mixedversion/mixedversion.go line 123 at r3 (raw file):

	// nodes in a cluster.
	defaultClusterSettings = []install.ClusterSettingOption{
		install.SecureOption(true),

Nice!


pkg/roachprod/install/cluster_synced.go line 1537 at r3 (raw file):

	l.Printf("%s: checking %s", c.Name, path)
	result, err := c.runCmdOnSingleNode(ctx, l, 1, `$(test -e `+path+`); echo $?`, false, l.Stdout, l.Stderr)
	return strings.TrimSpace(result.Stdout) == "0", err

Might be worth leaving a comment as to why TrimSpace is required for correctness. Alternatively, echo -n $? would suffice, methinks.

This commit fixes a number of small bugs related to using secure
clusters in roachtests, which probably stayed dormant up to this point
because we don't use secure clusters enough, especially in tests where
nodes are restarted.

In this commit, we avoid refetching certs when restarting, fix the
checks for certificate existence on nodes, and fix the command to wipe
a cluster when certs are to be preserved.

Epic: none

Release note: None
This parameter already existed in the underlying `cluster_synced`
implemenation, but the `cluster` interface exposed to roachtsts forced
that argument to `false`.

This commit changes the interface to expose the parameter, allowing
tests to wipe clusters while keeping the certs intact.

Epic: none

Release note: None
Secure clusters are closer to production deployments and also allow
us to tests features that we couldn't before, like creating new users
with passwords during a test, and then performing SQL operations with
those users.

Epic: CRDB-19321

Release note: None
@renatolabs renatolabs force-pushed the rc/mixedversion-secure-clusters branch from cf171a6 to c2eaf1f Compare June 29, 2023 13:28
Copy link
Contributor Author

@renatolabs renatolabs left a comment

Choose a reason for hiding this comment

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

TFTR!

bors r=srosenberg

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


pkg/roachprod/install/cluster_synced.go line 1537 at r3 (raw file):

Previously, srosenberg (Stan Rosenberg) wrote…

Might be worth leaving a comment as to why TrimSpace is required for correctness. Alternatively, echo -n $? would suffice, methinks.

Opted to use echo -n, including a comment as to why it's needed.

@craig craig bot merged commit 2b66f95 into cockroachdb:master Jun 29, 2023
@craig
Copy link
Contributor

craig bot commented Jun 29, 2023

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.

3 participants