From 768dea31198d84d2dba0c470913a3eeeee1a0500 Mon Sep 17 00:00:00 2001 From: ShuNing Date: Fri, 5 Jan 2024 09:51:32 +0800 Subject: [PATCH 1/2] playground: init some pd configuration (#2351) Signed-off-by: nolouch --- components/playground/instance/pd.go | 14 +++++++++++--- components/playground/instance/pd_config.go | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 components/playground/instance/pd_config.go diff --git a/components/playground/instance/pd.go b/components/playground/instance/pd.go index 5d9a549cac..38a7e4f950 100644 --- a/components/playground/instance/pd.go +++ b/components/playground/instance/pd.go @@ -89,6 +89,15 @@ func (inst *PDInstance) Name() string { // Start calls set inst.cmd and Start func (inst *PDInstance) Start(ctx context.Context, version utils.Version) error { + configPath := filepath.Join(inst.Dir, "pd.toml") + if err := prepareConfig( + configPath, + inst.ConfigPath, + inst.getConfig(), + ); err != nil { + return err + } + uid := inst.Name() var args []string switch inst.Role { @@ -98,6 +107,7 @@ func (inst *PDInstance) Start(ctx context.Context, version utils.Version) error } args = append(args, []string{ "--name=" + uid, + fmt.Sprintf("--config=%s", configPath), fmt.Sprintf("--data-dir=%s", filepath.Join(inst.Dir, "data")), fmt.Sprintf("--peer-urls=http://%s", utils.JoinHostPort(inst.Host, inst.Port)), fmt.Sprintf("--advertise-peer-urls=http://%s", utils.JoinHostPort(AdvertiseHost(inst.Host), inst.Port)), @@ -105,9 +115,7 @@ func (inst *PDInstance) Start(ctx context.Context, version utils.Version) error fmt.Sprintf("--advertise-client-urls=http://%s", utils.JoinHostPort(AdvertiseHost(inst.Host), inst.StatusPort)), fmt.Sprintf("--log-file=%s", inst.LogFile()), }...) - if inst.ConfigPath != "" { - args = append(args, fmt.Sprintf("--config=%s", inst.ConfigPath)) - } + switch { case len(inst.initEndpoints) > 0: endpoints := make([]string, 0) diff --git a/components/playground/instance/pd_config.go b/components/playground/instance/pd_config.go new file mode 100644 index 0000000000..3ef80b6f4d --- /dev/null +++ b/components/playground/instance/pd_config.go @@ -0,0 +1,20 @@ +// Copyright 2024 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// limitations under the License. + +package instance + +func (inst *PDInstance) getConfig() map[string]any { + config := make(map[string]any) + config["schedule.patrol-region-interval"] = "100ms" + return config +} From 1210bc2e86ed8ffcdc48f36201b3ae5cc4f1cbd1 Mon Sep 17 00:00:00 2001 From: Wenxuan Date: Fri, 5 Jan 2024 22:35:39 +0800 Subject: [PATCH 2/2] playground: Allow configuring pd.binpath for all PD microservices (#2347) Signed-off-by: Wish Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> --- components/playground/main.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/playground/main.go b/components/playground/main.go index 8215362fed..713f6c8e33 100644 --- a/components/playground/main.go +++ b/components/playground/main.go @@ -414,17 +414,17 @@ func populateDefaultOpt(flagSet *pflag.FlagSet) error { defaultInt(&options.PD.Num, "pd", 1) case "ms": defaultInt(&options.PDAPI.Num, "pd.api", 1) - defaultStr(&options.PDAPI.BinPath, "pd.api.binpath", options.PDAPI.BinPath) - defaultStr(&options.PDAPI.ConfigPath, "pd.api.config", options.PDAPI.ConfigPath) + defaultStr(&options.PDAPI.BinPath, "pd.api.binpath", options.PD.BinPath) + defaultStr(&options.PDAPI.ConfigPath, "pd.api.config", options.PD.ConfigPath) defaultInt(&options.PDTSO.Num, "pd.tso", 1) - defaultStr(&options.PDTSO.BinPath, "pd.tso.binpath", options.PDTSO.BinPath) - defaultStr(&options.PDTSO.ConfigPath, "pd.tso.config", options.PDTSO.ConfigPath) + defaultStr(&options.PDTSO.BinPath, "pd.tso.binpath", options.PD.BinPath) + defaultStr(&options.PDTSO.ConfigPath, "pd.tso.config", options.PD.ConfigPath) defaultInt(&options.PDScheduling.Num, "pd.scheduling", 1) - defaultStr(&options.PDScheduling.BinPath, "pd.scheduling.binpath", options.PDScheduling.BinPath) - defaultStr(&options.PDScheduling.ConfigPath, "pd.scheduling.config", options.PDScheduling.ConfigPath) + defaultStr(&options.PDScheduling.BinPath, "pd.scheduling.binpath", options.PD.BinPath) + defaultStr(&options.PDScheduling.ConfigPath, "pd.scheduling.config", options.PD.ConfigPath) defaultInt(&options.PDRM.Num, "pd.rm", 1) - defaultStr(&options.PDRM.BinPath, "pd.rm.binpath", options.PDRM.BinPath) - defaultStr(&options.PDRM.ConfigPath, "pd.rm.config", options.PDRM.ConfigPath) + defaultStr(&options.PDRM.BinPath, "pd.rm.binpath", options.PD.BinPath) + defaultStr(&options.PDRM.ConfigPath, "pd.rm.config", options.PD.ConfigPath) default: return errors.Errorf("Unknown --pd.mode %s", options.PDMode) }