Skip to content

Commit

Permalink
dry: merge dm's {alertmanager,grafana,prometheus} into cluster (pingc…
Browse files Browse the repository at this point in the history
  • Loading branch information
jsvisa authored Nov 13, 2020
1 parent bb072ef commit cc41ad5
Show file tree
Hide file tree
Showing 48 changed files with 535 additions and 1,185 deletions.
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 cc41ad5

Please sign in to comment.