Skip to content

Commit

Permalink
cluster: check ports for monitoring agent between clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis committed Jul 30, 2020
1 parent 67fca66 commit a4e6b45
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pkg/cliutil/prepare/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/pingcap/tiup/pkg/cluster/spec"
"github.com/pingcap/tiup/pkg/cluster/task"
"github.com/pingcap/tiup/pkg/errutil"
"github.com/pingcap/tiup/pkg/set"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -231,13 +232,30 @@ func CheckClusterPortConflict(clusterSpec *spec.SpecManager, clusterName string,
}

metadata.GetTopology().IterInstance(func(inst spec.Instance) {
uniqueHosts := set.NewStringSet()
nodeExporterPort := metadata.GetTopology().GetMonitoredOptions().NodeExporterPort
blackboxExporterPort := metadata.GetTopology().GetMonitoredOptions().BlackboxExporterPort
for _, port := range inst.UsedPorts() {
existingEntries = append(existingEntries, Entry{
clusterName: name,
instance: inst,
port: port,
})
}
if !uniqueHosts.Exist(inst.GetHost()) {
uniqueHosts.Insert(inst.GetHost())
existingEntries = append(existingEntries,
Entry{
clusterName: name,
instance: inst,
port: nodeExporterPort,
},
Entry{
clusterName: name,
instance: inst,
port: blackboxExporterPort,
})
}
})
}

Expand All @@ -248,6 +266,20 @@ func CheckClusterPortConflict(clusterSpec *spec.SpecManager, clusterName string,
port: port,
})
}

uniqueHosts := set.NewStringSet()
if !uniqueHosts.Exist(inst.GetHost()) {
uniqueHosts.Insert(inst.GetHost())
currentEntries = append(currentEntries,
Entry{
instance: inst,
port: topo.GetMonitoredOptions().NodeExporterPort,
},
Entry{
instance: inst,
port: topo.GetMonitoredOptions().BlackboxExporterPort,
})
}
})

for _, p1 := range currentEntries {
Expand Down

0 comments on commit a4e6b45

Please sign in to comment.