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 24, 2020
1 parent 0ec224a commit e837bdf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/playground/playground.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,14 +559,14 @@ func (p *Playground) enableBinlog() bool {

func (p *Playground) addInstance(componentID string, cfg instance.Config) (ins instance.Instance, err error) {
if cfg.BinPath != "" {
cfg.BinPath,err = getAbsolutePath(cfg.BinPath)
cfg.BinPath, err = getAbsolutePath(cfg.BinPath)
if err != nil {
return nil, err
}
}

if cfg.ConfigPath != "" {
cfg.ConfigPath,err = getAbsolutePath(cfg.ConfigPath)
cfg.ConfigPath, err = getAbsolutePath(cfg.ConfigPath)
if err != nil {
return nil, err
}
Expand Down
33 changes: 33 additions & 0 deletions pkg/cliutil/prepare/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/pingcap/tiup/pkg/cluster/task"
"github.com/pingcap/tiup/pkg/errutil"
"github.com/pingcap/tiup/pkg/meta"
"github.com/pingcap/tiup/pkg/set"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -216,6 +217,10 @@ func CheckClusterPortConflict(clusterSpec *meta.SpecManager, clusterName string,
return errors.Trace(err)
}

uniqueHosts := set.NewStringSet()
nodeExporterPort := metadata.Topology.MonitoredOptions.NodeExporterPort
blackboxExporterPort := metadata.Topology.MonitoredOptions.BlackboxExporterPort

metadata.Topology.IterInstance(func(inst spec.Instance) {
for _, port := range inst.UsedPorts() {
existingEntries = append(existingEntries, Entry{
Expand All @@ -224,6 +229,20 @@ func CheckClusterPortConflict(clusterSpec *meta.SpecManager, clusterName string,
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 @@ -234,6 +253,20 @@ func CheckClusterPortConflict(clusterSpec *meta.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.MonitoredOptions.NodeExporterPort,
},
Entry{
instance: inst,
port: topo.MonitoredOptions.BlackboxExporterPort,
})
}
})

for _, p1 := range currentEntries {
Expand Down

0 comments on commit e837bdf

Please sign in to comment.