Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
3pointer committed Sep 2, 2022
1 parent 45fc143 commit 64319d7
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions br/pkg/task/restore_ebs_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,25 +173,8 @@ func (h *restoreEBSMetaHelper) preRestore(ctx context.Context) error {
}
h.metaInfo = metaInfo

// stop scheduler before recover data
log.Info("starting to remove some PD schedulers")
restoreFunc, e := h.pdc.RemoveAllPDSchedulers(ctx)
if e != nil {
return errors.Trace(err)
}
defer func() {
if ctx.Err() != nil {
log.Warn("context canceled, doing clean work with background context")
ctx = context.Background()
}
if restoreE := restoreFunc(ctx); restoreE != nil {
log.Warn("failed to restore removed schedulers, you may need to restore them manually", zap.Error(restoreE))
}
}()

// todo: check whether target cluster is compatible with the backup
// but cluster hasn't bootstrapped, we cannot get cluster version from pd now.

return nil
}

Expand Down Expand Up @@ -228,6 +211,22 @@ func (h *restoreEBSMetaHelper) restore() error {
return errors.Trace(err)
}

// stop scheduler before recover data
log.Info("starting to remove some PD schedulers")
restoreFunc, e := h.pdc.RemoveAllPDSchedulers(ctx)
if e != nil {
return errors.Trace(err)
}
defer func() {
if ctx.Err() != nil {
log.Warn("context canceled, doing clean work with background context")
ctx = context.Background()
}
if restoreE := restoreFunc(ctx); restoreE != nil {
log.Warn("failed to restore removed schedulers, you may need to restore them manually", zap.Error(restoreE))
}
}()

storeCount := h.metaInfo.GetStoreCount()
progress := h.g.StartProgress(ctx, h.cmdName, int64(storeCount), !h.cfg.LogProgress)
defer progress.Close()
Expand Down

0 comments on commit 64319d7

Please sign in to comment.