Skip to content

Commit

Permalink
Revert "pdms(playground, cluster): add name to start pdms (#2438)" (#…
Browse files Browse the repository at this point in the history
…2446)

This reverts commit 9c5ad9a.
  • Loading branch information
kaaaaaaang authored Jul 30, 2024
1 parent 9c5ad9a commit 61c9724
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 239 deletions.
16 changes: 1 addition & 15 deletions components/playground/instance/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"strings"

"github.com/pingcap/errors"
"github.com/pingcap/tiup/pkg/tidbver"
"github.com/pingcap/tiup/pkg/utils"
)

Expand Down Expand Up @@ -84,14 +83,7 @@ func (inst *PDInstance) InitCluster(pds []*PDInstance) *PDInstance {

// Name return the name of pd.
func (inst *PDInstance) Name() string {
switch inst.Role {
case PDRoleTSO:
return fmt.Sprintf("tso-%d", inst.ID)
case PDRoleScheduling:
return fmt.Sprintf("scheduling-%d", inst.ID)
default:
return fmt.Sprintf("pd-%d", inst.ID)
}
return fmt.Sprintf("pd-%d", inst.ID)
}

// Start calls set inst.cmd and Start
Expand Down Expand Up @@ -150,9 +142,6 @@ func (inst *PDInstance) Start(ctx context.Context) error {
fmt.Sprintf("--log-file=%s", inst.LogFile()),
fmt.Sprintf("--config=%s", configPath),
}
if tidbver.PDSupportMicroServicesWithName(inst.Version.String()) {
args = append(args, fmt.Sprintf("--name=%s", uid))
}
case PDRoleScheduling:
endpoints := pdEndpoints(inst.pds, true)
args = []string{
Expand All @@ -164,9 +153,6 @@ func (inst *PDInstance) Start(ctx context.Context) error {
fmt.Sprintf("--log-file=%s", inst.LogFile()),
fmt.Sprintf("--config=%s", configPath),
}
if tidbver.PDSupportMicroServicesWithName(inst.Version.String()) {
args = append(args, fmt.Sprintf("--name=%s", uid))
}
}

inst.Process = &process{cmd: PrepareCommand(ctx, inst.BinPath, args, nil, inst.Dir)}
Expand Down
3 changes: 0 additions & 3 deletions embed/templates/scripts/run_scheduling.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ cd "${DEPLOY_DIR}" || exit 1
exec numactl --cpunodebind={{.NumaNode}} --membind={{.NumaNode}} env GODEBUG=madvdontneed=1 bin/pd-server services scheduling\
{{- else}}
exec env GODEBUG=madvdontneed=1 bin/pd-server services scheduling \
{{- end}}
{{- if .Name}}
--name="{{.Name}}" \
{{- end}}
--backend-endpoints="{{.BackendEndpoints}}" \
--listen-addr="{{.ListenURL}}" \
Expand Down
3 changes: 0 additions & 3 deletions embed/templates/scripts/run_tso.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ cd "${DEPLOY_DIR}" || exit 1
exec numactl --cpunodebind={{.NumaNode}} --membind={{.NumaNode}} env GODEBUG=madvdontneed=1 bin/pd-server services tso\
{{- else}}
exec env GODEBUG=madvdontneed=1 bin/pd-server services tso \
{{- end}}
{{- if .Name}}
--name="{{.Name}}" \
{{- end}}
--backend-endpoints="{{.BackendEndpoints}}" \
--listen-addr="{{.ListenURL}}" \
Expand Down
15 changes: 0 additions & 15 deletions pkg/cluster/manager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,6 @@ pd_servers:
assert.Nil(err)
err = validateNewTopo(&topo)
assert.NotNil(err)

topo = spec.Specification{}
err = yaml.Unmarshal([]byte(`
global:
user: "test4"
deploy_dir: "test-deploy"
data_dir: "test-data"
tso_servers:
- host: 172.16.5.53
scheduling_servers:
- host: 172.16.5.54
`), &topo)
assert.Nil(err)
err = validateNewTopo(&topo)
assert.Nil(err)
}

func TestDeduplicateCheckResult(t *testing.T) {
Expand Down
28 changes: 0 additions & 28 deletions pkg/cluster/manager/transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,4 @@ func TestRenderSpec(t *testing.T) {
dir, err = renderSpec("{{.DataDir}}", s, "test-pd")
assert.Nil(t, err)
assert.NotEmpty(t, dir)

s = &spec.TSOInstance{BaseInstance: spec.BaseInstance{
InstanceSpec: &spec.TSOSpec{
Host: "172.16.5.140",
SSHPort: 22,
Name: "tso-1",
DeployDir: "/home/test/deploy/tso-3379",
DataDir: "/home/test/deploy/tso-3379/data",
},
}}
// s.BaseInstance.InstanceSpec
dir, err = renderSpec("{{.DataDir}}", s, "test-tso")
assert.Nil(t, err)
assert.NotEmpty(t, dir)

s = &spec.SchedulingInstance{BaseInstance: spec.BaseInstance{
InstanceSpec: &spec.SchedulingSpec{
Host: "172.16.5.140",
SSHPort: 22,
Name: "scheduling-1",
DeployDir: "/home/test/deploy/scheduling-3379",
DataDir: "/home/test/deploy/scheduling-3379/data",
},
}}
// s.BaseInstance.InstanceSpec
dir, err = renderSpec("{{.DataDir}}", s, "test-scheduling")
assert.Nil(t, err)
assert.NotEmpty(t, dir)
}
38 changes: 16 additions & 22 deletions pkg/cluster/spec/scheduling.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,26 @@ import (
"github.com/pingcap/tiup/pkg/cluster/ctxt"
"github.com/pingcap/tiup/pkg/cluster/template/scripts"
"github.com/pingcap/tiup/pkg/meta"
"github.com/pingcap/tiup/pkg/tidbver"
"github.com/pingcap/tiup/pkg/utils"
)

// SchedulingSpec represents the scheduling topology specification in topology.yaml
type SchedulingSpec struct {
Host string `yaml:"host"`
ManageHost string `yaml:"manage_host,omitempty" validate:"manage_host:editable"`
ListenHost string `yaml:"listen_host,omitempty"`
AdvertiseListenAddr string `yaml:"advertise_listen_addr,omitempty"`
SSHPort int `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
IgnoreExporter bool `yaml:"ignore_exporter,omitempty"`
// Use Name to get the name with a default value if it's empty.
Name string `yaml:"name,omitempty"`
Port int `yaml:"port" default:"3379"`
DeployDir string `yaml:"deploy_dir,omitempty"`
DataDir string `yaml:"data_dir,omitempty"`
LogDir string `yaml:"log_dir,omitempty"`
Source string `yaml:"source,omitempty" validate:"source:editable"`
NumaNode string `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
Config map[string]any `yaml:"config,omitempty" validate:"config:ignore"`
Arch string `yaml:"arch,omitempty"`
OS string `yaml:"os,omitempty"`
Host string `yaml:"host"`
ManageHost string `yaml:"manage_host,omitempty" validate:"manage_host:editable"`
ListenHost string `yaml:"listen_host,omitempty"`
AdvertiseListenAddr string `yaml:"advertise_listen_addr,omitempty"`
SSHPort int `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
IgnoreExporter bool `yaml:"ignore_exporter,omitempty"`
Port int `yaml:"port" default:"3379"`
DeployDir string `yaml:"deploy_dir,omitempty"`
DataDir string `yaml:"data_dir,omitempty"`
LogDir string `yaml:"log_dir,omitempty"`
Source string `yaml:"source,omitempty" validate:"source:editable"`
NumaNode string `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
Config map[string]any `yaml:"config,omitempty" validate:"config:ignore"`
Arch string `yaml:"arch,omitempty"`
OS string `yaml:"os,omitempty"`
}

// Status queries current status of the instance
Expand Down Expand Up @@ -203,6 +200,7 @@ func (c *SchedulingComponent) Instances() []Instance {

// SchedulingInstance represent the scheduling instance
type SchedulingInstance struct {
Name string
BaseInstance
topo Topology
}
Expand Down Expand Up @@ -231,7 +229,6 @@ func (i *SchedulingInstance) InitConfig(
pds = append(pds, pdspec.GetAdvertiseClientURL(enableTLS))
}
cfg := &scripts.SchedulingScript{
Name: spec.Name,
ListenURL: fmt.Sprintf("%s://%s", scheme, utils.JoinHostPort(i.GetListenHost(), spec.Port)),
AdvertiseListenURL: spec.GetAdvertiseListenURL(enableTLS),
BackendEndpoints: strings.Join(pds, ","),
Expand All @@ -240,9 +237,6 @@ func (i *SchedulingInstance) InitConfig(
LogDir: paths.Log,
NumaNode: spec.NumaNode,
}
if !tidbver.PDSupportMicroServicesWithName(version) {
cfg.Name = ""
}

fp := filepath.Join(paths.Cache, fmt.Sprintf("run_scheduling_%s_%d.sh", i.GetHost(), i.GetPort()))
if err := cfg.ConfigToFile(fp); err != nil {
Expand Down
10 changes: 0 additions & 10 deletions pkg/cluster/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,20 +679,10 @@ func setCustomDefaults(globalOptions *GlobalOptions, field reflect.Value) error
}
field.Field(j).Set(reflect.ValueOf(globalOptions.SSHPort))
case "Name":
// Only PD related components have `Name` field,
if field.Field(j).String() != "" {
continue
}
host := reflect.Indirect(field).FieldByName("Host").String()
// `TSO` and `Scheduling` components use `Port` filed
if reflect.Indirect(field).FieldByName("Port").IsValid() {
port := reflect.Indirect(field).FieldByName("Port").Int()
// field.String() is <spec.TSOSpec Value>
role := strings.Split(strings.Split(field.Type().String(), ".")[1], "Spec")[0]
component := strings.ToLower(role)
field.Field(j).Set(reflect.ValueOf(fmt.Sprintf("%s-%s-%d", component, host, port)))
continue
}
clientPort := reflect.Indirect(field).FieldByName("ClientPort").Int()
field.Field(j).Set(reflect.ValueOf(fmt.Sprintf("pd-%s-%d", host, clientPort)))
case "DataDir":
Expand Down
38 changes: 16 additions & 22 deletions pkg/cluster/spec/tso.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,26 @@ import (
"github.com/pingcap/tiup/pkg/cluster/ctxt"
"github.com/pingcap/tiup/pkg/cluster/template/scripts"
"github.com/pingcap/tiup/pkg/meta"
"github.com/pingcap/tiup/pkg/tidbver"
"github.com/pingcap/tiup/pkg/utils"
)

// TSOSpec represents the TSO topology specification in topology.yaml
type TSOSpec struct {
Host string `yaml:"host"`
ManageHost string `yaml:"manage_host,omitempty" validate:"manage_host:editable"`
ListenHost string `yaml:"listen_host,omitempty"`
AdvertiseListenAddr string `yaml:"advertise_listen_addr,omitempty"`
SSHPort int `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
IgnoreExporter bool `yaml:"ignore_exporter,omitempty"`
// Use Name to get the name with a default value if it's empty.
Name string `yaml:"name,omitempty"`
Port int `yaml:"port" default:"3379"`
DeployDir string `yaml:"deploy_dir,omitempty"`
DataDir string `yaml:"data_dir,omitempty"`
LogDir string `yaml:"log_dir,omitempty"`
Source string `yaml:"source,omitempty" validate:"source:editable"`
NumaNode string `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
Config map[string]any `yaml:"config,omitempty" validate:"config:ignore"`
Arch string `yaml:"arch,omitempty"`
OS string `yaml:"os,omitempty"`
Host string `yaml:"host"`
ManageHost string `yaml:"manage_host,omitempty" validate:"manage_host:editable"`
ListenHost string `yaml:"listen_host,omitempty"`
AdvertiseListenAddr string `yaml:"advertise_listen_addr,omitempty"`
SSHPort int `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
IgnoreExporter bool `yaml:"ignore_exporter,omitempty"`
Port int `yaml:"port" default:"3379"`
DeployDir string `yaml:"deploy_dir,omitempty"`
DataDir string `yaml:"data_dir,omitempty"`
LogDir string `yaml:"log_dir,omitempty"`
Source string `yaml:"source,omitempty" validate:"source:editable"`
NumaNode string `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
Config map[string]any `yaml:"config,omitempty" validate:"config:ignore"`
Arch string `yaml:"arch,omitempty"`
OS string `yaml:"os,omitempty"`
}

// Status queries current status of the instance
Expand Down Expand Up @@ -203,6 +200,7 @@ func (c *TSOComponent) Instances() []Instance {

// TSOInstance represent the TSO instance
type TSOInstance struct {
Name string
BaseInstance
topo Topology
}
Expand Down Expand Up @@ -231,7 +229,6 @@ func (i *TSOInstance) InitConfig(
pds = append(pds, pdspec.GetAdvertiseClientURL(enableTLS))
}
cfg := &scripts.TSOScript{
Name: spec.Name,
ListenURL: fmt.Sprintf("%s://%s", scheme, utils.JoinHostPort(i.GetListenHost(), spec.Port)),
AdvertiseListenURL: spec.GetAdvertiseListenURL(enableTLS),
BackendEndpoints: strings.Join(pds, ","),
Expand All @@ -240,9 +237,6 @@ func (i *TSOInstance) InitConfig(
LogDir: paths.Log,
NumaNode: spec.NumaNode,
}
if !tidbver.PDSupportMicroServicesWithName(version) {
cfg.Name = ""
}

fp := filepath.Join(paths.Cache, fmt.Sprintf("run_tso_%s_%d.sh", i.GetHost(), i.GetPort()))
if err := cfg.ConfigToFile(fp); err != nil {
Expand Down
34 changes: 0 additions & 34 deletions pkg/cluster/spec/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -984,38 +984,6 @@ func (s *Specification) validatePDNames() error {
return nil
}

func (s *Specification) validateTSONames() error {
// check tso server name
tsoNames := set.NewStringSet()
for _, tso := range s.TSOServers {
if tso.Name == "" {
continue
}

if tsoNames.Exist(tso.Name) {
return errors.Errorf("component tso_servers.name is not supported duplicated, the name %s is duplicated", tso.Name)
}
tsoNames.Insert(tso.Name)
}
return nil
}

func (s *Specification) validateSchedulingNames() error {
// check scheduling server name
schedulingNames := set.NewStringSet()
for _, scheduling := range s.SchedulingServers {
if scheduling.Name == "" {
continue
}

if schedulingNames.Exist(scheduling.Name) {
return errors.Errorf("component scheduling_servers.name is not supported duplicated, the name %s is duplicated", scheduling.Name)
}
schedulingNames.Insert(scheduling.Name)
}
return nil
}

func (s *Specification) validateTiFlashConfigs() error {
c := FindComponent(s, ComponentTiFlash)
for _, ins := range c.Instances() {
Expand Down Expand Up @@ -1095,8 +1063,6 @@ func (s *Specification) Validate() error {
s.dirConflictsDetect,
s.validateUserGroup,
s.validatePDNames,
s.validateTSONames,
s.validateSchedulingNames,
s.validateTiSparkSpec,
s.validateTiFlashConfigs,
s.validateMonitorAgent,
Expand Down
Loading

0 comments on commit 61c9724

Please sign in to comment.