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

ebs br: check status of global nodes before doing data recovery #5243

Closed
wants to merge 1 commit into from
Closed
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
21 changes: 21 additions & 0 deletions pkg/apis/pingcap/v1alpha1/tidbcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,17 @@ func (tc *TidbCluster) PDAllMembersReady() bool {
return true
}

// PDAllPeerMembersReady return whether all peer members of PD are ready.
func (tc *TidbCluster) PDAllPeerMembersReady() bool {

for _, member := range tc.Status.PD.PeerMembers {
if !member.Health {
return false
}
}
return true
}

func (tc *TidbCluster) PDAutoFailovering() bool {
if len(tc.Status.PD.FailureMembers) == 0 {
return false
Expand Down Expand Up @@ -908,6 +919,16 @@ func (tc *TidbCluster) AllTiKVsAreAvailable() bool {
return true
}

func (tc *TidbCluster) AllPeerTiKVsAreAvailable() bool {
for _, store := range tc.Status.TiKV.PeerStores {
if store.State != TiKVStateUp {
return false
}
}

return true
}

func (tc *TidbCluster) PumpIsAvailable() bool {
lowerLimit := 1
if len(tc.Status.Pump.Members) < lowerLimit {
Expand Down
4 changes: 2 additions & 2 deletions pkg/backup/restore/restore_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ func (rm *restoreManager) syncRestoreJob(restore *v1alpha1.Restore) error {
}, nil)
return err
}
if !tc.PDAllMembersReady() {
if !tc.PDAllMembersReady() || !tc.PDAllPeerMembersReady() {
return controller.RequeueErrorf("restore %s/%s: waiting for all PD members are ready in tidbcluster %s/%s", ns, name, tc.Namespace, tc.Name)
}

if v1alpha1.IsRestoreVolumeComplete(restore) && !v1alpha1.IsRestoreTiKVComplete(restore) {
if !tc.AllTiKVsAreAvailable() {
if !tc.AllTiKVsAreAvailable() || !tc.AllPeerTiKVsAreAvailable() {
return controller.RequeueErrorf("restore %s/%s: waiting for all TiKVs are available in tidbcluster %s/%s", ns, name, tc.Namespace, tc.Name)
} else {
sel, err := label.New().Instance(tc.Name).TiKV().Selector()
Expand Down
Loading