From f5025db169d642c2bbd045b00bfa455537c12f40 Mon Sep 17 00:00:00 2001 From: Allen Zhong Date: Thu, 5 Aug 2021 11:42:41 +0800 Subject: [PATCH] ignore exporters when check data_dir overlap --- pkg/cluster/spec/validate.go | 10 +++++++++- pkg/cluster/spec/validate_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/pkg/cluster/spec/validate.go b/pkg/cluster/spec/validate.go index 5e6df41f78..0679eb70f4 100644 --- a/pkg/cluster/spec/validate.go +++ b/pkg/cluster/spec/validate.go @@ -227,7 +227,7 @@ func CheckClusterDirOverlap(entries []DirEntry) error { if d1.instance.IsImported() && d2.instance.IsImported() { continue } - // overlap is alloed in the case one side is imported and the other is monitor, + // overlap is allowed in the case one side is imported and the other is monitor, // we assume that the monitor is deployed with the first instance in that host, // it implies that the monitor is imported too. if (strings.HasPrefix(d1.dirKind, "monitor") && d2.instance.IsImported()) || @@ -235,6 +235,14 @@ func CheckClusterDirOverlap(entries []DirEntry) error { continue } + // overlap is allowed in the case one side is data dir of a monitor instance, + // as the *_exporter don't need data dir, the field is only kept for compatiability + // with legacy tidb-ansible deployments. + if (strings.HasPrefix(d1.dirKind, "monitor data directory")) || + (strings.HasPrefix(d2.dirKind, "monitor data directory")) { + continue + } + properties := map[string]string{ "ThisDirKind": d1.dirKind, "ThisDir": d1.dir, diff --git a/pkg/cluster/spec/validate_test.go b/pkg/cluster/spec/validate_test.go index 15846fee70..ebd6f4e2c2 100644 --- a/pkg/cluster/spec/validate_test.go +++ b/pkg/cluster/spec/validate_test.go @@ -1045,6 +1045,32 @@ tikv_servers: status_port: 32180 log_dir: "/home/tidb6wu/tidb1-data/tikv-32160-log" data_dir: "/home/tidb6wu/tidb1-data/tikv-32160" +`, + ` +monitored: + node_exporter_port: 9100 + blackbox_exporter_port: 9115 + deploy_dir: /data/deploy/monitor-9100 + data_dir: /data/deploy/monitor-9100 + log_dir: /data/deploy/monitor-9100/log +pd_servers: + - host: n0 + name: pd0 + imported: true + deploy_dir: /data/deploy + data_dir: /data/deploy/data.pd + log_dir: /data/deploy/log + - host: n1 + name: pd1 + log_dir: "/data/deploy/pd-2379/log" + data_dir: "/data/pd-2379" + deploy_dir: "/data/deploy/pd-2379" +cdc_servers: + - host: n1 + port: 8300 + deploy_dir: /data/deploy/ticdc-8300 + data_dir: /data1/ticdc-8300 + log_dir: /data/deploy/ticdc-8300/log `, } for _, s := range goodTopos {