Skip to content

Commit

Permalink
clusterversion: reduce stuttering in package API
Browse files Browse the repository at this point in the history
This package was extracted out of pkg/settings/cluster in #45455. Now
that we're coupling it tightly with our migrations infrastructure
(pkg/migration), let's remove some unnecessary stuttering for ease of
use.

```diff
- if <settings handle>.Version.IsActive(ctx, clusterversion.VersionSomething) {
+ if <settings handle>.Version.IsActive(ctx, clusterversion.Something) {
```

All the diffs here are just mechanical goland-renames.

Release note: None
  • Loading branch information
irfansharif committed Dec 2, 2020
1 parent ae509ad commit 3230734
Show file tree
Hide file tree
Showing 45 changed files with 227 additions and 231 deletions.
2 changes: 1 addition & 1 deletion pkg/ccl/backupccl/restore_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ func (r *restoreResumer) Resume(
details := r.job.Details().(jobspb.RestoreDetails)
p := execCtx.(sql.JobExecContext)
r.versionAtLeast20_2 = p.ExecCfg().Settings.Version.IsActive(
ctx, clusterversion.VersionLeasedDatabaseDescriptors)
ctx, clusterversion.LeasedDatabaseDescriptors)

backupManifests, latestBackupManifest, sqlDescs, err := loadBackupSQLDescs(
ctx, p, details, details.Encryption,
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/backupccl/restore_planning.go
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,7 @@ func doRestorePlan(
//
// TODO(ajwerner): Remove this version check in 21.1.
canResetModTime := p.ExecCfg().Settings.Version.IsActive(
ctx, clusterversion.VersionLeasedDatabaseDescriptors)
ctx, clusterversion.LeasedDatabaseDescriptors)
if err := RewriteTableDescs(
tables, descriptorRewrites, intoDB, canResetModTime,
); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/importccl/import_stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ func prepareNewTableDescsForIngestion(
}
// TODO(ajwerner): Remove this in 21.1.
canResetModTime := p.ExecCfg().Settings.Version.IsActive(
ctx, clusterversion.VersionLeasedDatabaseDescriptors)
ctx, clusterversion.LeasedDatabaseDescriptors)
if err := backupccl.RewriteTableDescs(
newMutableTableDescriptors, tableRewrites, "", canResetModTime,
); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/clusterversion/.gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
versionkey_string.go binary
key_string.go binary
2 changes: 1 addition & 1 deletion pkg/clusterversion/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ go_library(
"cluster_version.pb.go",
"clusterversion.go",
"cockroach_versions.go",
"key_string.go",
"keyed_versions.go",
"setting.go",
"testutils.go",
"versionkey_string.go",
],
importpath = "github.com/cockroachdb/cockroach/pkg/clusterversion",
visibility = ["//visibility:public"],
Expand Down
8 changes: 4 additions & 4 deletions pkg/clusterversion/clusterversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type Handle interface {
// outbound requests. When receiving these "new" inbound requests, despite
// not seeing the latest active version, node2 is aware that the sending
// node has, and it will too, eventually.
IsActive(context.Context, VersionKey) bool
IsActive(context.Context, Key) bool

// BinaryVersion returns the build version of this binary.
BinaryVersion() roachpb.Version
Expand Down Expand Up @@ -206,7 +206,7 @@ func (v *handleImpl) SetActiveVersion(ctx context.Context, cv ClusterVersion) er
}

// IsActive implements the Handle interface.
func (v *handleImpl) IsActive(ctx context.Context, key VersionKey) bool {
func (v *handleImpl) IsActive(ctx context.Context, key Key) bool {
return version.isActive(ctx, v.sv, key)
}

Expand All @@ -228,8 +228,8 @@ func (cv ClusterVersion) IsActiveVersion(v roachpb.Version) bool {

// IsActive returns true if the features of the supplied version are active at
// the running version.
func (cv ClusterVersion) IsActive(versionKey VersionKey) bool {
v := VersionByKey(versionKey)
func (cv ClusterVersion) IsActive(versionKey Key) bool {
v := ByKey(versionKey)
return cv.IsActiveVersion(v)
}

Expand Down
Loading

0 comments on commit 3230734

Please sign in to comment.