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. (#1088)

Fix #697

Co-authored-by: Ti Chi Robot <71242396+ti-chi-bot@users.noreply.github.com>
  • Loading branch information
2 people authored and AstroProfundis committed Mar 24, 2021
1 parent 137363a commit 9b0e00c
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 @@ -35,13 +35,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(getter, insts, options, isEnable)
Expand All @@ -52,8 +56,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(getter, inst, monitoredOptions, options.OptTimeout, isEnable); err != nil {
return err
}
Expand Down

0 comments on commit 9b0e00c

Please sign in to comment.