Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

playground: support scaling ms instances when using playground #2417

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions components/playground/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func buildCommands(tp CommandType, opt *BootOptions) (cmds []Command) {
instance.Config
}{
{"pd", opt.PD},
{"tso", opt.TSO},
{"scheduling", opt.Scheduling},
{"tikv", opt.TiKV},
{"pump", opt.Pump},
{"tiflash", opt.TiFlash},
Expand Down Expand Up @@ -98,6 +100,8 @@ func newScaleOut() *cobra.Command {
cmd.Flags().IntVarP(&opt.TiDB.Num, "db", "", opt.TiDB.Num, "TiDB instance number")
cmd.Flags().IntVarP(&opt.TiKV.Num, "kv", "", opt.TiKV.Num, "TiKV instance number")
cmd.Flags().IntVarP(&opt.PD.Num, "pd", "", opt.PD.Num, "PD instance number")
cmd.Flags().IntVarP(&opt.TSO.Num, "tso", "", opt.TSO.Num, "TSO instance number")
cmd.Flags().IntVarP(&opt.Scheduling.Num, "scheduling", "", opt.Scheduling.Num, "Scheduling instance number")
cmd.Flags().IntVarP(&opt.TiFlash.Num, "tiflash", "", opt.TiFlash.Num, "TiFlash instance number")
cmd.Flags().IntVarP(&opt.TiProxy.Num, "tiproxy", "", opt.TiProxy.Num, "TiProxy instance number")
cmd.Flags().IntVarP(&opt.TiCDC.Num, "ticdc", "", opt.TiCDC.Num, "TiCDC instance number")
Expand All @@ -106,11 +110,15 @@ func newScaleOut() *cobra.Command {
cmd.Flags().IntVarP(&opt.Drainer.Num, "drainer", "", opt.Pump.Num, "Drainer instance number")
cmd.Flags().StringVarP(&opt.TiDB.Host, "db.host", "", opt.TiDB.Host, "Playground TiDB host. If not provided, TiDB will still use `host` flag as its host")
cmd.Flags().StringVarP(&opt.PD.Host, "pd.host", "", opt.PD.Host, "Playground PD host. If not provided, PD will still use `host` flag as its host")
cmd.Flags().StringVarP(&opt.TSO.Host, "tso.host", "", opt.TSO.Host, "Playground TSO host. If not provided, TSO will still use `host` flag as its host")
cmd.Flags().StringVarP(&opt.Scheduling.Host, "scheduling.host", "", opt.Scheduling.Host, "Playground Scheduling host. If not provided, Scheduling will still use `host` flag as its host")
cmd.Flags().StringVarP(&opt.TiProxy.Host, "tiproxy.host", "", opt.PD.Host, "Playground TiProxy host. If not provided, TiProxy will still use `host` flag as its host")

cmd.Flags().StringVarP(&opt.TiDB.ConfigPath, "db.config", "", opt.TiDB.ConfigPath, "TiDB instance configuration file")
cmd.Flags().StringVarP(&opt.TiKV.ConfigPath, "kv.config", "", opt.TiKV.ConfigPath, "TiKV instance configuration file")
cmd.Flags().StringVarP(&opt.PD.ConfigPath, "pd.config", "", opt.PD.ConfigPath, "PD instance configuration file")
cmd.Flags().StringVarP(&opt.TSO.ConfigPath, "tso.config", "", opt.TSO.ConfigPath, "TSO instance configuration file")
cmd.Flags().StringVarP(&opt.Scheduling.ConfigPath, "scheduling.config", "", opt.Scheduling.ConfigPath, "Scheduling instance configuration file")
cmd.Flags().StringVarP(&opt.TiFlash.ConfigPath, "tiflash.config", "", opt.TiFlash.ConfigPath, "TiFlash instance configuration file")
cmd.Flags().StringVarP(&opt.TiProxy.ConfigPath, "tiproxy.config", "", opt.TiProxy.ConfigPath, "TiProxy instance configuration file")
cmd.Flags().StringVarP(&opt.Pump.ConfigPath, "pump.config", "", opt.Pump.ConfigPath, "Pump instance configuration file")
Expand All @@ -119,6 +127,8 @@ func newScaleOut() *cobra.Command {
cmd.Flags().StringVarP(&opt.TiDB.BinPath, "db.binpath", "", opt.TiDB.BinPath, "TiDB instance binary path")
cmd.Flags().StringVarP(&opt.TiKV.BinPath, "kv.binpath", "", opt.TiKV.BinPath, "TiKV instance binary path")
cmd.Flags().StringVarP(&opt.PD.BinPath, "pd.binpath", "", opt.PD.BinPath, "PD instance binary path")
cmd.Flags().StringVarP(&opt.TSO.BinPath, "tso.binpath", "", opt.TSO.BinPath, "TSO instance binary path")
cmd.Flags().StringVarP(&opt.Scheduling.BinPath, "scheduling.binpath", "", opt.Scheduling.BinPath, "Scheduling instance binary path")
cmd.Flags().StringVarP(&opt.TiFlash.BinPath, "tiflash.binpath", "", opt.TiFlash.BinPath, "TiFlash instance binary path")
cmd.Flags().StringVarP(&opt.TiProxy.BinPath, "tiproxy.binpath", "", opt.TiProxy.BinPath, "TiProxy instance binary path")
cmd.Flags().StringVarP(&opt.TiCDC.BinPath, "ticdc.binpath", "", opt.TiCDC.BinPath, "TiCDC instance binary path")
Expand Down
25 changes: 24 additions & 1 deletion components/playground/playground.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ func (p *Playground) handleScaleIn(w io.Writer, pid int) error {

switch cid {
case spec.ComponentPD:
// microservice not support scale in temporarily
for i := 0; i < len(p.pds); i++ {
if p.pds[i].Pid() == pid {
inst := p.pds[i]
Expand All @@ -279,6 +278,18 @@ func (p *Playground) handleScaleIn(w io.Writer, pid int) error {
p.pds = append(p.pds[:i], p.pds[i+1:]...)
}
}
case spec.ComponentTSO:
for i := 0; i < len(p.tsos); i++ {
if p.tsos[i].Pid() == pid {
p.tsos = append(p.tsos[:i], p.tsos[i+1:]...)
}
}
case spec.ComponentScheduling:
for i := 0; i < len(p.schedulings); i++ {
if p.schedulings[i].Pid() == pid {
p.schedulings = append(p.schedulings[:i], p.schedulings[i+1:]...)
}
}
case spec.ComponentTiKV:
for i := 0; i < len(p.tikvs); i++ {
if p.tikvs[i].Pid() == pid {
Expand Down Expand Up @@ -409,6 +420,10 @@ func (p *Playground) sanitizeComponentConfig(cid string, cfg *instance.Config) e
switch cid {
case spec.ComponentPD:
return p.sanitizeConfig(p.bootOptions.PD, cfg)
case spec.ComponentTSO:
return p.sanitizeConfig(p.bootOptions.TSO, cfg)
case spec.ComponentScheduling:
return p.sanitizeConfig(p.bootOptions.Scheduling, cfg)
case spec.ComponentTiKV:
return p.sanitizeConfig(p.bootOptions.TiKV, cfg)
case spec.ComponentTiDB:
Expand Down Expand Up @@ -720,6 +735,14 @@ func (p *Playground) addInstance(componentID string, pdRole instance.PDRole, tif
} else if pdRole == instance.PDRoleScheduling {
p.schedulings = append(p.schedulings, inst)
}
case spec.ComponentTSO:
inst := instance.NewPDInstance(instance.PDRoleTSO, cfg.BinPath, dir, host, cfg.ConfigPath, id, p.pds, cfg.Port, p.bootOptions.Mode == "tidb-cse")
ins = inst
p.tsos = append(p.tsos, inst)
case spec.ComponentScheduling:
inst := instance.NewPDInstance(instance.PDRoleScheduling, cfg.BinPath, dir, host, cfg.ConfigPath, id, p.pds, cfg.Port, p.bootOptions.Mode == "tidb-cse")
ins = inst
p.schedulings = append(p.schedulings, inst)
case spec.ComponentTiDB:
inst := instance.NewTiDBInstance(cfg.BinPath, dir, host, cfg.ConfigPath, id, cfg.Port, p.pds, dataDir, p.enableBinlog(), p.bootOptions.Mode == "tidb-cse")
ins = inst
Expand Down
Loading