Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
KanShiori committed Feb 10, 2023
1 parent d1a445f commit 3ea0114
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pkg/manager/member/tikv_upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,24 +295,23 @@ func (u *tikvUpgrader) endEvictLeaderAfterUpgrade(tc *v1alpha1.TidbCluster, pod
// refer to https://github.com/pingcap/tiup/pull/2051

isLeaderTransferBackOrTimeout := func() bool {
leaderCountBefore := int(*store.LeaderCountBeforeUpgrade)
if leaderCountBefore < 200 {
klog.Infof("%s: leader count is %d and less than 200, so skip waiting leaders for transfer back", logPrefix, leaderCountBefore)
return true
}

evictLeaderEndTimeStr, exist := pod.Annotations[annoKeyEvictLeaderEndTime]
if !exist {
klog.Errorf("%s: miss annotation %q, so skip waiting leaders for transfer back", logPrefix, annoKeyEvictLeaderEndTime)
return true
}

evictLeaderEndTime, err := time.Parse(time.RFC3339, evictLeaderEndTimeStr)
if err != nil {
klog.Errorf("%s: parse annotation %q to time failed, so skip waiting leaders for transfer back", logPrefix, annoKeyEvictLeaderEndTime)
return true
}

leaderCountBefore := int(*store.LeaderCountBeforeUpgrade)
if leaderCountBefore < 200 {
klog.Infof("%s: leader count is %d and less than 200, so skip waiting leaders for transfer back", logPrefix, leaderCountBefore)
return true
}

timeout := tc.TiKVWaitLeaderTransferBackTimeout()
if time.Now().After(evictLeaderEndTime.Add(timeout)) {
klog.Infof("%s: time out with threshold %v, so skip waiting leaders for transfer back", logPrefix, timeout)
Expand Down

0 comments on commit 3ea0114

Please sign in to comment.