Skip to content

Commit

Permalink
server: add assertion around binary versions
Browse files Browse the repository at this point in the history
Makes for a more helpful error message in cockroachdb#69828; there we're dealing
with tests that override the binary version that now fail seeing as how
the min supported version is advanced.

Release note: None
  • Loading branch information
irfansharif committed Oct 19, 2021
1 parent bfe8164 commit 475a110
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
9 changes: 8 additions & 1 deletion pkg/server/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,14 +616,21 @@ type initServerCfg struct {
testingKnobs base.TestingKnobs
}

func newInitServerConfig(cfg Config, dialOpts []grpc.DialOption) initServerCfg {
func newInitServerConfig(
ctx context.Context, cfg Config, dialOpts []grpc.DialOption,
) initServerCfg {
binaryVersion := cfg.Settings.Version.BinaryVersion()
if knobs := cfg.TestingKnobs.Server; knobs != nil {
if ov := knobs.(*TestingKnobs).BinaryVersionOverride; ov != (roachpb.Version{}) {
binaryVersion = ov
}
}
binaryMinSupportedVersion := cfg.Settings.Version.BinaryMinSupportedVersion()
if binaryVersion.Less(binaryMinSupportedVersion) {
log.Fatalf(ctx, "binary version (%s) less than min supported version (%s)",
binaryVersion, binaryMinSupportedVersion)
}

bootstrapAddresses := cfg.FilterGossipBootstrapAddresses(context.Background())
return initServerCfg{
advertiseAddr: cfg.AdvertiseAddr,
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ func (s *Server) PreStart(ctx context.Context) error {
return err
}

initConfig := newInitServerConfig(s.cfg, dialOpts)
initConfig := newInitServerConfig(ctx, s.cfg, dialOpts)
inspectedDiskState, err := inspectEngines(
ctx,
s.engines,
Expand Down
3 changes: 2 additions & 1 deletion pkg/server/settings_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func TestCachedSettingsServerRestart(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

ctx := context.Background()
stickyEngineRegistry := NewStickyInMemEnginesRegistry()
defer stickyEngineRegistry.CloseAllStickyInMemEngines()

Expand Down Expand Up @@ -105,7 +106,7 @@ func TestCachedSettingsServerRestart(t *testing.T) {
dialOpts, err := s.rpcContext.GRPCDialOptions()
require.NoError(t, err)

initConfig := newInitServerConfig(s.cfg, dialOpts)
initConfig := newInitServerConfig(ctx, s.cfg, dialOpts)
inspectState, err := inspectEngines(
context.Background(),
s.engines,
Expand Down

0 comments on commit 475a110

Please sign in to comment.