Skip to content

Commit

Permalink
Fix the issue that the imported monitor directory may conflict with o…
Browse files Browse the repository at this point in the history
…ther components

Fix #1385
  • Loading branch information
lucklove committed May 25, 2021
1 parent 876377b commit e563e15
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/cluster/spec/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ Please change to use another directory or another host.
return CheckClusterDirOverlap(currentEntries)
}

// CheckClusterDirOverlap checks cluster dir overlaps with data or log
// we don't allow to deploy log under data, and vise versa
// CheckClusterDirOverlap checks cluster dir overlaps with data or log.
// this should only be used across clusters.
// we don't allow to deploy log under data, and vise versa.
// ref https://github.com/pingcap/tiup/issues/1047#issuecomment-761711508
func CheckClusterDirOverlap(entries []DirEntry) error {
ignore := func(d1, d2 DirEntry) bool {
Expand All @@ -223,9 +224,18 @@ func CheckClusterDirOverlap(entries []DirEntry) error {
}

if utils.IsSubDir(d1.dir, d2.dir) || utils.IsSubDir(d2.dir, d1.dir) {
// overlap is allowed in the case both sides are imported
if d1.instance.IsImported() && d2.instance.IsImported() {
continue
}
// overlap is alloed 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()) ||
(d1.instance.IsImported() && strings.HasPrefix(d2.dirKind, "monitor")) {
continue
}

properties := map[string]string{
"ThisDirKind": d1.dirKind,
"ThisDir": d1.dir,
Expand Down

0 comments on commit e563e15

Please sign in to comment.