-
Notifications
You must be signed in to change notification settings - Fork 499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check PD enpoints status when it's unhealthy. #545
Changes from all commits
ddf6024
fddbcd9
4997aa9
5d523cd
e423318
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ type pdMemberManager struct { | |
setLister v1beta1.StatefulSetLister | ||
svcLister corelisters.ServiceLister | ||
podLister corelisters.PodLister | ||
epsLister corelisters.EndpointsLister | ||
podControl controller.PodControlInterface | ||
pvcLister corelisters.PersistentVolumeClaimLister | ||
pdScaler Scaler | ||
|
@@ -55,6 +56,7 @@ func NewPDMemberManager(pdControl controller.PDControlInterface, | |
setLister v1beta1.StatefulSetLister, | ||
svcLister corelisters.ServiceLister, | ||
podLister corelisters.PodLister, | ||
epsLister corelisters.EndpointsLister, | ||
podControl controller.PodControlInterface, | ||
pvcLister corelisters.PersistentVolumeClaimLister, | ||
pdScaler Scaler, | ||
|
@@ -68,6 +70,7 @@ func NewPDMemberManager(pdControl controller.PDControlInterface, | |
setLister, | ||
svcLister, | ||
podLister, | ||
epsLister, | ||
podControl, | ||
pvcLister, | ||
pdScaler, | ||
|
@@ -258,18 +261,27 @@ func (pmm *pdMemberManager) syncTidbClusterStatus(tc *v1alpha1.TidbCluster, set | |
|
||
pdClient := pmm.pdControl.GetPDClient(tc) | ||
|
||
cluster, err := pdClient.GetCluster() | ||
healthInfo, err := pdClient.GetHealth() | ||
if err != nil { | ||
tc.Status.PD.Synced = false | ||
// get endpoints info | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
so we should move these codes to https://github.com/pingcap/tidb-operator/pull/545/files#diff-006f391cd7cdae269e89bd77e21c1a6fR266 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, I think that it may be better to check health state at first, and check endpoints' status when it's unhealthy, just like the previous code. Here is what I think:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, i am fine with both orders. But these codes must be moved to the first method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for your patience! |
||
eps, epErr := pmm.epsLister.Endpoints(ns).Get(controller.PDMemberName(tcName)) | ||
if epErr != nil { | ||
return fmt.Errorf("%s, %s", err, epErr) | ||
} | ||
// pd service has no endpoints | ||
if eps != nil && len(eps.Subsets) == 0 { | ||
return fmt.Errorf("%s, service %s/%s has no endpoints", err, ns, controller.PDMemberName(tcName)) | ||
} | ||
return err | ||
} | ||
tc.Status.ClusterID = strconv.FormatUint(cluster.Id, 10) | ||
|
||
healthInfo, err := pdClient.GetHealth() | ||
cluster, err := pdClient.GetCluster() | ||
if err != nil { | ||
tc.Status.PD.Synced = false | ||
return err | ||
} | ||
tc.Status.ClusterID = strconv.FormatUint(cluster.Id, 10) | ||
leader, err := pdClient.GetPDLeader() | ||
if err != nil { | ||
tc.Status.PD.Synced = false | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you chage the order
pdClient.GetHealth()
andpdClient.GetCluster()
?If there is no special need, it is better to stay in the old order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It maybe more intuitive to check pd's health first, in my opinion. QAQ
Alright, I'll reset the order.