Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

br: add some log to record the CR we are processing (#5711) #5712

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cmd/backup-manager/app/backup/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
errorutils "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/klog/v2"
)
Expand Down Expand Up @@ -95,6 +96,13 @@ func (bm *Manager) ProcessBackup() error {
return errorutils.NewAggregate(errs)
}

crData, err := json.Marshal(backup)
if err != nil {
klog.Errorf("failed to marshal backup %v to json, err: %v", backup, err)
} else {
klog.Infof("start to process backup: %s", string(crData))
}

// we treat snapshot backup as restarted if its status is not scheduled when backup pod just start to run
// we will clean backup data before run br command
if backup.Spec.Mode == v1alpha1.BackupModeSnapshot && (backup.Status.Phase != v1alpha1.BackupScheduled || v1alpha1.IsBackupRestart(backup)) {
Expand Down Expand Up @@ -122,6 +130,9 @@ func (bm *Manager) ProcessBackup() error {
return bm.performBackup(ctx, backup.DeepCopy(), nil)
}

klog.Infof("start to connect to tidb server (%s:%d) as the .spec.from field is specified",
backup.Spec.From.Host, backup.Spec.From.Port)

// validate and create from db
var db *sql.DB
db, err = bm.validateAndCreateFromDB(ctx, backup.DeepCopy())
Expand Down
8 changes: 8 additions & 0 deletions cmd/backup-manager/app/export/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
errorutils "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/klog/v2"
)
Expand Down Expand Up @@ -99,6 +100,13 @@ func (bm *BackupManager) ProcessBackup() error {
return errorutils.NewAggregate(errs)
}

crData, err := json.Marshal(backup)
if err != nil {
klog.Errorf("failed to marshal backup %v to json, err: %v", backup, err)
} else {
klog.Infof("start to process backup: %s", string(crData))
}

reason, err := bm.setOptions(backup)
if err != nil {
errs = append(errs, err)
Expand Down
8 changes: 8 additions & 0 deletions cmd/backup-manager/app/import/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
errorutils "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/klog/v2"
)

Expand Down Expand Up @@ -87,6 +88,13 @@ func (rm *RestoreManager) ProcessRestore() error {
return errorutils.NewAggregate(errs)
}

crData, err := json.Marshal(restore)
if err != nil {
klog.Errorf("failed to marshal restore %v to json, err: %s", restore, err)
} else {
klog.Infof("start to process restore: %s", string(crData))
}

rm.setOptions(restore)

return rm.performRestore(ctx, restore.DeepCopy())
Expand Down
11 changes: 11 additions & 0 deletions cmd/backup-manager/app/restore/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
errorutils "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/klog/v2"
)
Expand Down Expand Up @@ -96,12 +97,22 @@ func (rm *Manager) ProcessRestore() error {
return fmt.Errorf("no br config in %s", rm)
}

crData, err := json.Marshal(restore)
if err != nil {
klog.Errorf("failed to marshal restore %v to json, err: %s", restore, err)
} else {
klog.Infof("start to process restore: %s", string(crData))
}

if restore.Spec.To == nil {
return rm.performRestore(ctx, restore.DeepCopy(), nil)
}

rm.setOptions(restore)

klog.Infof("start to connect to tidb server (%s:%d) as the .spec.to field is specified",
restore.Spec.To.Host, restore.Spec.To.Port)

var db *sql.DB
var dsn string
err = wait.PollImmediate(constants.PollInterval, constants.CheckTimeout, func() (done bool, err error) {
Expand Down
Loading