Skip to content

Commit

Permalink
Merge branch 'master' into bump-v1.13.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kaaaaaaang authored Sep 25, 2023
2 parents 902274d + 1c9c153 commit ba19e3a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
4 changes: 3 additions & 1 deletion components/cluster/command/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

func newUpgradeCmd() *cobra.Command {
offlineMode := false
ignoreVersionCheck := false

cmd := &cobra.Command{
Use: "upgrade <cluster-name> <version>",
Expand All @@ -38,7 +39,7 @@ func newUpgradeCmd() *cobra.Command {
teleCommand = append(teleCommand, scrubClusterName(clusterName))
teleCommand = append(teleCommand, version)

return cm.Upgrade(clusterName, version, gOpt, skipConfirm, offlineMode)
return cm.Upgrade(clusterName, version, gOpt, skipConfirm, offlineMode, ignoreVersionCheck)
},
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
switch len(args) {
Expand All @@ -53,6 +54,7 @@ func newUpgradeCmd() *cobra.Command {
cmd.Flags().Uint64Var(&gOpt.APITimeout, "transfer-timeout", 600, "Timeout in seconds when transferring PD and TiKV store leaders, also for TiCDC drain one capture")
cmd.Flags().BoolVarP(&gOpt.IgnoreConfigCheck, "ignore-config-check", "", false, "Ignore the config check result")
cmd.Flags().BoolVarP(&offlineMode, "offline", "", false, "Upgrade a stopped cluster")
cmd.Flags().BoolVarP(&ignoreVersionCheck, "ignore-version-check", "", false, "Ignore checking if target version is bigger than current version")
cmd.Flags().StringVar(&gOpt.SSHCustomScripts.BeforeRestartInstance.Raw, "pre-upgrade-script", "", "(EXPERIMENTAL) Custom script to be executed on each server before the server is upgraded")
cmd.Flags().StringVar(&gOpt.SSHCustomScripts.AfterRestartInstance.Raw, "post-upgrade-script", "", "(EXPERIMENTAL) Custom script to be executed on each server after the server is upgraded")

Expand Down
5 changes: 3 additions & 2 deletions components/dm/command/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

func newUpgradeCmd() *cobra.Command {
offlineMode := false

ignoreVersionCheck := false
cmd := &cobra.Command{
Use: "upgrade <cluster-name> <version>",
Short: "Upgrade a specified DM cluster",
Expand All @@ -28,7 +28,7 @@ func newUpgradeCmd() *cobra.Command {
return cmd.Help()
}

return cm.Upgrade(args[0], args[1], gOpt, skipConfirm, offlineMode)
return cm.Upgrade(args[0], args[1], gOpt, skipConfirm, offlineMode, ignoreVersionCheck)
},
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
switch len(args) {
Expand All @@ -41,6 +41,7 @@ func newUpgradeCmd() *cobra.Command {
}

cmd.Flags().BoolVarP(&offlineMode, "offline", "", false, "Upgrade a stopped cluster")
cmd.Flags().BoolVarP(&ignoreVersionCheck, "ignore-version-check", "", false, "Ignore checking if target version is higher than current version")

return cmd
}
7 changes: 5 additions & 2 deletions pkg/cluster/manager/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
)

// Upgrade the cluster.
func (m *Manager) Upgrade(name string, clusterVersion string, opt operator.Options, skipConfirm, offline bool) error {
func (m *Manager) Upgrade(name string, clusterVersion string, opt operator.Options, skipConfirm, offline, ignoreVersionCheck bool) error {
if err := clusterutil.ValidateClusterNameOrError(name); err != nil {
return err
}
Expand Down Expand Up @@ -68,7 +68,10 @@ func (m *Manager) Upgrade(name string, clusterVersion string, opt operator.Optio
)

if err := versionCompare(base.Version, clusterVersion); err != nil {
return err
if !ignoreVersionCheck {
return err
}
m.logger.Warnf(color.RedString("There is no guarantee that the cluster can be downgraded. Be careful before you continue."))
}

if !skipConfirm {
Expand Down
10 changes: 10 additions & 0 deletions pkg/repository/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package repository

import (
"bytes"
"crypto/tls"
"encoding/json"
stderrors "errors"
"fmt"
Expand Down Expand Up @@ -293,6 +294,14 @@ func (l *httpMirror) downloadFile(url string, to string, maxSize int64) (io.Read
}(time.Now())

client := grab.NewClient()

// workaround to resolve cdn error "tls: protocol version not supported"
client.HTTPClient.(*http.Client).Transport = &http.Transport{
Proxy: http.ProxyFromEnvironment,
// avoid using http/2 by setting non-nil TLSClientConfig
TLSClientConfig: &tls.Config{},
}

client.UserAgent = fmt.Sprintf("tiup/%s", version.NewTiUPVersion().SemVer())
req, err := grab.NewRequest(to, url)
if err != nil {
Expand Down Expand Up @@ -326,6 +335,7 @@ L:
}
progress.SetCurrent(resp.BytesComplete())
case <-resp.Done:
progress.SetCurrent(resp.BytesComplete())
progress.Finish()
break L
}
Expand Down
1 change: 0 additions & 1 deletion pkg/repository/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,5 @@ func (p *ProgressBar) SetCurrent(size int64) {

// Finish implement the DownloadProgress interface
func (p *ProgressBar) Finish() {
p.bar.SetCurrent(p.size)
p.bar.Finish()
}

0 comments on commit ba19e3a

Please sign in to comment.