Skip to content

Commit

Permalink
Replace glog with klog (pingcap#1805)
Browse files Browse the repository at this point in the history
  • Loading branch information
u5surf committed Feb 27, 2020
1 parent 4cbffa7 commit 590bf37
Show file tree
Hide file tree
Showing 96 changed files with 833 additions and 833 deletions.
6 changes: 3 additions & 3 deletions cmd/backup-manager/app/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"os/exec"

"github.com/gogo/protobuf/proto"
glog "k8s.io/klog"
"k8s.io/klog"

kvbackup "github.com/pingcap/kvproto/pkg/backup"
"github.com/pingcap/tidb-operator/cmd/backup-manager/app/constants"
Expand Down Expand Up @@ -54,12 +54,12 @@ func (bo *Options) backupData(backup *v1alpha1.Backup) (string, error) {
btype,
}
fullArgs = append(fullArgs, args...)
glog.Infof("Running br command with args: %v", fullArgs)
klog.Infof("Running br command with args: %v", fullArgs)
output, err := exec.Command("br", fullArgs...).CombinedOutput()
if err != nil {
return path, fmt.Errorf("cluster %s, execute br command %v failed, output: %s, err: %v", bo, fullArgs, string(output), err)
}
glog.Infof("Backup data for cluster %s successfully, output: %s", bo, string(output))
klog.Infof("Backup data for cluster %s successfully, output: %s", bo, string(output))
return path, nil
}

Expand Down
16 changes: 8 additions & 8 deletions cmd/backup-manager/app/backup/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/pingcap/tidb-operator/pkg/controller"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
glog "k8s.io/klog"
"k8s.io/klog"
)

// Manager mainly used to manage backup related work
Expand All @@ -48,7 +48,7 @@ func NewManager(
func (bm *Manager) ProcessBackup() error {
backup, err := bm.backupLister.Backups(bm.Namespace).Get(bm.BackupName)
if err != nil {
glog.Errorf("can't find cluster %s backup %s CRD object, err: %v", bm, bm.BackupName, err)
klog.Errorf("can't find cluster %s backup %s CRD object, err: %v", bm, bm.BackupName, err)
return bm.StatusUpdater.Update(backup, &v1alpha1.BackupCondition{
Type: v1alpha1.BackupFailed,
Status: corev1.ConditionTrue,
Expand Down Expand Up @@ -76,41 +76,41 @@ func (bm *Manager) performBackup(backup *v1alpha1.Backup) error {

backupFullPath, err := bm.backupData(backup)
if err != nil {
glog.Errorf("backup cluster %s data failed, err: %s", bm, err)
klog.Errorf("backup cluster %s data failed, err: %s", bm, err)
return bm.StatusUpdater.Update(backup, &v1alpha1.BackupCondition{
Type: v1alpha1.BackupFailed,
Status: corev1.ConditionTrue,
Reason: "BackupDataToRemoteFailed",
Message: err.Error(),
})
}
glog.Infof("backup cluster %s data to %s success", bm, backupFullPath)
klog.Infof("backup cluster %s data to %s success", bm, backupFullPath)

// Note: The size get from remote may be incorrect because the blobs
// are eventually consistent.
size, err := getBackupSize(backup)
if err != nil {
glog.Errorf("Get size for backup files in %s of cluster %s failed, err: %s", backupFullPath, bm, err)
klog.Errorf("Get size for backup files in %s of cluster %s failed, err: %s", backupFullPath, bm, err)
return bm.StatusUpdater.Update(backup, &v1alpha1.BackupCondition{
Type: v1alpha1.BackupFailed,
Status: corev1.ConditionTrue,
Reason: "GetBackupSizeFailed",
Message: err.Error(),
})
}
glog.Infof("Get size %d for backup files in %s of cluster %s success", size, backupFullPath, bm)
klog.Infof("Get size %d for backup files in %s of cluster %s success", size, backupFullPath, bm)

commitTs, err := getCommitTs(backup)
if err != nil {
glog.Errorf("get cluster %s commitTs failed, err: %s", bm, err)
klog.Errorf("get cluster %s commitTs failed, err: %s", bm, err)
return bm.StatusUpdater.Update(backup, &v1alpha1.BackupCondition{
Type: v1alpha1.BackupFailed,
Status: corev1.ConditionTrue,
Reason: "GetCommitTsFailed",
Message: err.Error(),
})
}
glog.Infof("get cluster %s commitTs %d success", bm, commitTs)
klog.Infof("get cluster %s commitTs %d success", bm, commitTs)

finish := time.Now()

Expand Down
2 changes: 1 addition & 1 deletion cmd/backup-manager/app/backup_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func Run() error {
logs.InitLogs()
defer logs.FlushLogs()

// fix glog parse error
// fix klog parse error
flag.CommandLine.Parse([]string{})

pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc)
Expand Down
8 changes: 4 additions & 4 deletions cmd/backup-manager/app/clean/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"io"
"os/exec"

glog "k8s.io/klog"
"k8s.io/klog"

"github.com/pingcap/tidb-operator/cmd/backup-manager/app/constants"
"github.com/pingcap/tidb-operator/cmd/backup-manager/app/util"
Expand Down Expand Up @@ -53,12 +53,12 @@ func (bo *Options) cleanBRRemoteBackupData(backup *v1alpha1.Backup) error {
if err != nil {
return err
}
glog.Infof("Prepare to delete %s for cluster %s", obj.Key, bo)
klog.Infof("Prepare to delete %s for cluster %s", obj.Key, bo)
err = s.Delete(context.Background(), obj.Key)
if err != nil {
return err
}
glog.Infof("Delete %s for cluster %s successfully", obj.Key, bo)
klog.Infof("Delete %s for cluster %s successfully", obj.Key, bo)
}
return nil
}
Expand All @@ -70,6 +70,6 @@ func (bo *Options) cleanRemoteBackupData(bucket string) error {
return fmt.Errorf("cluster %s, execute rclone deletefile command failed, output: %s, err: %v", bo, string(output), err)
}

glog.Infof("cluster %s backup %s was deleted successfully", bo, bucket)
klog.Infof("cluster %s backup %s was deleted successfully", bo, bucket)
return nil
}
8 changes: 4 additions & 4 deletions cmd/backup-manager/app/clean/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"fmt"

corev1 "k8s.io/api/core/v1"
glog "k8s.io/klog"
"k8s.io/klog"

"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1"
listers "github.com/pingcap/tidb-operator/pkg/client/listers/pingcap/v1alpha1"
Expand Down Expand Up @@ -55,7 +55,7 @@ func (bm *Manager) ProcessCleanBackup() error {

func (bm *Manager) performCleanBackup(backup *v1alpha1.Backup) error {
if backup.Status.BackupPath == "" {
glog.Errorf("cluster %s backup path is empty", bm)
klog.Errorf("cluster %s backup path is empty", bm)
return bm.StatusUpdater.Update(backup, &v1alpha1.BackupCondition{
Type: v1alpha1.BackupFailed,
Status: corev1.ConditionTrue,
Expand All @@ -72,7 +72,7 @@ func (bm *Manager) performCleanBackup(backup *v1alpha1.Backup) error {
}

if err != nil {
glog.Errorf("clean cluster %s backup %s failed, err: %s", bm, backup.Status.BackupPath, err)
klog.Errorf("clean cluster %s backup %s failed, err: %s", bm, backup.Status.BackupPath, err)
return bm.StatusUpdater.Update(backup, &v1alpha1.BackupCondition{
Type: v1alpha1.BackupFailed,
Status: corev1.ConditionTrue,
Expand All @@ -81,7 +81,7 @@ func (bm *Manager) performCleanBackup(backup *v1alpha1.Backup) error {
})
}

glog.Infof("clean cluster %s backup %s success", bm, backup.Status.BackupPath)
klog.Infof("clean cluster %s backup %s success", bm, backup.Status.BackupPath)
return bm.StatusUpdater.Update(backup, &v1alpha1.BackupCondition{
Type: v1alpha1.BackupClean,
Status: corev1.ConditionTrue,
Expand Down
4 changes: 2 additions & 2 deletions cmd/backup-manager/app/cmd/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/pingcap/tidb-operator/pkg/controller"
"github.com/spf13/cobra"
"k8s.io/client-go/tools/cache"
glog "k8s.io/klog"
"k8s.io/klog"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
)

Expand Down Expand Up @@ -63,7 +63,7 @@ func runBackup(backupOpts backup.Options, kubecfg string) error {
// waiting for the shared informer's store has synced.
cache.WaitForCacheSync(ctx.Done(), backupInformer.Informer().HasSynced)

glog.Infof("start to process backup %s", backupOpts.String())
klog.Infof("start to process backup %s", backupOpts.String())
bm := backup.NewManager(backupInformer.Lister(), statusUpdater, backupOpts)
return bm.ProcessBackup()
}
4 changes: 2 additions & 2 deletions cmd/backup-manager/app/cmd/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/pingcap/tidb-operator/pkg/controller"
"github.com/spf13/cobra"
"k8s.io/client-go/tools/cache"
glog "k8s.io/klog"
"k8s.io/klog"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
)

Expand Down Expand Up @@ -64,7 +64,7 @@ func runClean(backupOpts clean.Options, kubecfg string) error {
// waiting for the shared informer's store has synced.
cache.WaitForCacheSync(ctx.Done(), backupInformer.Informer().HasSynced)

glog.Infof("start to clean backup %s", backupOpts.String())
klog.Infof("start to clean backup %s", backupOpts.String())
bm := clean.NewManager(backupInformer.Lister(), statusUpdater, backupOpts)
return bm.ProcessCleanBackup()
}
4 changes: 2 additions & 2 deletions cmd/backup-manager/app/cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/pingcap/tidb-operator/pkg/controller"
"github.com/spf13/cobra"
"k8s.io/client-go/tools/cache"
glog "k8s.io/klog"
"k8s.io/klog"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
)

Expand Down Expand Up @@ -73,7 +73,7 @@ func runExport(backupOpts export.BackupOpts, kubecfg string) error {
// waiting for the shared informer's store has synced.
cache.WaitForCacheSync(ctx.Done(), backupInformer.Informer().HasSynced)

glog.Infof("start to process backup %s", backupOpts.String())
klog.Infof("start to process backup %s", backupOpts.String())
bm := export.NewBackupManager(backupInformer.Lister(), statusUpdater, backupOpts)
return bm.ProcessBackup()
}
4 changes: 2 additions & 2 deletions cmd/backup-manager/app/cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/pingcap/tidb-operator/pkg/controller"
"github.com/spf13/cobra"
"k8s.io/client-go/tools/cache"
glog "k8s.io/klog"
"k8s.io/klog"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
)

Expand Down Expand Up @@ -72,7 +72,7 @@ func runImport(restoreOpts _import.RestoreOpts, kubecfg string) error {
// waiting for the shared informer's store has synced.
cache.WaitForCacheSync(ctx.Done(), restoreInformer.Informer().HasSynced)

glog.Infof("start to process restore %s", restoreOpts.String())
klog.Infof("start to process restore %s", restoreOpts.String())
rm := _import.NewRestoreManager(restoreInformer.Lister(), statusUpdater, restoreOpts)
return rm.ProcessRestore()
}
4 changes: 2 additions & 2 deletions cmd/backup-manager/app/cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/pingcap/tidb-operator/pkg/controller"
"github.com/spf13/cobra"
"k8s.io/client-go/tools/cache"
glog "k8s.io/klog"
"k8s.io/klog"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
)

Expand Down Expand Up @@ -67,7 +67,7 @@ func runRestore(restoreOpts restore.Options, kubecfg string) error {
// waiting for the shared informer's store has synced.
cache.WaitForCacheSync(ctx.Done(), restoreInformer.Informer().HasSynced)

glog.Infof("start to process restore %s", restoreOpts.String())
klog.Infof("start to process restore %s", restoreOpts.String())
rm := restore.NewManager(restoreInformer.Lister(), statusUpdater, restoreOpts)
return rm.ProcessRestore()
}
4 changes: 2 additions & 2 deletions cmd/backup-manager/app/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"time"

"github.com/mholt/archiver"
glog "k8s.io/klog"
"k8s.io/klog"

"github.com/pingcap/tidb-operator/cmd/backup-manager/app/constants"
"github.com/pingcap/tidb-operator/cmd/backup-manager/app/util"
Expand Down Expand Up @@ -114,7 +114,7 @@ func (bo *BackupOpts) backupDataToRemote(source, bucketURI string) error {
return fmt.Errorf("cluster %s, execute rclone copyto command for upload backup data %s failed, output: %s, err: %v", bo, bucketURI, string(output), err)
}

glog.Infof("upload cluster %s backup data to %s successfully, now move it to permanent URL %s", bo, tmpDestBucket, destBucket)
klog.Infof("upload cluster %s backup data to %s successfully, now move it to permanent URL %s", bo, tmpDestBucket, destBucket)

// the backup was a success
// remove .tmp extension
Expand Down
Loading

0 comments on commit 590bf37

Please sign in to comment.