Skip to content

Commit

Permalink
cluster: skip dir conflict if node marked ignore_exporter (#1649)
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis authored Dec 3, 2021
1 parent 5e97222 commit e7f9871
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/cluster/spec/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ func CheckClusterDirConflict(clusterList map[string]Metadata, clusterName string
continue
}

// ignore conflict in the case when both sides are monitor and either one of them
// is marked as ignore exporter.
if strings.HasPrefix(d1.dirKind, "monitor") &&
strings.HasPrefix(d2.dirKind, "monitor") &&
(d1.instance.IgnoreMonitorAgent() || d2.instance.IgnoreMonitorAgent()) {
continue
}

if d1.dir == d2.dir && d1.dir != "" {
properties := map[string]string{
"ThisDirKind": d1.dirKind,
Expand Down Expand Up @@ -229,6 +237,7 @@ func CheckClusterDirOverlap(entries []DirEntry) error {
if d1.instance.IsImported() && d2.instance.IsImported() {
continue
}

// 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.
Expand Down
10 changes: 10 additions & 0 deletions pkg/cluster/spec/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,16 @@ It conflicts to a directory in the existing cluster:
Please change to use another directory or another host.`)

// no dir conflict error if one of the instance is marked as ignore_exporter
err = yaml.Unmarshal([]byte(`
tidb_servers:
- host: 172.16.5.138
ignore_exporter: true
`), &topo3)
c.Assert(err, IsNil)
err = CheckClusterDirConflict(clsList, "topo", &topo3)
c.Assert(err, IsNil)

// component with different port has no dir conflict
topo4 := Specification{}
err = yaml.Unmarshal([]byte(`
Expand Down

0 comments on commit e7f9871

Please sign in to comment.