Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cluster: fix upgrade not restart exporer #1758

Merged
merged 4 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pkg/cluster/operation/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,16 @@ func StopMonitored(ctx context.Context, hosts []string, noAgentHosts set.StringS
return systemctlMonitor(ctx, hosts, noAgentHosts, options, "stop", timeout)
}

// RestartMonitored stop BlackboxExporter and NodeExporter
func RestartMonitored(ctx context.Context, hosts []string, noAgentHosts set.StringSet, options *spec.MonitoredOptions, timeout uint64) error {
err := StopMonitored(ctx, hosts, noAgentHosts, options, timeout)
if err != nil {
return err
}

return StartMonitored(ctx, hosts, noAgentHosts, options, timeout)
}

// EnableMonitored enable/disable monitor service in a cluster
func EnableMonitored(ctx context.Context, hosts []string, noAgentHosts set.StringSet, options *spec.MonitoredOptions, timeout uint64, isEnable bool) error {
action := "disable"
Expand Down
15 changes: 13 additions & 2 deletions pkg/cluster/operation/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ func Upgrade(
components = FilterComponent(components, roleFilter)
logger := ctx.Value(logprinter.ContextKeyLogger).(*logprinter.Logger)

noAgentHosts := set.NewStringSet()
uniqueHosts := set.NewStringSet()

for _, component := range components {
instances := FilterInstance(component.Instances(), nodeFilter)
if len(instances) < 1 {
continue
}

logger.Infof("Upgrading component %s", component.Name())

// perform pre-upgrade actions of component
Expand Down Expand Up @@ -102,6 +104,11 @@ func Upgrade(
deferInstances := make([]spec.Instance, 0)

for _, instance := range instances {
// monitors
uniqueHosts.Insert(instance.GetHost())
if instance.IgnoreMonitorAgent() {
noAgentHosts.Insert(instance.GetHost())
}
switch component.Name() {
case spec.ComponentPD:
// defer PD leader to be upgraded after others
Expand Down Expand Up @@ -132,7 +139,11 @@ func Upgrade(
}
}

return nil
if topo.GetMonitoredOptions() == nil {
return nil
}

return RestartMonitored(ctx, uniqueHosts.Slice(), noAgentHosts, topo.GetMonitoredOptions(), options.OptTimeout)
}

func upgradeInstance(ctx context.Context, topo spec.Topology, instance spec.Instance, options Options, tlsCfg *tls.Config) (err error) {
Expand Down