Skip to content

Commit

Permalink
Fix the issue that tiup-cluster disable monitoring service regardless…
Browse files Browse the repository at this point in the history
… if there are other service still running on that node.

Fix #697
  • Loading branch information
lucklove committed Jan 22, 2021
1 parent d85cb88 commit 4f66ce7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/cluster/operation/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ func Enable(
options Options,
isEnable bool,
) error {
uniqueHosts := set.NewStringSet()
roleFilter := set.NewStringSet(options.Roles...)
nodeFilter := set.NewStringSet(options.Nodes...)
components := cluster.ComponentsByStartOrder()
components = FilterComponent(components, roleFilter)
monitoredOptions := cluster.GetMonitoredOptions()

instCount := map[string]int{}
cluster.IterInstance(func(inst spec.Instance) {
instCount[inst.GetHost()]++
})

for _, comp := range components {
insts := FilterInstance(comp.Instances(), nodeFilter)
err := EnableComponent(ctx, insts, options, isEnable)
Expand All @@ -54,8 +58,8 @@ func Enable(
continue
}
for _, inst := range insts {
if !uniqueHosts.Exist(inst.GetHost()) {
uniqueHosts.Insert(inst.GetHost())
instCount[inst.GetHost()]--
if instCount[inst.GetHost()] == 0 {
if err := EnableMonitored(ctx, inst, monitoredOptions, options.OptTimeout, isEnable); err != nil {
return err
}
Expand Down

0 comments on commit 4f66ce7

Please sign in to comment.