Skip to content

Commit

Permalink
ebs br: check status globals for PD and TiKV nodes
Browse files Browse the repository at this point in the history
Signed-off-by: BornChanger <[email protected]>
  • Loading branch information
BornChanger committed Aug 14, 2023
1 parent 0eefbb8 commit 5426375
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
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

0 comments on commit 5426375

Please sign in to comment.