Skip to content

Commit

Permalink
Merge e261e25 into 10da905
Browse files Browse the repository at this point in the history
  • Loading branch information
srstack authored Feb 16, 2022
2 parents 10da905 + e261e25 commit ee480cd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
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

0 comments on commit ee480cd

Please sign in to comment.