diff --git a/components/dm/ansible/import.go b/components/dm/ansible/import.go index 18ae1f4bd2..e0fd50dc21 100644 --- a/components/dm/ansible/import.go +++ b/components/dm/ansible/import.go @@ -330,8 +330,9 @@ func (im *Importer) ImportFromAnsibleDir(ctx context.Context) (clusterName strin case "dm_master_servers": for _, host := range group.Hosts { srv := &spec.MasterSpec{ - Host: host.Vars["ansible_host"], - SSHPort: ansible.GetHostPort(host, cfg), + Host: host.Vars["ansible_host"], + SSHPort: ansible.GetHostPort(host, cfg), + Imported: true, } runFileName := filepath.Join(host.Vars["deploy_dir"], "scripts", "run_dm-master.sh") @@ -380,6 +381,7 @@ func (im *Importer) ImportFromAnsibleDir(ctx context.Context) (clusterName strin Host: host.Vars["ansible_host"], SSHPort: ansible.GetHostPort(host, cfg), DeployDir: firstNonEmpty(host.Vars["deploy_dir"], topo.GlobalOptions.DeployDir), + Imported: true, } runFileName := filepath.Join(host.Vars["deploy_dir"], "scripts", "run_dm-worker.sh") @@ -441,6 +443,7 @@ func (im *Importer) ImportFromAnsibleDir(ctx context.Context) (clusterName strin Host: host.Vars["ansible_host"], SSHPort: ansible.GetHostPort(host, cfg), DeployDir: firstNonEmpty(host.Vars["deploy_dir"], topo.GlobalOptions.DeployDir), + Imported: true, } runFileName := filepath.Join(host.Vars["deploy_dir"], "scripts", "run_prometheus.sh") @@ -489,6 +492,7 @@ func (im *Importer) ImportFromAnsibleDir(ctx context.Context) (clusterName strin Host: host.Vars["ansible_host"], SSHPort: ansible.GetHostPort(host, cfg), DeployDir: firstNonEmpty(host.Vars["deploy_dir"], topo.GlobalOptions.DeployDir), + Imported: true, } runFileName := filepath.Join(host.Vars["deploy_dir"], "scripts", "run_alertmanager.sh") @@ -546,6 +550,7 @@ func (im *Importer) ImportFromAnsibleDir(ctx context.Context) (clusterName strin Port: port, Username: grafanaUser, Password: grafanaPass, + Imported: true, } runFileName := filepath.Join(host.Vars["deploy_dir"], "scripts", "run_grafana.sh") diff --git a/components/dm/ansible/import_test.go b/components/dm/ansible/import_test.go index 66109bcd3d..51711695f6 100644 --- a/components/dm/ansible/import_test.go +++ b/components/dm/ansible/import_test.go @@ -164,6 +164,7 @@ func TestImportFromAnsible(t *testing.T) { DeployDir: "", LogDir: "/home/tidb/deploy/log", Config: map[string]interface{}{"log-level": "info"}, + Imported: true, } assert.Equal(expectedMaster, master) @@ -180,6 +181,7 @@ func TestImportFromAnsible(t *testing.T) { DeployDir: "/home/tidb/deploy", LogDir: "/home/tidb/deploy/log", Config: map[string]interface{}{"log-level": "info"}, + Imported: true, } worker := topo.Workers[0] @@ -199,6 +201,7 @@ func TestImportFromAnsible(t *testing.T) { DeployDir: "", DataDir: "/home/tidb/deploy/data.alertmanager", LogDir: "/home/tidb/deploy/log", + Imported: true, } assert.Equal(expectedAlter, aler) @@ -212,6 +215,7 @@ func TestImportFromAnsible(t *testing.T) { Port: 3001, Username: "foo", Password: "bar", + Imported: true, } assert.Equal(expectedGrafana, grafana) @@ -225,6 +229,7 @@ func TestImportFromAnsible(t *testing.T) { DataDir: "/home/tidb/deploy/prometheus.data.metrics", LogDir: "/home/tidb/deploy/log", Port: 9090, + Imported: true, } assert.Equal(expectedMonitor, monitor) diff --git a/pkg/cluster/manager/deploy.go b/pkg/cluster/manager/deploy.go index 1ca3ecde85..f38e82624e 100644 --- a/pkg/cluster/manager/deploy.go +++ b/pkg/cluster/manager/deploy.go @@ -187,8 +187,9 @@ func (m *Manager) Deploy( iterErr = nil topo.IterInstance(func(inst spec.Instance) { if _, found := uniqueHosts[inst.GetHost()]; !found { - // check for "imported" parameter, it can not be true when scaling out - if inst.IsImported() { + // check for "imported" parameter, it can not be true when deploying and scaling out + // only for tidb now, need to support dm + if inst.IsImported() && m.sysName == "tidb" { iterErr = errors.New( "'imported' is set to 'true' for new instance, this is only used " + "for instances imported from tidb-ansible and make no sense when " + diff --git a/pkg/cluster/spec/prometheus.go b/pkg/cluster/spec/prometheus.go index fad408e7de..3b6703b11d 100644 --- a/pkg/cluster/spec/prometheus.go +++ b/pkg/cluster/spec/prometheus.go @@ -372,7 +372,7 @@ func (i *MonitorInstance) initRules(ctx context.Context, e ctxt.Executor, spec * "mkdir -p %[1]s/conf", `find %[1]s/conf -type f -name "*.rules.yml" -delete`, `find %[1]s/bin/prometheus -maxdepth 1 -type f -name "*.rules.yml" -exec cp {} %[1]s/conf/ \;`, - `find %[1]s/conf -maxdepth 1 -type f -name "*.rules.yml" -exec sed -i "s/ENV_LABELS_ENV/%[2]s/g" {} \;`, + `find %[1]s/conf -maxdepth 1 -type f -name "*.rules.yml" -exec sed -i -e "s/ENV_LABELS_ENV/%[2]s/g" {} \;`, } _, stderr, err := e.Execute(ctx, fmt.Sprintf(strings.Join(cmds, " && "), paths.Deploy, clusterName), false) if err != nil { diff --git a/pkg/cluster/spec/validate.go b/pkg/cluster/spec/validate.go index fcbd6d8d19..ad12d76e45 100644 --- a/pkg/cluster/spec/validate.go +++ b/pkg/cluster/spec/validate.go @@ -223,6 +223,9 @@ func CheckClusterDirOverlap(entries []DirEntry) error { } if utils.IsSubDir(d1.dir, d2.dir) || utils.IsSubDir(d2.dir, d1.dir) { + if d1.instance.IsImported() && d2.instance.IsImported() { + continue + } properties := map[string]string{ "ThisDirKind": d1.dirKind, "ThisDir": d1.dir,