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
merge master and support tiproxy version
  • Loading branch information
nexustar committed Nov 3, 2023
commit cc5c49b5dfacd9d064db4c8de262ae5292a3566b
7 changes: 5 additions & 2 deletions components/cluster/command/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (

func newUpgradeCmd() *cobra.Command {
offlineMode := false
var tidbVer, tikvVer, pdVer, tiflashVer, kvcdcVer, dashboardVer, cdcVer, alertmanagerVer, nodeExporterVer, blackboxExporterVer string
ignoreVersionCheck := false
var tidbVer, tikvVer, pdVer, tiflashVer, kvcdcVer, dashboardVer, cdcVer, alertmanagerVer, nodeExporterVer, blackboxExporterVer, tiproxyVer string

cmd := &cobra.Command{
Use: "upgrade <cluster-name> <version>",
Expand Down Expand Up @@ -49,11 +50,12 @@ func newUpgradeCmd() *cobra.Command {
spec.ComponentTiFlash: tiflashVer,
spec.ComponentTiKVCDC: kvcdcVer,
spec.ComponentCDC: cdcVer,
spec.ComponentTiProxy: tiproxyVer,
spec.ComponentBlackboxExporter: blackboxExporterVer,
spec.ComponentNodeExporter: nodeExporterVer,
}

return cm.Upgrade(clusterName, version, componentVersions, gOpt, skipConfirm, offlineMode)
return cm.Upgrade(clusterName, version, componentVersions, gOpt, skipConfirm, offlineMode, ignoreVersionCheck)
},
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
switch len(args) {
Expand Down Expand Up @@ -82,5 +84,6 @@ func newUpgradeCmd() *cobra.Command {
cmd.Flags().StringVar(&alertmanagerVer, "alertmanager-version", "", "Specify the version of alertmanager to upgrade to")
cmd.Flags().StringVar(&nodeExporterVer, "node-exporter-version", "", "Specify the version of node-exporter to upgrade to")
cmd.Flags().StringVar(&blackboxExporterVer, "blackbox-exporter-version", "", "Specify the version of blackbox-exporter to upgrade to")
cmd.Flags().StringVar(&tiproxyVer, "tiproxy-version", "", "Specify the version of tiproxy to upgrade to")
return cmd
}
2 changes: 1 addition & 1 deletion components/dm/command/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func newUpgradeCmd() *cobra.Command {
return cmd.Help()
}

return cm.Upgrade(args[0], args[1], nil, gOpt, skipConfirm, offlineMode)
return cm.Upgrade(args[0], args[1], nil, gOpt, skipConfirm, offlineMode, ignoreVersionCheck)
},
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
switch len(args) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/manager/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
)

// Upgrade the cluster.
func (m *Manager) Upgrade(name string, clusterVersion string, componentVersions map[string]string, opt operator.Options, skipConfirm, offline bool) error {
func (m *Manager) Upgrade(name string, clusterVersion string, componentVersions map[string]string, opt operator.Options, skipConfirm, offline, ignoreVersionCheck bool) error {
if !skipConfirm && strings.ToLower(opt.DisplayMode) != "json" {
for _, v := range componentVersions {
if v != "" {
Expand Down
6 changes: 4 additions & 2 deletions pkg/cluster/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ type (
Drainer string `yaml:"drainer"`
CDC string `yaml:"cdc"`
TiKVCDC string `yaml:"kvcdc"`
TiProxy string `yaml:"tiproxy"`
Prometheus string `yaml:"prometheus"`
Grafana string `yaml:"grafana"`
AlertManager string `yaml:"alertmanager"`
Expand All @@ -147,6 +148,7 @@ type (
TiDBServers []*TiDBSpec `yaml:"tidb_servers"`
TiKVServers []*TiKVSpec `yaml:"tikv_servers"`
TiFlashServers []*TiFlashSpec `yaml:"tiflash_servers"`
TiProxyServers []*TiProxySpec `yaml:"tiproxy_servers"`
PDServers []*PDSpec `yaml:"pd_servers"`
DashboardServers []*DashboardSpec `yaml:"tidb_dashboard_servers,omitempty"`
PumpServers []*PumpSpec `yaml:"pump_servers,omitempty"`
Expand Down Expand Up @@ -739,7 +741,7 @@ func (s *Specification) ComponentsByStopOrder() (comps []Component) {

// ComponentsByStartOrder return component in the order need to start.
func (s *Specification) ComponentsByStartOrder() (comps []Component) {
// "pd", "dashboard", "tikv", "pump", "tidb", "tiflash", "drainer", "cdc", "tikv-cdc", "prometheus", "grafana", "alertmanager"
// "pd", "dashboard", "tiproxy", "tikv", "pump", "tidb", "tiflash", "drainer", "cdc", "tikv-cdc", "prometheus", "grafana", "alertmanager"
comps = append(comps, &PDComponent{s})
comps = append(comps, &DashboardComponent{s})
comps = append(comps, &TiProxyComponent{s})
Expand All @@ -763,7 +765,7 @@ func (s *Specification) ComponentsByUpdateOrder(curVer string) (comps []Componen
// Ref: https://github.com/pingcap/tiup/issues/2166
cdcUpgradeBeforePDTiKVTiDB := tidbver.TiCDCUpgradeBeforePDTiKVTiDB(curVer)

// "tiflash", <"cdc">, "pd", "dashboard", "tikv", "pump", "tidb", "drainer", <"cdc>", "prometheus", "grafana", "alertmanager"
// "tiflash", <"cdc">, "pd", "dashboard", "tiproxy", "tikv", "pump", "tidb", "drainer", <"cdc>", "prometheus", "grafana", "alertmanager"
comps = append(comps, &TiFlashComponent{s})
if cdcUpgradeBeforePDTiKVTiDB {
comps = append(comps, &CDCComponent{s})
Expand Down
15 changes: 15 additions & 0 deletions pkg/cluster/spec/tiproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,21 @@ func (c *TiProxyComponent) Role() string {
return ComponentTiProxy
}

// CalculateVersion implements the Component interface
func (c *TiProxyComponent) CalculateVersion(clusterVersion string) string {
// always not follow global version, use ""(latest) by default
version := c.Topology.ComponentVersions.TiProxy
if version != "" {
return version
}
return "nightly"
}

// SetVersion implements Component interface.
func (c *TiProxyComponent) SetVersion(version string) {
c.Topology.ComponentVersions.TiProxy = version
}

// Instances implements Component interface.
func (c *TiProxyComponent) Instances() []Instance {
ins := make([]Instance, 0, len(c.Topology.TiProxyServers))
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.