From 8ca5b9fb6301d4da8bd05a63bf303c533a44ff65 Mon Sep 17 00:00:00 2001 From: Oliver Tan Date: Tue, 27 Apr 2021 07:15:58 +1000 Subject: [PATCH] cli: rename demoCtx.simulateLatency to demoCtx.global Release note: None --- pkg/cli/context.go | 4 ++-- pkg/cli/demo.go | 4 ++-- pkg/cli/demo_cluster.go | 10 +++++----- pkg/cli/demo_test.go | 5 +++-- pkg/cli/flags.go | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/pkg/cli/context.go b/pkg/cli/context.go index 73586fbb8251..14ddcd356fdd 100644 --- a/pkg/cli/context.go +++ b/pkg/cli/context.go @@ -559,7 +559,7 @@ var demoCtx struct { runWorkload bool localities demoLocalityList geoPartitionedReplicas bool - simulateLatency bool + global bool transientCluster *transientCluster insecure bool sqlPort int @@ -574,7 +574,7 @@ func setDemoContextDefaults() { demoCtx.sqlPoolMemorySize = 128 << 20 // 128MB, chosen to fit 9 nodes on 2GB machine. demoCtx.cacheSize = 64 << 20 // 64MB, chosen to fit 9 nodes on 2GB machine. demoCtx.noExampleDatabase = false - demoCtx.simulateLatency = false + demoCtx.global = false demoCtx.runWorkload = false demoCtx.localities = nil demoCtx.geoPartitionedReplicas = false diff --git a/pkg/cli/demo.go b/pkg/cli/demo.go index d28a8d67e821..50dac710d48b 100644 --- a/pkg/cli/demo.go +++ b/pkg/cli/demo.go @@ -200,7 +200,7 @@ func checkDemoConfiguration( } // If artificial latencies were requested, then the user cannot supply their own localities. - if demoCtx.simulateLatency && demoCtx.localities != nil { + if demoCtx.global && demoCtx.localities != nil { return nil, errors.Newf("--%s cannot be used with --%s", cliflags.Global.Name, cliflags.DemoNodeLocality.Name) } @@ -299,7 +299,7 @@ func runDemo(cmd *cobra.Command, gen workload.Generator) (err error) { # You are connected to a temporary, in-memory CockroachDB cluster of %d node%s. `, demoCtx.nodes, util.Pluralize(int64(demoCtx.nodes))) - if demoCtx.simulateLatency { + if demoCtx.global { printfUnlessEmbedded( "#\n# WARNING: the use of --%s is experimental. Some features may not work as expected.\n", cliflags.Global.Name, diff --git a/pkg/cli/demo_cluster.go b/pkg/cli/demo_cluster.go index 80e3149e0ae4..63507e2fded6 100644 --- a/pkg/cli/demo_cluster.go +++ b/pkg/cli/demo_cluster.go @@ -240,7 +240,7 @@ func (c *transientCluster) start( phaseCtx := logtags.AddTag(ctx, "phase", 5) // If latency simulation is requested, initialize the latency map. - if demoCtx.simulateLatency { + if demoCtx.global { // Now, all servers have been started enough to know their own RPC serving // addresses, but nothing else. Assemble the artificial latency map. log.Infof(phaseCtx, "initializing latency map") @@ -374,7 +374,7 @@ func (c *transientCluster) createAndAddNode( // it continues the startup routine. serverKnobs.PauseAfterGettingRPCAddress = latencyMapWaitCh - if demoCtx.simulateLatency { + if demoCtx.global { // The latency map will be populated after all servers have // started listening on RPC, and before they proceed with their // startup routine. @@ -627,7 +627,7 @@ func (c *transientCluster) cleanup(ctx context.Context) { // DrainAndShutdown will gracefully attempt to drain a node in the cluster, and // then shut it down. func (c *transientCluster) DrainAndShutdown(nodeID roachpb.NodeID) error { - if demoCtx.simulateLatency { + if demoCtx.global { return errors.Errorf("shutting down nodes is not supported in --%s configurations", cliflags.Global.Name) } nodeIndex := int(nodeID - 1) @@ -751,7 +751,7 @@ func (c *transientCluster) RestartNode(nodeID roachpb.NodeID) error { // TODO(#42243): re-compute the latency mapping. // TODO(...): the RPC address of the first server may not be available // if the first server was shut down. - if demoCtx.simulateLatency { + if demoCtx.global { return errors.Errorf("restarting nodes is not supported in --%s configurations", cliflags.Global.Name) } args := testServerArgsForTransientCluster(c.sockForServer(nodeID), nodeID, @@ -790,7 +790,7 @@ func (c *transientCluster) RestartNode(nodeID roachpb.NodeID) error { // starting. func (c *transientCluster) AddNode(ctx context.Context, localityString string) error { // TODO(#42243): re-compute the latency mapping for this to work. - if demoCtx.simulateLatency { + if demoCtx.global { return errors.Errorf("adding nodes is not supported in --%s configurations", cliflags.Global.Name) } diff --git a/pkg/cli/demo_test.go b/pkg/cli/demo_test.go index 229a26836065..c5c923119dff 100644 --- a/pkg/cli/demo_test.go +++ b/pkg/cli/demo_test.go @@ -120,7 +120,7 @@ func TestTestServerArgsForTransientCluster(t *testing.T) { } } -func TestTransientClusterSimulateLatencies(t *testing.T) { +func TestTransientClusterGlobal(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) @@ -134,7 +134,8 @@ func TestTransientClusterSimulateLatencies(t *testing.T) { defer TestingReset() // Set up an empty 9-node cluster with simulated latencies. - demoCtx.simulateLatency = true + demoCtx.global = true + demoCtx.noExampleDatabase = true demoCtx.nodes = 9 certsDir, err := ioutil.TempDir("", "cli-demo-test") diff --git a/pkg/cli/flags.go b/pkg/cli/flags.go index 1a448357ea26..8012bb7af050 100644 --- a/pkg/cli/flags.go +++ b/pkg/cli/flags.go @@ -766,7 +766,7 @@ func init() { "For details, see: "+build.MakeIssueURL(53404)) boolFlag(f, &demoCtx.disableLicenseAcquisition, cliflags.DemoNoLicense) - boolFlag(f, &demoCtx.simulateLatency, cliflags.Global) + boolFlag(f, &demoCtx.global, cliflags.Global) // The --empty flag is only valid for the top level demo command, // so we use the regular flag set. boolFlag(demoCmd.Flags(), &demoCtx.noExampleDatabase, cliflags.UseEmptyDatabase)