Skip to content

Commit

Permalink
tasks: print error to log after fail. (pingcap#310)
Browse files Browse the repository at this point in the history
* tasks: print error to log after fail.

* Update restore.go

Co-authored-by: 3pointer <[email protected]>
  • Loading branch information
YuJuncen and 3pointer authored May 28, 2020
1 parent 428dcb7 commit 1edbe26
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
14 changes: 12 additions & 2 deletions cmd/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
package cmd

import (
"github.com/pingcap/log"
"github.com/pingcap/tidb/ddl"
"github.com/pingcap/tidb/session"
"github.com/spf13/cobra"
"go.uber.org/zap"

"github.com/pingcap/br/pkg/gluetikv"
"github.com/pingcap/br/pkg/summary"
Expand All @@ -19,7 +21,11 @@ func runBackupCommand(command *cobra.Command, cmdName string) error {
command.SilenceUsage = false
return err
}
return task.RunBackup(GetDefaultContext(), tidbGlue, cmdName, &cfg)
if err := task.RunBackup(GetDefaultContext(), tidbGlue, cmdName, &cfg); err != nil {
log.Error("failed to backup", zap.Error(err))
return err
}
return nil
}

func runBackupRawCommand(command *cobra.Command, cmdName string) error {
Expand All @@ -28,7 +34,11 @@ func runBackupRawCommand(command *cobra.Command, cmdName string) error {
command.SilenceUsage = false
return err
}
return task.RunBackupRaw(GetDefaultContext(), gluetikv.Glue{}, cmdName, &cfg)
if err := task.RunBackupRaw(GetDefaultContext(), gluetikv.Glue{}, cmdName, &cfg); err != nil {
log.Error("failed to backup raw kv", zap.Error(err))
return err
}
return nil
}

// NewBackupCommand return a full backup subcommand.
Expand Down
20 changes: 17 additions & 3 deletions cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
package cmd

import (
"github.com/pingcap/log"
"github.com/pingcap/tidb/session"
"github.com/spf13/cobra"
"go.uber.org/zap"

"github.com/pingcap/br/pkg/gluetikv"
"github.com/pingcap/br/pkg/summary"
Expand All @@ -18,7 +20,11 @@ func runRestoreCommand(command *cobra.Command, cmdName string) error {
command.SilenceUsage = false
return err
}
return task.RunRestore(GetDefaultContext(), tidbGlue, cmdName, &cfg)
if err := task.RunRestore(GetDefaultContext(), tidbGlue, cmdName, &cfg); err != nil {
log.Error("failed to restore", zap.Error(err))
return err
}
return nil
}

func runRestoreRawCommand(command *cobra.Command, cmdName string) error {
Expand All @@ -29,7 +35,11 @@ func runRestoreRawCommand(command *cobra.Command, cmdName string) error {
command.SilenceUsage = false
return err
}
return task.RunRestoreRaw(GetDefaultContext(), gluetikv.Glue{}, cmdName, &cfg)
if err := task.RunRestoreRaw(GetDefaultContext(), gluetikv.Glue{}, cmdName, &cfg); err != nil {
log.Error("failed to restore raw kv", zap.Error(err))
return err
}
return nil
}

func runRestoreTiflashReplicaCommand(command *cobra.Command, cmdName string) error {
Expand All @@ -39,7 +49,11 @@ func runRestoreTiflashReplicaCommand(command *cobra.Command, cmdName string) err
return err
}

return task.RunRestoreTiflashReplica(GetDefaultContext(), tidbGlue, cmdName, &cfg)
if err := task.RunRestoreTiflashReplica(GetDefaultContext(), tidbGlue, cmdName, &cfg); err != nil {
log.Error("failed to restore tiflash replica", zap.Error(err))
return err
}
return nil
}

// NewRestoreCommand returns a restore subcommand.
Expand Down

0 comments on commit 1edbe26

Please sign in to comment.