Skip to content

Commit

Permalink
server: rename BootstrapVersionOverride to something more appropriate
Browse files Browse the repository at this point in the history
Release justification: non-production code changes
Release note: None
  • Loading branch information
irfansharif committed Aug 28, 2020
1 parent 575ebf6 commit e755415
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pkg/server/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ func (s *initServer) DiskClusterVersion() clusterversion.ClusterVersion {
type initServerCfg struct {
advertiseAddr string
binaryMinSupportedVersion roachpb.Version
binaryVersion roachpb.Version
binaryVersion roachpb.Version // This is what's used for bootstrap.
defaultSystemZoneConfig zonepb.ZoneConfig
defaultZoneConfig zonepb.ZoneConfig

Expand All @@ -543,7 +543,7 @@ type initServerCfg struct {
func newInitServerConfig(cfg Config, dialOpts []grpc.DialOption) initServerCfg {
binaryVersion := cfg.Settings.Version.BinaryVersion()
if knobs := cfg.TestingKnobs.Server; knobs != nil {
if ov := knobs.(*TestingKnobs).BootstrapVersionOverride; ov != (roachpb.Version{}) {
if ov := knobs.(*TestingKnobs).BinaryVersionOverride; ov != (roachpb.Version{}) {
binaryVersion = ov
}
}
Expand Down
23 changes: 14 additions & 9 deletions pkg/server/testing_knobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,27 @@ type TestingKnobs struct {
// server fails to start.
RPCListener net.Listener

// BootstrapVersionOverride, if not empty, will be used for bootstrapping
// clusters instead of clusterversion.BinaryVersion (if this server is the
// one bootstrapping the cluster).
// BinaryVersionOverride overrides the binary version the CRDB server thinks
// it's running.
//
// This can be used by tests to essentially pretend that a new cluster is
// not starting from scratch, but instead is "created" by a node starting up
// with engines that had already been bootstrapped, at this
// BootstrapVersionOverride. For example, it allows convenient creation of a
// cluster from a 2.1 binary, but that's running at version 2.0.
// This is consulted when bootstrapping clusters, opting to do it at the
// override instead of clusterversion.BinaryVersion (if this server is the
// one bootstrapping the cluster). This can als be used by tests to
// essentially that a new cluster is not starting from scratch, but instead
// is "created" by a node starting up with engines that had already been
// bootstrapped, at this BinaryVersionOverride. For example, it allows
// convenient creation of a cluster from a 2.1 binary, but that's running at
// version 2.0.
//
// It's also used when advertising this server's binary version when sending
// out join requests.
//
// NB: When setting this, you probably also want to set
// DisableAutomaticVersionUpgrade.
//
// TODO(irfansharif): Update users of this testing knob to use the
// appropriate clusterversion.Handle instead.
BootstrapVersionOverride roachpb.Version
BinaryVersionOverride roachpb.Version
}

// ModuleTestingKnobs is part of the base.ModuleTestingKnobs interface.
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/updates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ func TestUpgradeHappensAfterMigrations(t *testing.T) {
Settings: st,
Knobs: base.TestingKnobs{
Server: &TestingKnobs{
BootstrapVersionOverride: clusterversion.TestingBinaryMinSupportedVersion,
BinaryVersionOverride: clusterversion.TestingBinaryMinSupportedVersion,
},
SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{
AfterEnsureMigrations: func() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/version_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func TestClusterVersionUpgrade(t *testing.T) {

knobs := base.TestingKnobs{
Server: &server.TestingKnobs{
BootstrapVersionOverride: oldVersion,
BinaryVersionOverride: oldVersion,
DisableAutomaticVersionUpgrade: 1,
},
}
Expand Down Expand Up @@ -421,7 +421,7 @@ func TestClusterVersionMixedVersionTooOld(t *testing.T) {
knobs := base.TestingKnobs{
Server: &server.TestingKnobs{
DisableAutomaticVersionUpgrade: 1,
BootstrapVersionOverride: v0,
BinaryVersionOverride: v0,
},
}
tc := setupMixedCluster(t, knobs, versions, "")
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/catalog/lease/lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2224,7 +2224,7 @@ func TestFinalizeVersionEnablesRangefeedUpdates(t *testing.T) {
DisableAutomaticVersionUpgrade: 1,
// Bootstrap the cluster at something below VersionRangefeedLeases so
// that we can test the upgrade.
BootstrapVersionOverride: clusterversion.VersionByKey(clusterversion.Version20_1),
BinaryVersionOverride: clusterversion.VersionByKey(clusterversion.Version20_1),
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/logictest/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ func (t *logicTest) setup(cfg testClusterConfig, serverArgs TestServerArgs) {
if params.ServerArgs.Knobs.Server == nil {
params.ServerArgs.Knobs.Server = &server.TestingKnobs{}
}
params.ServerArgs.Knobs.Server.(*server.TestingKnobs).BootstrapVersionOverride = cfg.bootstrapVersion
params.ServerArgs.Knobs.Server.(*server.TestingKnobs).BinaryVersionOverride = cfg.bootstrapVersion
}
if cfg.disableUpgrade {
if params.ServerArgs.Knobs.Server == nil {
Expand Down

0 comments on commit e755415

Please sign in to comment.