-
Notifications
You must be signed in to change notification settings - Fork 498
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
Add Volume Replacement feature with support for pd, tidb, tikv #5150
Conversation
Welcome @anish-db! It looks like this is your first PR to pingcap/tidb-operator 🎉 |
a27ac67
to
b86f219
Compare
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.
Hi @anish-db, thanks for your patience! I had an initial round of review, I'm still reading into the details but I don't want to put you in the wait for so long. Maybe we can start from these initial comments before I finish the review entirely? And don't hesitate to let me know if you have some different ideas in these comments, thanks!
// If desired sc name is unspecified , any sc used by pvc is okay. (Default storage class). | ||
if desiredScName != "" && ignoreNil(pvc.Spec.StorageClassName) != desiredScName { |
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.
Should we also return true
if desiredScName is set to empty string? If let's say a sc name is changed from a non-empty sc name to the empty string, I think user's intention is to switch from the original sc to the default sc, right? And maybe we should propagate the sc name to 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.
If desiredScName is blank, the pvc storage class will still not be blank but use whatever is the default storage class configured in the k8s cluster. It is a little tricky to find out which is default and use it to compare because the default might change later and trigger a change in disks with operator.
Existing pvc modifier also uses this behaviour (ignore changes if desired sc is blank), e.g.:
tidb-operator/pkg/manager/volumes/phase.go
Line 200 in 899409c
if cur != "" && pre != cur { |
if scName != "" && oldSc != scName { |
So I think safer behavior is to not change storage class if it is not explicitly specified.
/test pull-e2e-kind |
@csuzhangxc: The label(s) In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
@csuzhangxc: No presubmit jobs available for pingcap/tidb-operator@master In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/test pull-e2e-kind |
@csuzhangxc: The label(s) In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
@csuzhangxc: No presubmit jobs available for pingcap/tidb-operator@master In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
This comment was marked as outdated.
This comment was marked as outdated.
@hanlins: The label(s) In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
@hanlins: No presubmit jobs available for pingcap/tidb-operator@master In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/test pull-e2e-kind |
@hanlins: The label(s) In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
@hanlins: No presubmit jobs available for pingcap/tidb-operator@master In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hanlins The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
/cherry-pick release-1.5 |
@csuzhangxc: The label(s) In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
@csuzhangxc: new pull request created to branch In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
#5274) Co-authored-by: Anish Shankar <[email protected]> Co-authored-by: csuzhangxc <[email protected]>
What problem does this PR solve?
Implement a generic feature to make volume changes to tidb via replacement.
Detects volume changes (storageclass change, size change, or number of volumes change)
Notably change in number of volumes such as adding a separate TiKV raft disk is poorly handled by operator today.
Deletes replicas one by one and replaces with new disks that use the new volume parameters in a graceful way similar to how scale in is implemented for components today. (e.g for TiKV it deletes stores and waits for transition).
Adds one spare replica (for PD & TiKV) for handling load while the current one is being deleted.
PR Implements support for TiDB, PD, TiKV components.
More details of problem described in https://docs.google.com/document/d/1WpAYVcF1fXpcuVH6mFlz9v0fbLG3EA9r2gsDgFdqW8E/edit#heading=h.sv3296iop7bh
What is changed and how does it work?
Detailed List of changes:
pod_vol_modifier.go
&pvc_modifier.go
in tovol_compare_utils.go
for reuse in this feature as well as some new functions to compare volume changes in pods, etc.tidb.pingcap.com/replace-disk
annotation that can be used to trigger a pvc replace implemented inpkg/controller/tidbcluster/pod_control.go
.UpdateStatus()
&Sync()
tidb_cluster_control.go
UpdateStatus()
is run before component member manager syncs, andSync()
is run after.UpdateStatus()
is responsible for detecting storage volume changes and sets theVolReplaceInProgress
status field for the respective component.VolReplaceInProgress
is set:Sync()
waits until scaling is complete, then deletes statefulset orphaning pods & waits for member manager to recreate it (with new config), then applies thetidb.pingcap.com/replace-disk
annotation to each pod one by one.tidb.pingcap.com/tikv-no-active-store-since
annotation for TiKV pods (set by pkg/controller/pod_control.go) when a TiKV pod has a valid store id in label but no active stores from PD (via status tikv stores fields). Used to detect Tombstone stores that have been GC'ed too soon (due to a potential PD early GC race when stores are deleted immediately after creation)MetaManager.Sync()
intidb_cluster_control.go
which sets tikv store labels to run before component member manager Sync's so that label is updated, even if member managers error.Code changes
Tests
Side effects
Related changes
Release Notes
Please refer to Release Notes Language Style Guide before writing the release note.
Manual Test
Here's a procedure to manually test this feature on a test cluster:
Enable feature by setting
features: [VolumeReplacing=true]
incharts/tidb-operator/values.yaml
Start a local operator using
./hack/local-up-operator.sh
Apply the basic tidb cluster but with 3 tikv replicas:
Once cluster is up, apply an update adding a second volume with a config change to be rolled out atomically:
Verify that new temporary tikv replica is created, new volumes created by deleting & replace, and spare replica cleaned up.
Takes about ~10min for test cluster.