Skip to content

Commit

Permalink
fix parallel upgrade bug (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaojingchen authored and tennix committed Oct 13, 2018
1 parent 29fd1d1 commit ab25cdd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
12 changes: 6 additions & 6 deletions pkg/manager/member/pd_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,12 @@ func (pmm *pdMemberManager) syncTidbClusterStatus(tc *v1alpha1.TidbCluster, set

tc.Status.PD.StatefulSet = &set.Status

if statefulSetIsUpgrading(set) {
tc.Status.PD.Phase = v1alpha1.UpgradePhase
} else {
tc.Status.PD.Phase = v1alpha1.NormalPhase
}

pdClient := pmm.pdControl.GetPDClient(tc)
healthInfo, err := pdClient.GetHealth()
if err != nil {
Expand Down Expand Up @@ -308,12 +314,6 @@ func (pmm *pdMemberManager) syncTidbClusterStatus(tc *v1alpha1.TidbCluster, set
tc.Status.PD.Members = pdStatus
tc.Status.PD.Leader = tc.Status.PD.Members[leader.GetName()]

if statefulSetIsUpgrading(set) {
tc.Status.PD.Phase = v1alpha1.UpgradePhase
} else {
tc.Status.PD.Phase = v1alpha1.NormalPhase
}

return nil
}

Expand Down
11 changes: 6 additions & 5 deletions pkg/manager/member/tidb_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ func (tmm *tidbMemberManager) getNewTiDBSetForTidbCluster(tc *v1alpha1.TidbClust
func (tmm *tidbMemberManager) syncTidbClusterStatus(tc *v1alpha1.TidbCluster, set *apps.StatefulSet) error {
tc.Status.TiDB.StatefulSet = &set.Status

if statefulSetIsUpgrading(set) {
tc.Status.TiDB.Phase = v1alpha1.UpgradePhase
} else {
tc.Status.TiDB.Phase = v1alpha1.NormalPhase
}

tidbStatus := map[string]v1alpha1.TiDBMember{}
tidbHealth := tmm.tidbControl.GetHealth(tc)
for name, health := range tidbHealth {
Expand All @@ -352,10 +358,5 @@ func (tmm *tidbMemberManager) syncTidbClusterStatus(tc *v1alpha1.TidbCluster, se
}
tc.Status.TiDB.Members = tidbStatus

if statefulSetIsUpgrading(set) {
tc.Status.TiDB.Phase = v1alpha1.UpgradePhase
} else {
tc.Status.TiDB.Phase = v1alpha1.NormalPhase
}
return nil
}
24 changes: 14 additions & 10 deletions pkg/manager/member/tikv_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,20 @@ func (tkmm *tikvMemberManager) syncTidbClusterStatus(tc *v1alpha1.TidbCluster, s

tc.Status.TiKV.StatefulSet = &set.Status

if statefulSetIsUpgrading(set) {
tc.Status.TiKV.Phase = v1alpha1.UpgradePhase
} else {
tc.Status.TiKV.Phase = v1alpha1.NormalPhase
}

exist, err := tkmm.evictSchedulerExists(tc)
if err != nil {
return err
}
if exist {
tc.Status.TiKV.Phase = v1alpha1.UpgradePhase
}

previousStores := tc.Status.TiKV.Stores
stores := map[string]v1alpha1.TiKVStore{}
tombstoneStores := map[string]v1alpha1.TiKVStore{}
Expand Down Expand Up @@ -505,16 +519,6 @@ func (tkmm *tikvMemberManager) syncTidbClusterStatus(tc *v1alpha1.TidbCluster, s
tc.Status.TiKV.Stores = stores
tc.Status.TiKV.TombstoneStores = tombstoneStores

exist, err := tkmm.evictSchedulerExists(tc)
if err != nil {
return err
}
if statefulSetIsUpgrading(set) || exist {
tc.Status.TiKV.Phase = v1alpha1.UpgradePhase
} else {
tc.Status.TiKV.Phase = v1alpha1.NormalPhase
}

return nil
}

Expand Down

0 comments on commit ab25cdd

Please sign in to comment.