From 456f37af225e3918cfb48955236e8285a81ef86c Mon Sep 17 00:00:00 2001 From: nexustar Date: Mon, 25 Sep 2023 15:28:46 +0800 Subject: [PATCH 1/3] add cdn workaround (#2285) --- pkg/repository/mirror.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/repository/mirror.go b/pkg/repository/mirror.go index f88cc75468..89d037c5de 100644 --- a/pkg/repository/mirror.go +++ b/pkg/repository/mirror.go @@ -15,6 +15,7 @@ package repository import ( "bytes" + "crypto/tls" "encoding/json" stderrors "errors" "fmt" @@ -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 { From f3b080677ac73e0ce97574224bdc5c11142e9a3d Mon Sep 17 00:00:00 2001 From: nexustar Date: Mon, 25 Sep 2023 16:40:46 +0800 Subject: [PATCH 2/3] cluster/dm: support ignore version check when upgrade (#2282) --- components/cluster/command/upgrade.go | 4 +++- components/dm/command/upgrade.go | 5 +++-- pkg/cluster/manager/upgrade.go | 7 +++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/components/cluster/command/upgrade.go b/components/cluster/command/upgrade.go index 2afe973a07..6ee3941e65 100644 --- a/components/cluster/command/upgrade.go +++ b/components/cluster/command/upgrade.go @@ -20,6 +20,7 @@ import ( func newUpgradeCmd() *cobra.Command { offlineMode := false + ignoreVersionCheck := false cmd := &cobra.Command{ Use: "upgrade ", @@ -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) { @@ -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") diff --git a/components/dm/command/upgrade.go b/components/dm/command/upgrade.go index bb6abf0ac7..fda3185089 100644 --- a/components/dm/command/upgrade.go +++ b/components/dm/command/upgrade.go @@ -19,7 +19,7 @@ import ( func newUpgradeCmd() *cobra.Command { offlineMode := false - + ignoreVersionCheck := false cmd := &cobra.Command{ Use: "upgrade ", Short: "Upgrade a specified DM cluster", @@ -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) { @@ -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 } diff --git a/pkg/cluster/manager/upgrade.go b/pkg/cluster/manager/upgrade.go index cf28dbadb0..06a668b999 100644 --- a/pkg/cluster/manager/upgrade.go +++ b/pkg/cluster/manager/upgrade.go @@ -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 } @@ -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 { From 1c9c153431a58f57c49ed046dbf79955954b32e5 Mon Sep 17 00:00:00 2001 From: nexustar Date: Mon, 25 Sep 2023 20:04:46 +0800 Subject: [PATCH 3/3] mirror: fix progress bar is not accurate (#2284) --- pkg/repository/mirror.go | 1 + pkg/repository/progress.go | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/repository/mirror.go b/pkg/repository/mirror.go index 89d037c5de..7fb446f704 100644 --- a/pkg/repository/mirror.go +++ b/pkg/repository/mirror.go @@ -335,6 +335,7 @@ L: } progress.SetCurrent(resp.BytesComplete()) case <-resp.Done: + progress.SetCurrent(resp.BytesComplete()) progress.Finish() break L } diff --git a/pkg/repository/progress.go b/pkg/repository/progress.go index 951dc99a88..f8df7e2cdf 100644 --- a/pkg/repository/progress.go +++ b/pkg/repository/progress.go @@ -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() }