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
Fix support for multiple pvc for pd #3820
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3820 +/- ##
==========================================
- Coverage 68.72% 67.77% -0.95%
==========================================
Files 173 173
Lines 18452 18448 -4
==========================================
- Hits 12681 12503 -178
- Misses 4667 4848 +181
+ Partials 1104 1097 -7
|
pkg/util/util.go
Outdated
} | ||
pvcs = append(pvcs, pvc) | ||
} | ||
} | ||
if len(pvcs) == 0 { | ||
return nil, errors.NewNotFound(corev1.Resource("pvc"), pod.Name) | ||
err := errors.NewNotFound(corev1.Resource("pvc"), "") |
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.
Refer to the comment here https://github.com/pingcap/tidb-operator/pull/3816/files#r587978537.
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.
details are fixed in the next line
Co-authored-by: DanielZhangQD <36026334+DanielZhangQD@users.noreply.github.com>
@@ -686,8 +722,12 @@ func oneFailureMember(tc *v1alpha1.TidbCluster) { | |||
pd0: {Name: pd0, ID: "0", Health: true}, | |||
pd2: {Name: pd2, ID: "2", Health: true}, | |||
} | |||
|
|||
pvcUIDSet := make(map[types.UID]struct{}) |
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 indicates that the failure member pd1
has 2 mounted PVCs as is set in the test function.
@@ -724,8 +764,12 @@ func oneNotReadyMemberAndAFailureMember(tc *v1alpha1.TidbCluster) { | |||
pd1: {Name: pd1, ID: "12891273174085095651", Health: false, LastTransitionTime: metav1.Time{Time: time.Now().Add(-10 * time.Minute)}}, | |||
pd2: {Name: pd2, ID: "2", Health: true}, | |||
} | |||
|
|||
pvcUIDSet := make(map[types.UID]struct{}) |
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.
Please make sure the code changes in pd_failover.go are fully covered.
Co-authored-by: DanielZhangQD <36026334+DanielZhangQD@users.noreply.github.com>
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.
LGTM
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.
LGTM
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by writing |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 3f7fa0b
|
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-1.1 in PR #3837 |
What problem does this PR solve?
ref: #3802
What is changed and how does it work?
Change pd related code to support multiple pvc from pod spec, instead of constructing a single pvc name from tc name and ordinal.
Similar to #3816.
Code changes
Tests
Unit test
E2E test
Manual test
Scalar Test
kubectl get pvc
pd-basic-pd-3
andpd-additional-basic-pd-3
has changed, because the old PVCs are deleted and new ones are created with the same name. we can tell from the differentVOLUME
name.Failover Test
kubectl get pvc
basic-pd-0
with wrong image usingkubectl patch pod basic-pd-0 --patch '{"spec": {"containers": [{"name": "pd", "image": "bad"}]}}'
. then check pod status withkubectl get pod
, and find thatbasic-pd-0
is inErrImagePull
status.basic-pd-3
is created, which is the failover operation. then Podbasic-pd-0
and its mounted PVCs are deleted, and recreated by StatefulSet controller. thenbasic-pd-3
is deleted, which is the recover operation. we can check bykubectl describe tc basic
and find that thebasic-pd-3
is in the unjoined member list.basic-pd-0
bykubectl get pvc
. note that the UIDs are changed forpd-basic-pd-0
andpd-additional-basic-pd-0
.kubectl get tc -o yaml | grep -i unjoinedmembers -A 10
, and find out that PD memberbasic-pd-3
has joined the PD cluster and now is in the unjoinedMembers list. Also note that thepvcUID
is the same aspd-basic-pd-3
.No code
Side effects
Related changes
Release Notes
Please refer to Release Notes Language Style Guide before writing the release note.