Skip to content

Commit

Permalink
Merge remote-tracking branch 'pingcap/master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleFall committed Nov 16, 2020
2 parents 273b711 + cc41ad5 commit 30bb957
Show file tree
Hide file tree
Showing 50 changed files with 539 additions and 1,209 deletions.
24 changes: 1 addition & 23 deletions components/cluster/command/scale_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
package command

import (
"context"
"io/ioutil"
"path/filepath"

"github.com/pingcap/tiup/pkg/cluster"
"github.com/pingcap/tiup/pkg/cluster/executor"
operator "github.com/pingcap/tiup/pkg/cluster/operation"
"github.com/pingcap/tiup/pkg/cluster/report"
"github.com/pingcap/tiup/pkg/cluster/spec"
"github.com/pingcap/tiup/pkg/cluster/task"
"github.com/pingcap/tiup/pkg/utils"
Expand Down Expand Up @@ -78,15 +75,6 @@ func newScaleOutCmd() *cobra.Command {
return cmd
}

// Deprecated
func convertStepDisplaysToTasks(t []*task.StepDisplay) []task.Task {
tasks := make([]task.Task, 0, len(t))
for _, sd := range t {
tasks = append(tasks, sd)
}
return tasks
}

func final(builder *task.Builder, name string, meta spec.Metadata) {
builder.UpdateTopology(name,
tidbSpec.Path(name),
Expand All @@ -96,15 +84,5 @@ func final(builder *task.Builder, name string, meta spec.Metadata) {
}

func postScaleOutHook(builder *task.Builder, newPart spec.Topology) {
nodeInfoTask := task.NewBuilder().Func("Check status", func(ctx *task.Context) error {
var err error
teleNodeInfos, err = operator.GetNodeInfo(context.Background(), ctx, newPart)
_ = err
// intend to never return error
return nil
}).BuildAsStep("Check status").SetHidden(true)

if report.Enable() {
builder.Parallel(false, convertStepDisplaysToTasks([]*task.StepDisplay{nodeInfoTask})...)
}
postDeployHook(builder, newPart)
}
12 changes: 6 additions & 6 deletions components/dm/ansible/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (im *Importer) handleWorkerConfig(srv *spec.WorkerSpec, fname string) error

// ScpSourceToMaster scp the source files to master,
// and set V1SourcePath of the master spec.
func (im *Importer) ScpSourceToMaster(topo *spec.Topology) (err error) {
func (im *Importer) ScpSourceToMaster(topo *spec.Specification) (err error) {
for i := 0; i < len(topo.Masters); i++ {
master := &topo.Masters[i]
target := filepath.Join(firstNonEmpty(master.DeployDir, topo.GlobalOptions.DeployDir), "v1source")
Expand Down Expand Up @@ -293,7 +293,7 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad
}

meta = &spec.Metadata{
Topology: new(spec.Topology),
Topology: new(spec.Specification),
}
topo := meta.Topology

Expand Down Expand Up @@ -480,7 +480,7 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad
}
case "alertmanager_servers":
for _, host := range group.Hosts {
srv := spec.AlertManagerSpec{
srv := spec.AlertmanagerSpec{
Host: host.Vars["ansible_host"],
SSHPort: ansible.GetHostPort(host, cfg),
DeployDir: firstNonEmpty(host.Vars["deploy_dir"], topo.GlobalOptions.DeployDir),
Expand Down Expand Up @@ -521,9 +521,9 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad
}
}

srv.DeployDir = instancDeployDir(spec.ComponentAlertManager, srv.WebPort, host.Vars["deploy_dir"], topo.GlobalOptions.DeployDir)
srv.DeployDir = instancDeployDir(spec.ComponentAlertmanager, srv.WebPort, host.Vars["deploy_dir"], topo.GlobalOptions.DeployDir)

topo.Alertmanager = append(topo.Alertmanager, srv)
topo.Alertmanagers = append(topo.Alertmanagers, srv)
}
case "grafana_servers":
for _, host := range group.Hosts {
Expand Down Expand Up @@ -559,7 +559,7 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad
}

srv.DeployDir = instancDeployDir(spec.ComponentGrafana, srv.Port, host.Vars["deploy_dir"], topo.GlobalOptions.DeployDir)
topo.Grafana = append(topo.Grafana, srv)
topo.Grafanas = append(topo.Grafanas, srv)
}
case "all", "ungrouped":
// ignore intent
Expand Down
10 changes: 5 additions & 5 deletions components/dm/ansible/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ func TestImportFromAnsible(t *testing.T) {
assert.Equal(expectedWorker, worker)

// check Alertmanager
assert.Len(topo.Alertmanager, 1)
aler := topo.Alertmanager[0]
expectedAlter := spec.AlertManagerSpec{
assert.Len(topo.Alertmanagers, 1)
aler := topo.Alertmanagers[0]
expectedAlter := spec.AlertmanagerSpec{
Host: "172.19.0.101",
SSHPort: 22,
WebPort: 9093,
Expand All @@ -201,8 +201,8 @@ func TestImportFromAnsible(t *testing.T) {
assert.Equal(expectedAlter, aler)

// Check Grafana
assert.Len(topo.Grafana, 1)
grafana := topo.Grafana[0]
assert.Len(topo.Grafanas, 1)
grafana := topo.Grafanas[0]
expectedGrafana := spec.GrafanaSpec{
Host: "172.19.0.101",
SSHPort: 22,
Expand Down
2 changes: 1 addition & 1 deletion components/dm/command/scale_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func newScaleInCmd() *cobra.Command {
// ScaleInDMCluster scale in dm cluster.
func ScaleInDMCluster(
getter operator.ExecutorGetter,
topo *dm.Topology,
topo *dm.Specification,
options operator.Options,
) error {
// instances by uuid
Expand Down
173 changes: 0 additions & 173 deletions components/dm/spec/alertmanager.go

This file was deleted.

2 changes: 1 addition & 1 deletion components/dm/spec/bindversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "github.com/pingcap/tiup/pkg/cluster/spec"
// DMComponentVersion maps the dm version to the third components binding version
func DMComponentVersion(comp, version string) string {
switch comp {
case spec.ComponentAlertManager:
case spec.ComponentAlertmanager:
return "v0.17.0"
case spec.ComponentGrafana, spec.ComponentPrometheus:
return "v4.0.3"
Expand Down
6 changes: 3 additions & 3 deletions components/dm/spec/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Metadata struct {
Version string `yaml:"dm_version"` // the version of TiDB cluster
//EnableFirewall bool `yaml:"firewall"`

Topology *Topology `yaml:"topology"`
Topology *Specification `yaml:"topology"`
}

var _ cspec.UpgradableMetadata = &Metadata{}
Expand All @@ -51,7 +51,7 @@ func (m *Metadata) GetTopology() cspec.Topology {

// SetTopology implements Metadata interface.
func (m *Metadata) SetTopology(topo cspec.Topology) {
dmTopo, ok := topo.(*Topology)
dmTopo, ok := topo.(*Specification)
if !ok {
panic(fmt.Sprintln("wrong type: ", reflect.TypeOf(topo)))
}
Expand All @@ -72,7 +72,7 @@ func GetSpecManager() *cspec.SpecManager {
if specManager == nil {
specManager = cspec.NewSpec(filepath.Join(cspec.ProfileDir(), cspec.TiOpsClusterDir), func() cspec.Metadata {
return &Metadata{
Topology: new(Topology),
Topology: new(Specification),
}
})
}
Expand Down
Loading

0 comments on commit 30bb957

Please sign in to comment.