Skip to content

Commit

Permalink
configprofiles: emphasize "cluster virtualization"
Browse files Browse the repository at this point in the history
Before this patch:
```
$ cockroach start-single-node --config-profile=help
...
replication-source                  configuration suitable for a replication source cluster (alias for "multitenant+app+sharedservice+repl")
replication-target                  configuration suitable for a replication target cluster (alias for "multitenant+noapp+repl")`
multitenant+app+sharedservice       multi-tenant cluster with one secondary tenant configured to serve SQL application traffic
multitenant+app+sharedservice+repl  multi-tenant cluster with one secondary tenant configured to serve SQL application traffic, with replication enabled
multitenant+noapp                   multi-tenant cluster with no secondary tenant defined yet
multitenant+noapp+repl              multi-tenant cluster with no secondary tenant defined yet, with replication enabled
```

After this patch:
```
replication-source              configuration suitable for a replication source cluster (alias for "virtual+app+sharedservice+repl")
replication-target              configuration suitable for a replication target cluster (alias for "virtual+noapp+repl")
virtual+app+sharedservice       one virtual cluster configured to serve SQL application traffic
virtual+app+sharedservice+repl  one virtual cluster configured to serve SQL application traffic, with replication enabled
virtual+noapp                   virtualization enabled but no virtual cluster defined yet
virtual+noapp+repl              virtualization enabled but no virtual cluster defined yet, with replication enabled
```

Release note: None
  • Loading branch information
knz committed Jul 6, 2023
1 parent 6319c0a commit 8b7f893
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 31 deletions.
43 changes: 22 additions & 21 deletions pkg/configprofiles/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ import (
type alias struct {
aliasTarget string
description string
hidden bool
}

var aliases = map[string]alias{
"replication-source": {
aliasTarget: "multitenant+app+sharedservice+repl",
aliasTarget: "virtual+app+sharedservice+repl",
description: "configuration suitable for a replication source cluster",
},
"replication-target": {
aliasTarget: "multitenant+noapp+repl",
aliasTarget: "virtual+noapp+repl",
description: "configuration suitable for a replication target cluster",
},
}
Expand Down Expand Up @@ -60,25 +61,25 @@ var staticProfiles = map[string]configProfile{
),
},
},
"multitenant+noapp": {
description: "multi-tenant cluster with no secondary tenant defined yet",
tasks: multitenantClusterInitTasks,
"virtual+noapp": {
description: "virtualization enabled but no virtual cluster defined yet",
tasks: virtClusterInitTasks,
},
"multitenant+noapp+repl": {
description: "multi-tenant cluster with no secondary tenant defined yet, with replication enabled",
tasks: enableReplication(multitenantClusterInitTasks),
"virtual+noapp+repl": {
description: "virtualization enabled but no virtual cluster defined yet, with replication enabled",
tasks: enableReplication(virtClusterInitTasks),
},
"multitenant+app+sharedservice": {
description: "multi-tenant cluster with one secondary tenant configured to serve SQL application traffic",
tasks: multitenantClusterWithAppServiceInitTasks,
"virtual+app+sharedservice": {
description: "one virtual cluster configured to serve SQL application traffic",
tasks: virtClusterWithAppServiceInitTasks,
},
"multitenant+app+sharedservice+repl": {
description: "multi-tenant cluster with one secondary tenant configured to serve SQL application traffic, with replication enabled",
tasks: enableReplication(multitenantClusterWithAppServiceInitTasks),
"virtual+app+sharedservice+repl": {
description: "one virtual cluster configured to serve SQL application traffic, with replication enabled",
tasks: enableReplication(virtClusterWithAppServiceInitTasks),
},
}

var multitenantClusterInitTasks = []autoconfigpb.Task{
var virtClusterInitTasks = []autoconfigpb.Task{
makeTask("initial cluster config",
/* nonTxnSQL */ []string{
// Disable trace redaction (this ought to be configurable per-tenant, but is not possible yet in v23.1).
Expand All @@ -96,7 +97,7 @@ var multitenantClusterInitTasks = []autoconfigpb.Task{
},
nil, /* txnSQL */
),
makeTask("create tenant template",
makeTask("create virtual cluster template",
nil, /* nonTxnSQL */
/* txnSQL */
[]string{
Expand All @@ -110,17 +111,17 @@ var multitenantClusterInitTasks = []autoconfigpb.Task{
},
),
// Finally.
makeTask("use the application tenant template by default in CREATE VIRTUAL CLUSTER",
makeTask("use the application virtual cluster template by default in CREATE VIRTUAL CLSUTER",
/* nonTxnSQL */ []string{
"SET CLUSTER SETTING sql.create_tenant.default_template = 'template'",
},
nil, /* txnSQL */
),
}

var multitenantClusterWithAppServiceInitTasks = append(
multitenantClusterInitTasks,
makeTask("create an application tenant",
var virtClusterWithAppServiceInitTasks = append(
virtClusterInitTasks,
makeTask("create an application virtual cluster",
nil, /* nonTxnSQL */
/* txnSQL */ []string{
// Create the app tenant record.
Expand All @@ -129,7 +130,7 @@ var multitenantClusterWithAppServiceInitTasks = append(
"ALTER VIRTUAL CLUSTER application START SERVICE SHARED",
},
),
makeTask("activate application tenant",
makeTask("activate application virtual cluster",
/* nonTxnSQL */ []string{
// Make the app tenant receive SQL connections by default.
"SET CLUSTER SETTING server.controller.default_tenant = 'application'",
Expand Down
3 changes: 3 additions & 0 deletions pkg/configprofiles/setter.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ var profileHelp = func() string {
if _, ok := staticProfiles[a.aliasTarget]; !ok {
panic(errors.AssertionFailedf("alias %q refers to non-existent profile %q", name, a.aliasTarget))
}
if a.hidden {
continue
}
allNames = append(allNames, name)
}
sort.Strings(allNames)
Expand Down
2 changes: 1 addition & 1 deletion pkg/configprofiles/testdata/replication-source
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
profile
replication-source
----
canonical profile name: multitenant+app+sharedservice+repl
canonical profile name: virtual+app+sharedservice+repl
server started
2 changes: 1 addition & 1 deletion pkg/configprofiles/testdata/replication-target
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
profile
replication-target
----
canonical profile name: multitenant+noapp+repl
canonical profile name: virtual+noapp+repl
server started
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
profile
multitenant+app+sharedservice
virtual+app+sharedservice
----
canonical profile name: multitenant+app+sharedservice
canonical profile name: virtual+app+sharedservice
server started

connect-tenant
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
profile
multitenant+app+sharedservice+repl
virtual+app+sharedservice+repl
----
canonical profile name: multitenant+app+sharedservice+repl
canonical profile name: virtual+app+sharedservice+repl
server started

connect-tenant
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
profile
multitenant+noapp
virtual+noapp
----
canonical profile name: multitenant+noapp
canonical profile name: virtual+noapp
server started

system-sql
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
profile
multitenant+noapp+repl
virtual+noapp+repl
----
canonical profile name: multitenant+noapp+repl
canonical profile name: virtual+noapp+repl
server started

system-sql
Expand Down

0 comments on commit 8b7f893

Please sign in to comment.