Skip to content

Commit

Permalink
Fix bug use shareinformer without copy (pingcap#462)
Browse files Browse the repository at this point in the history
* use shareinformer without copy

* fix bug use shareinformer without copy in kv pd and svc
  • Loading branch information
shuijing198799 authored and weekface committed May 8, 2019
1 parent 0b220ea commit c8648e7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 6 additions & 2 deletions pkg/manager/member/pd_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (pmm *pdMemberManager) syncPDServiceForTidbCluster(tc *v1alpha1.TidbCluster
tcName := tc.GetName()

newSvc := pmm.getNewPDServiceForTidbCluster(tc)
oldSvc, err := pmm.svcLister.Services(ns).Get(controller.PDMemberName(tcName))
oldSvcTmp, err := pmm.svcLister.Services(ns).Get(controller.PDMemberName(tcName))
if errors.IsNotFound(err) {
err = SetServiceLastAppliedConfigAnnotation(newSvc)
if err != nil {
Expand All @@ -108,6 +108,8 @@ func (pmm *pdMemberManager) syncPDServiceForTidbCluster(tc *v1alpha1.TidbCluster
return err
}

oldSvc := oldSvcTmp.DeepCopy()

equal, err := serviceEqual(newSvc, oldSvc)
if err != nil {
return err
Expand Down Expand Up @@ -172,7 +174,7 @@ func (pmm *pdMemberManager) syncPDStatefulSetForTidbCluster(tc *v1alpha1.TidbClu
return err
}

oldPDSet, err := pmm.setLister.StatefulSets(ns).Get(controller.PDMemberName(tcName))
oldPDSetTmp, err := pmm.setLister.StatefulSets(ns).Get(controller.PDMemberName(tcName))
if err != nil && !errors.IsNotFound(err) {
return err
}
Expand All @@ -188,6 +190,8 @@ func (pmm *pdMemberManager) syncPDStatefulSetForTidbCluster(tc *v1alpha1.TidbClu
return controller.RequeueErrorf("TidbCluster: [%s/%s], waiting for PD cluster running", ns, tcName)
}

oldPDSet := oldPDSetTmp.DeepCopy()

if err := pmm.syncTidbClusterStatus(tc, oldPDSet); err != nil {
glog.Errorf("failed to sync TidbCluster: [%s/%s]'s status, error: %v", ns, tcName, err)
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/manager/member/tidb_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (tmm *tidbMemberManager) syncTiDBHeadlessServiceForTidbCluster(tc *v1alpha1
tcName := tc.GetName()

newSvc := tmm.getNewTiDBHeadlessServiceForTidbCluster(tc)
oldSvc, err := tmm.svcLister.Services(ns).Get(controller.TiDBPeerMemberName(tcName))
oldSvcTmp, err := tmm.svcLister.Services(ns).Get(controller.TiDBPeerMemberName(tcName))
if errors.IsNotFound(err) {
err = SetServiceLastAppliedConfigAnnotation(newSvc)
if err != nil {
Expand All @@ -108,6 +108,8 @@ func (tmm *tidbMemberManager) syncTiDBHeadlessServiceForTidbCluster(tc *v1alpha1
return err
}

oldSvc := oldSvcTmp.DeepCopy()

equal, err := serviceEqual(newSvc, oldSvc)
if err != nil {
return err
Expand All @@ -131,7 +133,7 @@ func (tmm *tidbMemberManager) syncTiDBStatefulSetForTidbCluster(tc *v1alpha1.Tid
tcName := tc.GetName()

newTiDBSet := tmm.getNewTiDBSetForTidbCluster(tc)
oldTiDBSet, err := tmm.setLister.StatefulSets(ns).Get(controller.TiDBMemberName(tcName))
oldTiDBSetTemp, err := tmm.setLister.StatefulSets(ns).Get(controller.TiDBMemberName(tcName))
if errors.IsNotFound(err) {
err = SetLastAppliedConfigAnnotation(newTiDBSet)
if err != nil {
Expand All @@ -144,6 +146,7 @@ func (tmm *tidbMemberManager) syncTiDBStatefulSetForTidbCluster(tc *v1alpha1.Tid
tc.Status.TiDB.StatefulSet = &apps.StatefulSetStatus{}
return nil
}
oldTiDBSet := oldTiDBSetTemp.DeepCopy()
if err != nil {
return err
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/manager/member/tikv_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (tkmm *tikvMemberManager) syncServiceForTidbCluster(tc *v1alpha1.TidbCluste
tcName := tc.GetName()

newSvc := tkmm.getNewServiceForTidbCluster(tc, svcConfig)
oldSvc, err := tkmm.svcLister.Services(ns).Get(svcConfig.MemberName(tcName))
oldSvcTmp, err := tkmm.svcLister.Services(ns).Get(svcConfig.MemberName(tcName))
if errors.IsNotFound(err) {
err = SetServiceLastAppliedConfigAnnotation(newSvc)
if err != nil {
Expand All @@ -133,6 +133,8 @@ func (tkmm *tikvMemberManager) syncServiceForTidbCluster(tc *v1alpha1.TidbCluste
return err
}

oldSvc := oldSvcTmp.DeepCopy()

equal, err := serviceEqual(newSvc, oldSvc)
if err != nil {
return err
Expand Down Expand Up @@ -162,7 +164,7 @@ func (tkmm *tikvMemberManager) syncStatefulSetForTidbCluster(tc *v1alpha1.TidbCl
return err
}

oldSet, err := tkmm.setLister.StatefulSets(ns).Get(controller.TiKVMemberName(tcName))
oldSetTmp, err := tkmm.setLister.StatefulSets(ns).Get(controller.TiKVMemberName(tcName))
if err != nil && !errors.IsNotFound(err) {
return err
}
Expand All @@ -179,6 +181,8 @@ func (tkmm *tikvMemberManager) syncStatefulSetForTidbCluster(tc *v1alpha1.TidbCl
return nil
}

oldSet := oldSetTmp.DeepCopy()

if err := tkmm.syncTidbClusterStatus(tc, oldSet); err != nil {
return err
}
Expand Down

0 comments on commit c8648e7

Please sign in to comment.