Skip to content

Commit

Permalink
cli: rename demoCtx.simulateLatency to demoCtx.global
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
otan committed Apr 26, 2021
1 parent 8165fad commit 8ca5b9f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pkg/cli/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ var demoCtx struct {
runWorkload bool
localities demoLocalityList
geoPartitionedReplicas bool
simulateLatency bool
global bool
transientCluster *transientCluster
insecure bool
sqlPort int
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions pkg/cli/demo_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/cli/demo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8ca5b9f

Please sign in to comment.