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

release-23.2: roachprod: support managing shared process virtual clusters #112709

Merged
merged 6 commits into from
Oct 23, 2023

Conversation

blathers-crl[bot]
Copy link

@blathers-crl blathers-crl bot commented Oct 19, 2023

Backport 6/6 commits from #111533 on behalf of @renatolabs.

/cc @cockroachdb/release


This PR adds support for shared process virtual clusters using start-sql and stop-sql; previously, these subcommands would always create separate process virtual clusters. After this PR, start-sql will create shared process tenants by default. Alternatively, the --external-cluster command line flag can be used to indicate where the separate processes should be deployed. Similarly, stop-sql may be used to stop separate process virtual clusters, as before, by killing the corresponding OS process; or shared process virtual clusters by using SQL (STOP SERVICE).

A few other changes introduced in this PR, done to support this work:

  • Made ExecSQL more flexible;
  • Fixed a bug in pgurl, where we would include the virtual cluster name in the connection url returned by roachprod pgurl. This is not allowed since the URL pointed to the SQL server process, which does not handle that option.
  • Remove ability to create tenants by specifying a tenant ID. We are now creating tenants with CREATE TENANT instead of crdb_internal.create_tenant. The tenant ID is computed automatically and used when starting the cockroach process for separate process deployments.

Epic: none

Release note: None


Release justification: test-only change.

Previously, this function would execute `cockroach sql`, log the
output and return whether any errors were found. In this commit, we
change the function to return the results to the caller instead. This
is more flexible since 1) not every caller might want the results
logged; and 2) allows callers to behave differently depending on the
output of the statement executed.

Epic: none

Release note: None
This commit changes when the tenant metadata is created: instead of
creating the system table entry out of band in `multitenant.go`, we
now make this part of the `Start` function itself; this allows users
of roachprod as a library to have this behaviour out of the box.

Epic: none

Release note: None
This unifies the handling of whether to pass a `cluster=` connection
option in `NodeURL`. Previously, this was done out of band before
every call to `NodeURL`, which was error prone: as an example,
`roachprod sql` had code that correctly handled this (i.e., not
setting a cluster option if service mode is shared); `roachprod
pgurl`, on the other hand, would always set `cluster=`, generating an
invalid connection string.

Epic: none

Release note: None
This commits changes how `start-sql` operates by introducing a new
`--external-cluster` command line argument: when passed, it indicates
that the virtual cluster should be serviced by separate SQL server
processes. By default `start-sql` will create shared process tenants.

The previous behaviour of `start-sql` was to always create separate
processes. The "virtual-cluster-nodes" argument that used to be
required is now only passed via `--external-cluster`.

This commit also changes the `(*SyncedCluster).Start()` code to set
default cluster settings for tenants as well, including organization
name and license, if available.

Epic: none

Release note: None
Similar to the previous commit, we now add support to shared process
virtual clusters to `stop-sql`. Since there is no process to be
stopped in this case, the `stop` call performs a `ALTER TENANT %s STOP
SERVICE` call in order to stop the virtual cluster. This should be
transparent to the user.

Epic: none

Release note: None
This changes how virtual clusters are referenced in roachprod commands
(`start-sql` and `stop-sql`). Specifically, where before a
`cluster-id` was requested, we now request a virtual cluster
name. This makes the API more user-friendly and removes the need for
the caller to keep track of virtual cluster IDs.

With this change we now remove the "default virtual cluster name"
logic, which is no longer necessary.

Epic: none

Release note: None
@blathers-crl blathers-crl bot requested a review from a team as a code owner October 19, 2023 19:44
@blathers-crl blathers-crl bot force-pushed the blathers/backport-release-23.2-111533 branch from 79ce3cb to 6b68d73 Compare October 19, 2023 19:44
@blathers-crl blathers-crl bot requested review from herkolategan and DarrylWong and removed request for a team October 19, 2023 19:44
@blathers-crl blathers-crl bot added blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. labels Oct 19, 2023
@blathers-crl blathers-crl bot force-pushed the blathers/backport-release-23.2-111533 branch from 92aa391 to f02ffd2 Compare October 19, 2023 19:44
@blathers-crl
Copy link
Author

blathers-crl bot commented Oct 19, 2023

Thanks for opening a backport.

Please check the backport criteria before merging:

  • Patches should only be created for serious issues or test-only changes.
  • Patches should not break backwards-compatibility.
  • Patches should change as little code as possible.
  • Patches should not change on-disk formats or node communication protocols.
  • Patches should not add new functionality.
  • Patches must not add, edit, or otherwise modify cluster versions; or add version gates.
If some of the basic criteria cannot be satisfied, ensure that the exceptional criteria are satisfied within.
  • There is a high priority need for the functionality that cannot wait until the next release and is difficult to address in another way.
  • The new functionality is additive-only and only runs for clusters which have specifically “opted in” to it (e.g. by a cluster setting).
  • New code is protected by a conditional check that is trivial to verify and ensures that it only runs for opt-in clusters.
  • The PM and TL on the team that owns the changed code have signed off that the change obeys the above rules.

Add a brief release justification to the body of your PR to justify this backport.

Some other things to consider:

  • What did we do to ensure that a user that doesn’t know & care about this backport, has no idea that it happened?
  • Will this work in a cluster of mixed patch versions? Did we test that?
  • If a user upgrades a patch version, uses this feature, and then downgrades, what happens?

@blathers-crl blathers-crl bot requested a review from renatolabs October 19, 2023 19:44
@blathers-crl blathers-crl bot added the backport Label PR's that are backports to older release branches label Oct 19, 2023
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@renatolabs renatolabs merged commit 11457b4 into release-23.2 Oct 23, 2023
2 checks passed
@renatolabs renatolabs deleted the blathers/backport-release-23.2-111533 branch October 23, 2023 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Label PR's that are backports to older release branches blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants