Skip to content

Commit

Permalink
Merge branch 'master' into fix/zsh-wildcard
Browse files Browse the repository at this point in the history
  • Loading branch information
lucklove authored Dec 15, 2020
2 parents 4daea51 + d36a601 commit 3c98ed3
Show file tree
Hide file tree
Showing 58 changed files with 205 additions and 296 deletions.
1 change: 1 addition & 0 deletions cmd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var envList = []string{
localdata.EnvNameKeepSourceTarget,
localdata.EnvNameMirrorSyncScript,
localdata.EnvNameLogPath,
localdata.EnvNameDebug,
}

func newEnvCmd() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion components/cluster/command/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ conflict checks with other clusters`,

exist, err := tidbSpec.Exist(clusterName)
if err != nil {
return perrs.AddStack(err)
return err
}

if !exist {
Expand Down
7 changes: 5 additions & 2 deletions components/cluster/command/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ func newCleanCmd() *cobra.Command {

cmd := &cobra.Command{
Use: "clean <cluster-name>",
Short: "Cleanup a specified cluster",
Long: `Cleanup a specified cluster without destroying it (experimental).
Short: "(EXPERIMENTAL) Cleanup a specified cluster",
Long: `EXPERIMENTAL: This is an experimental feature, things may or may not work,
please backup your data before process.
Cleanup a specified cluster without destroying it.
You can retain some nodes and roles data when cleanup the cluster, eg:
$ tiup cluster clean <cluster-name> --all
$ tiup cluster clean <cluster-name> --log
Expand Down
2 changes: 1 addition & 1 deletion components/cluster/command/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func newDeploy() *cobra.Command {
}

cmd.Flags().StringVarP(&opt.User, "user", "u", utils.CurrentUser(), "The user name to login via SSH. The user must has root (or sudo) privilege.")
cmd.Flags().BoolVarP(&opt.SkipCreateUser, "skip-create-user", "", false, "Skip creating the user specified in topology (experimental).")
cmd.Flags().BoolVarP(&opt.SkipCreateUser, "skip-create-user", "", false, "(EXPERIMENTAL) Skip creating the user specified in topology.")
cmd.Flags().StringVarP(&opt.IdentityFile, "identity_file", "i", opt.IdentityFile, "The path of the SSH identity file. If specified, public key authentication will be used.")
cmd.Flags().BoolVarP(&opt.UsePassword, "password", "p", false, "Use password of target hosts. If specified, password authentication will be used.")
cmd.Flags().BoolVarP(&opt.IgnoreConfigCheck, "ignore-config-check", "", opt.IgnoreConfigCheck, "Ignore the config check result")
Expand Down
6 changes: 3 additions & 3 deletions components/cluster/command/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func newDisplayCmd() *cobra.Command {

exist, err := tidbSpec.Exist(clusterName)
if err != nil {
return perrs.AddStack(err)
return err
}

if !exist {
Expand All @@ -57,12 +57,12 @@ func newDisplayCmd() *cobra.Command {
metadata, err := spec.ClusterMetadata(clusterName)
if err != nil && !errors.Is(perrs.Cause(err), meta.ErrValidate) &&
!errors.Is(perrs.Cause(err), spec.ErrNoTiSparkMaster) {
return perrs.AddStack(err)
return err
}
if showDashboardOnly {
tlsCfg, err := metadata.Topology.TLSConfig(tidbSpec.Path(clusterName, spec.TLSCertKeyDir))
if err != nil {
return perrs.AddStack(err)
return err
}
return displayDashboardInfo(clusterName, tlsCfg)
}
Expand Down
3 changes: 1 addition & 2 deletions components/cluster/command/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"path/filepath"

"github.com/fatih/color"
"github.com/pingcap/errors"
"github.com/pingcap/tiup/pkg/cliutil"
"github.com/pingcap/tiup/pkg/cluster/ansible"
"github.com/pingcap/tiup/pkg/cluster/spec"
Expand Down Expand Up @@ -66,7 +65,7 @@ func newImportCmd() *cobra.Command {

exist, err := tidbSpec.Exist(clsName)
if err != nil {
return errors.AddStack(err)
return err
}

if exist {
Expand Down
6 changes: 2 additions & 4 deletions components/cluster/command/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ func init() {

colorutil.AddColorFunctionsForCobra()

// Initialize the global variables
flags.ShowBacktrace = len(os.Getenv("TIUP_BACKTRACE")) > 0
cobra.EnableCommandSorting = false

nativeEnvVar := strings.ToLower(os.Getenv(localdata.EnvNameNativeSSHClient))
Expand Down Expand Up @@ -136,8 +134,8 @@ func init() {
// start/stop operations is 90s, the default value of this argument is better be longer than that
rootCmd.PersistentFlags().Uint64Var(&gOpt.OptTimeout, "wait-timeout", 120, "Timeout in seconds to wait for an operation to complete, ignored for operations that don't fit.")
rootCmd.PersistentFlags().BoolVarP(&skipConfirm, "yes", "y", false, "Skip all confirmations and assumes 'yes'")
rootCmd.PersistentFlags().BoolVar(&gOpt.NativeSSH, "native-ssh", gOpt.NativeSSH, "Use the native SSH client installed on local system instead of the build-in one (experimental).")
rootCmd.PersistentFlags().StringVar((*string)(&gOpt.SSHType), "ssh", "", "(experimental) The executor type: 'builtin', 'system', 'none'.")
rootCmd.PersistentFlags().BoolVar(&gOpt.NativeSSH, "native-ssh", gOpt.NativeSSH, "(EXPERIMENTAL) Use the native SSH client installed on local system instead of the build-in one.")
rootCmd.PersistentFlags().StringVar((*string)(&gOpt.SSHType), "ssh", "", "(EXPERIMENTAL) The executor type: 'builtin', 'system', 'none'.")
_ = rootCmd.PersistentFlags().MarkHidden("native-ssh")

rootCmd.AddCommand(
Expand Down
2 changes: 1 addition & 1 deletion components/cluster/command/scale_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func newScaleOutCmd() *cobra.Command {
}

cmd.Flags().StringVarP(&opt.User, "user", "u", utils.CurrentUser(), "The user name to login via SSH. The user must has root (or sudo) privilege.")
cmd.Flags().BoolVarP(&opt.SkipCreateUser, "skip-create-user", "", false, "Skip creating the user specified in topology (experimental).")
cmd.Flags().BoolVarP(&opt.SkipCreateUser, "skip-create-user", "", false, "(EXPERIMENTAL) Skip creating the user specified in topology.")
cmd.Flags().StringVarP(&opt.IdentityFile, "identity_file", "i", opt.IdentityFile, "The path of the SSH identity file. If specified, public key authentication will be used.")
cmd.Flags().BoolVarP(&opt.UsePassword, "password", "p", false, "Use password of target hosts. If specified, password authentication will be used.")
cmd.Flags().BoolVarP(&opt.NoLabels, "no-labels", "", false, "Don't check TiKV labels")
Expand Down
2 changes: 1 addition & 1 deletion components/cluster/command/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func newTestCmd() *cobra.Command {

exist, err := tidbSpec.Exist(clusterName)
if err != nil {
return perrs.AddStack(err)
return err
}

if !exist {
Expand Down
30 changes: 15 additions & 15 deletions components/dm/ansible/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func searchConfigFile(dir string) (fname string, err error) {
func readConfigFile(dir string) (file *ini.File, err error) {
fname, err := searchConfigFile(dir)
if err != nil {
return nil, errors.AddStack(err)
return nil, err
}

file, err = ini.Load(fname)
Expand Down Expand Up @@ -205,7 +205,7 @@ func setConfig(config *map[string]interface{}, k string, v interface{}) {
func (im *Importer) handleWorkerConfig(srv *spec.WorkerSpec, fname string) error {
data, err := im.fetchFile(srv.Host, srv.SSHPort, fname)
if err != nil {
return errors.AddStack(err)
return err
}

config := new(Config)
Expand Down Expand Up @@ -255,7 +255,7 @@ func (im *Importer) ScpSourceToMaster(topo *spec.Specification) (err error) {

err = e.Transfer(f.Name(), filepath.Join(target, addr+".yml"), false)
if err != nil {
return errors.AddStack(err)
return err
}
}
}
Expand All @@ -278,7 +278,7 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad

cfg, err := readConfigFile(dir)
if err != nil {
return "", nil, errors.AddStack(err)
return "", nil, err
}

fname := filepath.Join(dir, inventoryFileName)
Expand Down Expand Up @@ -336,11 +336,11 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad
runFileName := filepath.Join(host.Vars["deploy_dir"], "scripts", "run_dm-master.sh")
data, err := im.fetchFile(srv.Host, srv.SSHPort, runFileName)
if err != nil {
return "", nil, errors.AddStack(err)
return "", nil, err
}
deployDir, flags, err := parseRunScript(data)
if err != nil {
return "", nil, errors.AddStack(err)
return "", nil, err
}

if deployDir == "" {
Expand Down Expand Up @@ -384,11 +384,11 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad
runFileName := filepath.Join(host.Vars["deploy_dir"], "scripts", "run_dm-worker.sh")
data, err := im.fetchFile(srv.Host, srv.SSHPort, runFileName)
if err != nil {
return "", nil, errors.AddStack(err)
return "", nil, err
}
deployDir, flags, err := parseRunScript(data)
if err != nil {
return "", nil, errors.AddStack(err)
return "", nil, err
}

if deployDir == "" {
Expand Down Expand Up @@ -427,7 +427,7 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad

err = im.handleWorkerConfig(&srv, configFileName)
if err != nil {
return "", nil, errors.AddStack(err)
return "", nil, err
}

topo.Workers = append(topo.Workers, srv)
Expand All @@ -445,12 +445,12 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad
runFileName := filepath.Join(host.Vars["deploy_dir"], "scripts", "run_prometheus.sh")
data, err := im.fetchFile(srv.Host, srv.SSHPort, runFileName)
if err != nil {
return "", nil, errors.AddStack(err)
return "", nil, err
}

deployDir, flags, err := parseRunScript(data)
if err != nil {
return "", nil, errors.AddStack(err)
return "", nil, err
}

if deployDir == "" {
Expand Down Expand Up @@ -493,12 +493,12 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad
runFileName := filepath.Join(host.Vars["deploy_dir"], "scripts", "run_alertmanager.sh")
data, err := im.fetchFile(srv.Host, srv.SSHPort, runFileName)
if err != nil {
return "", nil, errors.AddStack(err)
return "", nil, err
}

deployDir, flags, err := parseRunScript(data)
if err != nil {
return "", nil, errors.AddStack(err)
return "", nil, err
}

if deployDir == "" {
Expand Down Expand Up @@ -550,11 +550,11 @@ func (im *Importer) ImportFromAnsibleDir() (clusterName string, meta *spec.Metad
runFileName := filepath.Join(host.Vars["deploy_dir"], "scripts", "run_grafana.sh")
data, err := im.fetchFile(srv.Host, srv.SSHPort, runFileName)
if err != nil {
return "", nil, errors.AddStack(err)
return "", nil, err
}
_, flags, err := parseRunScript(data)
if err != nil {
return "", nil, errors.AddStack(err)
return "", nil, err
}

for k, v := range flags {
Expand Down
12 changes: 6 additions & 6 deletions components/dm/command/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ func newImportCmd() *cobra.Command {
Short: "Import an exist DM 1.0 cluster from dm-ansible and re-deploy 2.0 version",
RunE: func(cmd *cobra.Command, args []string) error {
if err := supportVersion(clusterVersion); err != nil {
return errors.AddStack(err)
return err
}

importer, err := ansible.NewImporter(ansibleDir, inventoryFileName, gOpt.SSHType, gOpt.SSHTimeout)
if err != nil {
return errors.AddStack(err)
return err
}

clusterName, meta, err := importer.ImportFromAnsibleDir()
if err != nil {
return errors.AddStack(err)
return err
}

if rename != "" {
Expand All @@ -58,7 +58,7 @@ func newImportCmd() *cobra.Command {

err = importer.ScpSourceToMaster(meta.Topology)
if err != nil {
return errors.AddStack(err)
return err
}

data, err := yaml.Marshal(meta.Topology)
Expand Down Expand Up @@ -86,7 +86,7 @@ func newImportCmd() *cobra.Command {
clusterName,
))
if err != nil {
return errors.AddStack(err)
return err
}
}

Expand All @@ -104,7 +104,7 @@ func newImportCmd() *cobra.Command {
)

if err != nil {
return errors.AddStack(err)
return err
}

return nil
Expand Down
9 changes: 4 additions & 5 deletions components/dm/command/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/pingcap/tiup/components/dm/spec"
"github.com/pingcap/tiup/pkg/cliutil"
"github.com/pingcap/tiup/pkg/cluster/executor"
"github.com/pingcap/tiup/pkg/cluster/flags"
"github.com/pingcap/tiup/pkg/cluster/manager"
operator "github.com/pingcap/tiup/pkg/cluster/operation"
cspec "github.com/pingcap/tiup/pkg/cluster/spec"
Expand Down Expand Up @@ -54,8 +53,6 @@ func init() {

colorutil.AddColorFunctionsForCobra()

// Initialize the global variables
flags.ShowBacktrace = len(os.Getenv("TIUP_BACKTRACE")) > 0
cobra.EnableCommandSorting = false

nativeEnvVar := strings.ToLower(os.Getenv(localdata.EnvNameNativeSSHClient))
Expand All @@ -64,8 +61,10 @@ func init() {
}

rootCmd = &cobra.Command{
Use: cliutil.OsArgs0(),
Short: "Deploy a DM cluster (experimental)",
Use: cliutil.OsArgs0(),
Short: "(EXPERIMENTAL) Deploy a DM cluster",
Long: `EXPERIMENTAL: This is an experimental feature, things may or may not work,
please backup your data before process.`,
SilenceUsage: true,
SilenceErrors: true,
Version: version.NewTiUPVersion().String(),
Expand Down
4 changes: 2 additions & 2 deletions components/dm/command/scale_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ func ScaleInDMCluster(
name := instance.(*dm.MasterInstance).Name
err := dmMasterClient.OfflineMaster(name, nil)
if err != nil {
return errors.AddStack(err)
return err
}
case dm.ComponentDMWorker:
name := instance.(*dm.WorkerInstance).Name
err := dmMasterClient.OfflineWorker(name, nil)
if err != nil {
return errors.AddStack(err)
return err
}
}

Expand Down
6 changes: 3 additions & 3 deletions components/playground/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func newDisplay() *cobra.Command {
func scaleIn(pids []int) error {
port, err := targetTag()
if err != nil {
return errors.AddStack(err)
return err
}

var cmds []Command
Expand All @@ -176,7 +176,7 @@ func scaleIn(pids []int) error {
func scaleOut(args []string, opt *bootOptions) (num int, err error) {
port, err := targetTag()
if err != nil {
return 0, errors.AddStack(err)
return 0, err
}

cmds := buildCommands(ScaleOutCommandType, opt)
Expand All @@ -191,7 +191,7 @@ func scaleOut(args []string, opt *bootOptions) (num int, err error) {
func display(args []string) error {
port, err := targetTag()
if err != nil {
return errors.AddStack(err)
return err
}
c := Command{
CommandType: DisplayCommandType,
Expand Down
Loading

0 comments on commit 3c98ed3

Please sign in to comment.