-
Notifications
You must be signed in to change notification settings - Fork 176
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
chore: support leave member by using any pods #7890
Conversation
This branch name is not following the standards: feature/|bugfix/|release/|hotfix/|support/|releasing/|dependabot/ |
// For the purpose of upgrade compatibility, if the version of Lorry is 0.7 and | ||
// the version of KB is upgraded to 0.8 or newer, lorry client will return an NotImplemented error, | ||
// in this case, here just ignore it. | ||
if err2 == lorry.NotImplemented { | ||
r.reqCtx.Log.Info("lorry leave member api is not implemented") | ||
} else if unableToConnect(err2) { |
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.
When a pod is pending, new lorry clients may encounter issues. This situation can also be resolved here.
// remove current member from db cluster | ||
err = manager.LeaveMemberFromCluster(ctx, cluster, manager.GetCurrentMemberName()) | ||
// remove member from db cluster, the member may be other pod, depending on if podName is assigned in req.Parameters | ||
err = manager.LeaveMemberFromCluster(ctx, cluster, memberNameToLeave) |
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.
This change in the API can be reflected in the DBManager interface.
if err2 := lorryCli.LeaveMember(r.reqCtx.Ctx, nil); err2 != nil { | ||
// For the purpose of upgrade compatibility, if the version of Lorry is 0.7 and | ||
// the version of KB is upgraded to 0.8 or newer, lorry client will return an NotImplemented error, | ||
// in this case, here just ignore it. | ||
if err2 == lorry.NotImplemented { | ||
r.reqCtx.Log.Info("lorry leave member api is not implemented") | ||
} else if unableToConnect(err2) { | ||
r.reqCtx.Log.Info(fmt.Sprintf("when leaving pod %s by lorry, can not connect lorry on pod %s, try to leave member by other pods", pod.Name, pod.Name)) | ||
err3 := r.leaveMemberByOtherPods(desiredPods, pod) | ||
if err == nil { | ||
err = err3 | ||
} |
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.
re-org lorryCli.LeaveMember
, unableToConnect
and r.leaveMemberByOtherPods
into one single method of r
seems more readable.
This branch name is not following the standards: feature/|bugfix/|release/|hotfix/|support/|releasing/|dependabot/ |
fixed #7753 |
parameters["podName"] = podToLeave.Spec.Hostname | ||
|
||
for _, pod := range desiredPods { | ||
lorryCli, err1 := lorry.NewClient(*pod) |
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 should follow the API definition, otherwise there will be risks in executing the action on other pods.
related issue: #7753