Skip to content

Commit

Permalink
Fix tikv ugprade process when local pd are down (#4427)
Browse files Browse the repository at this point in the history
  • Loading branch information
just1900 authored Feb 22, 2022
1 parent e424e60 commit 2493cf0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pkg/controller/pd_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"github.com/pingcap/tidb-operator/pkg/pdapi"
)

// GetPDClientFromService gets the pd client from the TidbCluster
func GetPDClientFromService(pdControl pdapi.PDControlInterface, tc *v1alpha1.TidbCluster) pdapi.PDClient {
// getPDClientFromService gets the pd client from the TidbCluster
func getPDClientFromService(pdControl pdapi.PDControlInterface, tc *v1alpha1.TidbCluster) pdapi.PDClient {
if tc.Heterogeneous() && tc.WithoutLocalPD() {
return pdControl.GetPDClient(pdapi.Namespace(tc.Spec.Cluster.Namespace), tc.Spec.Cluster.Name, tc.IsTLSClusterEnabled(),
pdapi.TLSCertFromTC(pdapi.Namespace(tc.GetNamespace()), tc.GetName()),
Expand All @@ -36,7 +36,7 @@ func GetPDClientFromService(pdControl pdapi.PDControlInterface, tc *v1alpha1.Tid
// ClientURL example:
// ClientURL: https://cluster2-pd-0.cluster2-pd-peer.pingcap.svc.cluster2.local
func GetPDClient(pdControl pdapi.PDControlInterface, tc *v1alpha1.TidbCluster) pdapi.PDClient {
pdClient := GetPDClientFromService(pdControl, tc)
pdClient := getPDClientFromService(pdControl, tc)

if len(tc.Status.PD.PeerMembers) == 0 {
return pdClient
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/pod_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (c *realPodControl) UpdateMetaInfo(tc *v1alpha1.TidbCluster, pod *corev1.Po
memberID := labels[label.MemberIDLabelKey]
storeID := labels[label.StoreIDLabelKey]

pdClient := GetPDClientFromService(c.pdControl, tc)
pdClient := GetPDClient(c.pdControl, tc)

if labels[label.ClusterIDLabelKey] == "" {
cluster, err := pdClient.GetCluster()
Expand Down
2 changes: 1 addition & 1 deletion pkg/manager/member/tikv_upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func endEvictLeaderbyStoreID(deps *controller.Dependencies, tc *v1alpha1.TidbClu
time.Sleep(5 * time.Second)
}

err := controller.GetPDClientFromService(deps.PDControl, tc).EndEvictLeader(storeID)
err := controller.GetPDClient(deps.PDControl, tc).EndEvictLeader(storeID)
if err != nil {
klog.Errorf("tikv: failed to end evict leader for store: %d of %s/%s, error: %v", storeID, tc.Namespace, tc.Name, err)
return err
Expand Down
4 changes: 2 additions & 2 deletions tests/failover.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (oa *OperatorActions) TruncateSSTFileThenCheckFailover(info *TidbClusterCon
}

// checkout pd config
pdCfg, err := controller.GetPDClientFromService(oa.pdControl, tc).GetConfig()
pdCfg, err := controller.GetPDClient(oa.pdControl, tc).GetConfig()
if err != nil {
log.Logf("ERROR: failed to get the pd config: tc=%s err=%s", info.ClusterName, err.Error())
return err
Expand Down Expand Up @@ -518,7 +518,7 @@ func (oa *OperatorActions) CheckRecover(cluster *TidbClusterConfig) (bool, error
// delete failover member store manually
if int32(len(tc.Status.TiKV.Stores)) > tc.Spec.TiKV.Replicas {

pdclient := controller.GetPDClientFromService(oa.pdControl, tc)
pdclient := controller.GetPDClient(oa.pdControl, tc)
for _, v := range tc.Status.TiKV.Stores {
ordinal, err := util.GetOrdinalFromPodName(v.PodName)
if err != nil {
Expand Down

0 comments on commit 2493cf0

Please sign in to comment.