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: support use different component versions #2264

Merged
merged 11 commits into from
Nov 7, 2023
Prev Previous commit
Next Next commit
fix
  • Loading branch information
nexustar committed Nov 7, 2023
commit 252748cfc7d3ac3c2b7e9735656579b7af6ade4f
21 changes: 11 additions & 10 deletions pkg/cluster/manager/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,6 @@ func (m *Manager) Upgrade(name string, clusterVersion string, componentVersions
m.logger.Warnf(color.RedString("There is no guarantee that the cluster can be downgraded. Be careful before you continue."))
}

monitoredOptions := topo.GetMonitoredOptions()
if componentVersions[spec.ComponentBlackboxExporter] != "" {
monitoredOptions.BlackboxExporterVersion = componentVersions[spec.ComponentBlackboxExporter]
}
if componentVersions[spec.ComponentNodeExporter] != "" {
monitoredOptions.NodeExporterVersion = componentVersions[spec.ComponentNodeExporter]
}

compVersionMsg := ""
for _, comp := range topo.ComponentsByUpdateOrder(base.Version) {
// if component version is not specified, use the cluster version or latest("")
Expand All @@ -106,8 +98,17 @@ func (m *Manager) Upgrade(name string, clusterVersion string, componentVersions
compVersionMsg += fmt.Sprintf("\nwill upgrade component %19s to \"%s\",", "\""+comp.Name()+"\"", comp.CalculateVersion(clusterVersion))
}
}
compVersionMsg += fmt.Sprintf("\nwill upgrade component %19s to \"%s\",", "\"node-exporter\"", monitoredOptions.NodeExporterVersion)
compVersionMsg += fmt.Sprintf("\nwill upgrade component %19s to \"%s\".", "\"blackbox-exporter\"", monitoredOptions.BlackboxExporterVersion)
monitoredOptions := topo.GetMonitoredOptions()
if monitoredOptions != nil {
if componentVersions[spec.ComponentBlackboxExporter] != "" {
monitoredOptions.BlackboxExporterVersion = componentVersions[spec.ComponentBlackboxExporter]
}
if componentVersions[spec.ComponentNodeExporter] != "" {
monitoredOptions.NodeExporterVersion = componentVersions[spec.ComponentNodeExporter]
}
compVersionMsg += fmt.Sprintf("\nwill upgrade component %19s to \"%s\",", "\"node-exporter\"", monitoredOptions.NodeExporterVersion)
compVersionMsg += fmt.Sprintf("\nwill upgrade component %19s to \"%s\".", "\"blackbox-exporter\"", monitoredOptions.BlackboxExporterVersion)
}

m.logger.Warnf(`%s
This operation will upgrade %s %s cluster %s to %s:%s`,
Expand Down
31 changes: 16 additions & 15 deletions pkg/cluster/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,22 @@ type (

// ComponentVersions represents the versions of components
ComponentVersions struct {
TiDB string `yaml:"tidb,omitempty"`
TiKV string `yaml:"tikv,omitempty"`
TiFlash string `yaml:"tiflash,omitempty"`
PD string `yaml:"pd,omitempty"`
Dashboard string `yaml:"tidb_dashboard,omitempty"`
Pump string `yaml:"pump,omitempty"`
Drainer string `yaml:"drainer,omitempty"`
CDC string `yaml:"cdc,omitempty"`
TiKVCDC string `yaml:"kvcdc,omitempty"`
TiProxy string `yaml:"tiproxy,omitempty"`
Prometheus string `yaml:"prometheus,omitempty"`
Grafana string `yaml:"grafana,omitempty"`
AlertManager string `yaml:"alertmanager,omitempty"`
NodeExporter string `yaml:"node_exporter,omitempty"`
BlackboxExporter string `yaml:"blackbox_exporter,omitempty"`
TiDB string `yaml:"tidb,omitempty"`
TiKV string `yaml:"tikv,omitempty"`
TiFlash string `yaml:"tiflash,omitempty"`
PD string `yaml:"pd,omitempty"`
Dashboard string `yaml:"tidb_dashboard,omitempty"`
Pump string `yaml:"pump,omitempty"`
Drainer string `yaml:"drainer,omitempty"`
CDC string `yaml:"cdc,omitempty"`
TiKVCDC string `yaml:"kvcdc,omitempty"`
TiProxy string `yaml:"tiproxy,omitempty"`
Prometheus string `yaml:"prometheus,omitempty"`
Grafana string `yaml:"grafana,omitempty"`
AlertManager string `yaml:"alertmanager,omitempty"`
// The versions of exporters are placed within the monitored section because they are not explicitly treated as separate components.
// NodeExporter string `yaml:"node_exporter,omitempty"`
// BlackboxExporter string `yaml:"blackbox_exporter,omitempty"`
}

// Specification represents the specification of topology.yaml
Expand Down