Skip to content

Commit

Permalink
cli: avoid generating ballast files for standalone SQL servers
Browse files Browse the repository at this point in the history
In a previous PR, we merged the startup code path between `cockroach
start` and `cockroach mt start-sql`. Doing so also (mostly) merged the
default store config. This was incorrect, as standalone SQL servers
should not receive an emergency ballast.

This patch fixes that.

Release note: None
  • Loading branch information
knz committed Nov 30, 2022
1 parent 265a5c4 commit 61161e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1201,5 +1201,17 @@ func mtStartSQLFlagsInit(cmd *cobra.Command) error {
tenantID := fs.Lookup(cliflags.TenantID.Name).Value.String()
serverCfg.Stores.Specs[0].Path += "-tenant-" + tenantID
}

// In standalone SQL servers, we do not generate a ballast file,
// unless a ballast size was specified explicitly by the user.
for i := range serverCfg.Stores.Specs {
spec := &serverCfg.Stores.Specs[i]
if spec.BallastSize == nil {
// Only override if there was no ballast size specified to start
// with.
zero := base.SizeSpec{InBytes: 0, Percent: 0}
spec.BallastSize = &zero
}
}
return nil
}
4 changes: 4 additions & 0 deletions pkg/cli/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,10 @@ func TestSQLPodStorageDefaults(t *testing.T) {
require.NoError(t, f.Parse(td.args))
require.NoError(t, mtStartSQLCmd.PersistentPreRunE(mtStartSQLCmd, td.args))
assert.Equal(t, td.storePath, serverCfg.Stores.Specs[0].Path)
for _, s := range serverCfg.Stores.Specs {
assert.Zero(t, s.BallastSize.InBytes)
assert.Zero(t, s.BallastSize.Percent)
}
})
}
}

0 comments on commit 61161e1

Please sign in to comment.