Skip to content

Commit

Permalink
upgrade: rename migration
Browse files Browse the repository at this point in the history
We've got a whole new team we're going to call migrations. It was bound to get
confusing.

Release note: None
  • Loading branch information
ajwerner committed May 17, 2022
1 parent a30f5a3 commit 32622e1
Show file tree
Hide file tree
Showing 108 changed files with 619 additions and 588 deletions.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
/pkg/ccl/cmdccl/stub-schema-registry/ @cockroachdb/cdc-prs
/pkg/ccl/gssapiccl/ @cockroachdb/server-prs
/pkg/ccl/kvccl/ @cockroachdb/kv-noreview
/pkg/ccl/migrationccl/ @cockroachdb/kv-prs-noreview
/pkg/ccl/upgradeccl/ @cockroachdb/kv-prs-noreview
/pkg/ccl/logictestccl/ @cockroachdb/sql-queries-noreview
/pkg/ccl/multiregionccl/ @cockroachdb/multiregion
/pkg/ccl/multitenantccl/ @cockroachdb/unowned
Expand Down Expand Up @@ -243,7 +243,7 @@
/pkg/keysbase/ @cockroachdb/kv-prs
# Don't ping KV on updates to reserved descriptor IDs and such.
/pkg/keys/constants.go @cockroachdb/kv-prs-noreview
/pkg/migration/ @cockroachdb/kv-prs-noreview @cockroachdb/sql-schema
/pkg/upgrade/ @cockroachdb/kv-prs-noreview @cockroachdb/sql-schema
/pkg/multitenant @cockroachdb/unowned
/pkg/release/ @cockroachdb/dev-inf
/pkg/roachpb/.gitattributes @cockroachdb/dev-inf
Expand Down
9 changes: 5 additions & 4 deletions pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ ALL_TESTS = [
"//pkg/ccl/kvccl/kvfollowerreadsccl:kvfollowerreadsccl_test",
"//pkg/ccl/kvccl/kvtenantccl:kvtenantccl_test",
"//pkg/ccl/logictestccl:logictestccl_test",
"//pkg/ccl/migrationccl/migrationsccl:migrationsccl_test",
"//pkg/ccl/multiregionccl:multiregionccl_test",
"//pkg/ccl/multitenantccl/tenantcostclient:tenantcostclient_test",
"//pkg/ccl/multitenantccl/tenantcostserver/tenanttokenbucket:tenanttokenbucket_test",
Expand Down Expand Up @@ -58,6 +57,8 @@ ALL_TESTS = [
"//pkg/ccl/telemetryccl:telemetryccl_test",
"//pkg/ccl/testccl/sqlccl:sqlccl_test",
"//pkg/ccl/testccl/workload/schemachange:schemachange_test",
"//pkg/ccl/upgradeccl/upgradessccl:upgradesccl_test",
"//pkg/ccl/upgradeccl/upgradessccl:upgradessccl_test",
"//pkg/ccl/utilccl/sampledataccl:sampledataccl_test",
"//pkg/ccl/utilccl:utilccl_test",
"//pkg/ccl/workloadccl/allccl:allccl_test",
Expand Down Expand Up @@ -177,9 +178,6 @@ ALL_TESTS = [
"//pkg/kv/kvserver/uncertainty:uncertainty_test",
"//pkg/kv/kvserver:kvserver_test",
"//pkg/kv:kv_test",
"//pkg/migration/migrationcluster:migrationcluster_test",
"//pkg/migration/migrationmanager:migrationmanager_test",
"//pkg/migration/migrations:migrations_test",
"//pkg/roachpb:roachpb_test",
"//pkg/roachpb:string_test",
"//pkg/roachprod/cloud:cloud_test",
Expand Down Expand Up @@ -434,6 +432,9 @@ ALL_TESTS = [
"//pkg/testutils:testutils_test",
"//pkg/ts/testmodel:testmodel_test",
"//pkg/ts:ts_test",
"//pkg/upgrade/upgradecluster:upgradecluster_test",
"//pkg/upgrade/upgrademanager:upgrademanager_test",
"//pkg/upgrade/upgrades:upgrades_test",
"//pkg/util/admission:admission_test",
"//pkg/util/binfetcher:binfetcher_test",
"//pkg/util/bitarray:bitarray_test",
Expand Down
2 changes: 1 addition & 1 deletion pkg/base/testing_knobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type TestingKnobs struct {
BackupRestore ModuleTestingKnobs
TTL ModuleTestingKnobs
Streaming ModuleTestingKnobs
MigrationManager ModuleTestingKnobs
UpgradeManager ModuleTestingKnobs
IndexUsageStatsKnobs ModuleTestingKnobs
SQLStatsKnobs ModuleTestingKnobs
SpanConfig ModuleTestingKnobs
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/kvccl/kvtenantccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ go_test(
"//pkg/kv/kvclient/kvtenant",
"//pkg/kv/kvserver",
"//pkg/kv/kvserver/kvserverbase",
"//pkg/migration",
"//pkg/migration/migrations",
"//pkg/roachpb",
"//pkg/rpc",
"//pkg/security",
Expand All @@ -77,6 +75,8 @@ go_test(
"//pkg/testutils/serverutils",
"//pkg/testutils/sqlutils",
"//pkg/testutils/testcluster",
"//pkg/upgrade",
"//pkg/upgrade/upgrades",
"//pkg/util",
"//pkg/util/grpcutil",
"//pkg/util/hlc",
Expand Down
22 changes: 11 additions & 11 deletions pkg/ccl/kvccl/kvtenantccl/tenant_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/config"
"github.com/cockroachdb/cockroach/pkg/jobs"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/migration"
"github.com/cockroachdb/cockroach/pkg/migration/migrations"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/security/username"
"github.com/cockroachdb/cockroach/pkg/server"
Expand All @@ -31,6 +29,8 @@ import (
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
"github.com/cockroachdb/cockroach/pkg/testutils/testcluster"
"github.com/cockroachdb/cockroach/pkg/upgrade"
"github.com/cockroachdb/cockroach/pkg/upgrade/upgrades"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/stop"
Expand Down Expand Up @@ -254,29 +254,29 @@ func TestTenantUpgradeFailure(t *testing.T) {
Existing: existing,
TestingKnobs: base.TestingKnobs{
JobsTestingKnobs: jobs.NewTestingKnobsWithShortIntervals(),
MigrationManager: &migration.TestingKnobs{
UpgradeManager: &upgrade.TestingKnobs{
ListBetweenOverride: func(from, to clusterversion.ClusterVersion) []clusterversion.ClusterVersion {
return []clusterversion.ClusterVersion{{Version: v1}, {Version: v2}}
},
RegistryOverride: func(cv clusterversion.ClusterVersion) (migration.Migration, bool) {
RegistryOverride: func(cv clusterversion.ClusterVersion) (upgrade.Upgrade, bool) {
switch cv.Version {
case v1:
return migration.NewTenantMigration("testing", clusterversion.ClusterVersion{
return upgrade.NewTenantUpgrade("testing", clusterversion.ClusterVersion{
Version: v1,
},
migrations.NoPrecondition,
upgrades.NoPrecondition,
func(
ctx context.Context, version clusterversion.ClusterVersion, deps migration.TenantDeps, _ *jobs.Job,
ctx context.Context, version clusterversion.ClusterVersion, deps upgrade.TenantDeps, _ *jobs.Job,
) error {
return nil
}), true
case v2:
return migration.NewTenantMigration("testing next", clusterversion.ClusterVersion{
return upgrade.NewTenantUpgrade("testing next", clusterversion.ClusterVersion{
Version: v2,
},
migrations.NoPrecondition,
upgrades.NoPrecondition,
func(
ctx context.Context, version clusterversion.ClusterVersion, deps migration.TenantDeps, _ *jobs.Job,
ctx context.Context, version clusterversion.ClusterVersion, deps upgrade.TenantDeps, _ *jobs.Job,
) error {
tenantStopperChannel <- struct{}{}
return nil
Expand Down Expand Up @@ -319,7 +319,7 @@ func TestTenantUpgradeFailure(t *testing.T) {
clusterversion.TestingBinaryVersion.String())
// Ensure that the tenant still works.
initialTenantRunner.CheckQueryResults(t, "SELECT * FROM t", [][]string{{"1"}, {"2"}})
// Upgrade the tenant cluster, but the migration will fail on v1.
// Upgrade the tenant cluster, but the upgrade will fail on v1.
initialTenantRunner.ExpectErr(t,
".*(database is closed|failed to connect|closed network connection)+",
"SET CLUSTER SETTING version = $1",
Expand Down
30 changes: 0 additions & 30 deletions pkg/ccl/migrationccl/migrationsccl/BUILD.bazel

This file was deleted.

4 changes: 2 additions & 2 deletions pkg/ccl/multitenantccl/tenantcostserver/system_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (h *sysTableHelper) readTenantAndInstanceState(
CurrentShareSum: float64(tree.MustBeDFloat(r[6])),
}
if consumption := r[7]; consumption != tree.DNull {
// total_consumption can be NULL because of a migration of the
// total_consumption can be NULL because of an upgrade of the
// tenant_usage table.
if err := protoutil.Unmarshal(
[]byte(tree.MustBeDBytes(consumption)), &tenant.Consumption,
Expand Down Expand Up @@ -512,7 +512,7 @@ func (h *sysTableHelper) checkInvariants() error {
return errors.Errorf("expected NULL column %d", j)
}
// We have an exception for total_consumption, which can be NULL because
// of a migration of the tenant_usage table.
// of an upgrade of the tenant_usage table.
if i != 7 {
return errors.Errorf("expected non-NULL column %d", j)
}
Expand Down
59 changes: 59 additions & 0 deletions pkg/ccl/upgradeccl/upgradessccl/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
load("@io_bazel_rules_go//go:def.bzl", "go_test")

go_test(
name = "upgradesccl_test",
srcs = [
"main_test.go",
"seed_span_counts_external_test.go",
"seed_tenant_span_configs_external_test.go",
],
deps = [
"//pkg/base",
"//pkg/ccl/kvccl/kvtenantccl",
"//pkg/clusterversion",
"//pkg/keys",
"//pkg/roachpb",
"//pkg/security",
"//pkg/security/securitytest",
"//pkg/security/username",
"//pkg/server",
"//pkg/settings/cluster",
"//pkg/spanconfig",
"//pkg/testutils",
"//pkg/testutils/serverutils",
"//pkg/testutils/sqlutils",
"//pkg/testutils/testcluster",
"//pkg/util/leaktest",
"//pkg/util/log",
"@com_github_stretchr_testify//require",
],
)

go_test(
name = "upgradessccl_test",
srcs = [
"main_test.go",
"seed_span_counts_external_test.go",
"seed_tenant_span_configs_external_test.go",
],
deps = [
"//pkg/base",
"//pkg/ccl/kvccl/kvtenantccl",
"//pkg/clusterversion",
"//pkg/keys",
"//pkg/roachpb",
"//pkg/security",
"//pkg/security/securitytest",
"//pkg/security/username",
"//pkg/server",
"//pkg/settings/cluster",
"//pkg/spanconfig",
"//pkg/testutils",
"//pkg/testutils/serverutils",
"//pkg/testutils/sqlutils",
"//pkg/testutils/testcluster",
"//pkg/util/leaktest",
"//pkg/util/log",
"@com_github_stretchr_testify//require",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt

package migrationsccl_test
package upgradessccl_test

import (
"os"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt

package migrationsccl_test
package upgradessccl_test

import (
"context"
Expand Down Expand Up @@ -105,7 +105,7 @@ func TestPreSeedSpanCountTable(t *testing.T) {
require.Equal(t, 5, spanCount)
}

// TestSeedSpanCountTable tests that the migration seeds system.span_count
// TestSeedSpanCountTable tests that the upgrade seeds system.span_count
// correctly for secondary tenants.
func TestSeedSpanCountTable(t *testing.T) {
defer leaktest.AfterTest(t)()
Expand Down Expand Up @@ -171,7 +171,7 @@ func TestSeedSpanCountTable(t *testing.T) {
require.Equal(t, 3, spanCount)
}

// TestSeedSpanCountTableOverLimit tests that the migration seeds
// TestSeedSpanCountTableOverLimit tests that the upgrade seeds
// system.span_count correctly for secondary tenants, even if over the
// proscribed limit. In these cases the tenant goes into debt -- all subsequent
// schema changes that add schema elements will be rejected. Attempts to free up
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt

package migrationsccl_test
package upgradessccl_test

import (
"context"
Expand Down Expand Up @@ -79,7 +79,7 @@ func TestPreSeedSpanConfigsWrittenWhenActive(t *testing.T) {
}
}

// TestSeedTenantSpanConfigs tests that the migration installs relevant seed
// TestSeedTenantSpanConfigs tests that the upgrade installs relevant seed
// span configs for existing secondary tenants.
func TestSeedTenantSpanConfigs(t *testing.T) {
defer leaktest.AfterTest(t)()
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestSeedTenantSpanConfigs(t *testing.T) {
}
}

// TestSeedTenantSpanConfigsWithExistingEntry tests that the migration ignores
// TestSeedTenantSpanConfigsWithExistingEntry tests that the upgrade ignores
// tenants with existing span config records.
func TestSeedTenantSpanConfigsWithExistingEntry(t *testing.T) {
defer leaktest.AfterTest(t)()
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/clisqlclient/statement_diag.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func StmtDiagListOutstandingRequests(

// TODO(yuzefovich): remove this in 22.2.
func isAtLeast22dot1ClusterVersion(ctx context.Context, conn Conn) (bool, error) {
// Check whether the migration to add the conditional diagnostics columns to
// Check whether the upgrade to add the conditional diagnostics columns to
// the statement_diagnostics_requests system table has already been run.
row, err := conn.QueryRow(ctx, `
SELECT
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/mt_start_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func runStartSQL(cmd *cobra.Command, args []string) error {
// In the initial 20.2 release of multi-tenant clusters, no version state was
// ever populated in the version cluster setting. A value is populated during
// the activation of 21.1. See the documentation attached to the TenantCluster
// in migration/migrationcluster for more details on the tenant upgrade flow.
// in upgrade/upgradecluster for more details on the tenant upgrade flow.
// Note that a the value of 21.1 is populated when a tenant cluster is created
// during 21.1 in crdb_internal.create_tenant.
//
Expand Down
4 changes: 2 additions & 2 deletions pkg/clusterversion/clusterversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// Package clusterversion defines the interfaces to interact with cluster/binary
// versions in order accommodate backward incompatible behaviors. It handles the
// feature gates and so must maintain a fairly lightweight set of dependencies.
// The migration sub-package handles advancing a cluster from one version to
// The upgrade sub-package handles advancing a cluster from one version to
// a later one.
//
// Ideally, every code change in a database would be backward compatible, but
Expand Down Expand Up @@ -269,7 +269,7 @@ func (cv ClusterVersion) SafeFormat(p redact.SafePrinter, _ rune) {
// not it is a fence version.
func (cv ClusterVersion) PrettyPrint() string {
// If we're a version greater than v20.2 and have an odd internal version,
// we're a fence version. See fenceVersionFor in pkg/migration to understand
// we're a fence version. See fenceVersionFor in pkg/upgrade to understand
// what these are.
fenceVersion := !cv.Version.LessEq(roachpb.Version{Major: 20, Minor: 2}) && (cv.Internal%2) == 1
if !fenceVersion {
Expand Down
2 changes: 1 addition & 1 deletion pkg/clusterversion/keyed_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (kv keyedVersions) Validate() error {
// a bit more lenient and allow one more release cycle until validation fails.
// In the above example, we would tolerate 20.1-x but not 19.2-x.
// Currently we're actually a few versions behind in enforcing a ban on old
// versions/migrations. See #47447.
// versions/upgrades. See #47447.
if n := len(byRelease) - 5; n >= 0 {
var buf strings.Builder
for i, mami := range byRelease[:n+1] {
Expand Down
2 changes: 1 addition & 1 deletion pkg/clusterversion/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const KeyVersionSetting = "version"

// version represents the cluster's "active version". This is a cluster setting,
// but a special one. It can only advance to higher and higher versions. The
// setting can be used to see if migrations are to be considered enabled or
// setting can be used to see if upgrades are to be considered enabled or
// disabled through the `isActive()` method. All external usage of the cluster
// settings takes place through a Handle and `Initialize()`.
//
Expand Down
Loading

0 comments on commit 32622e1

Please sign in to comment.