pingcap / tidb-operator

TiDB operator creates and manages TiDB clusters running in Kubernetes.
https://docs.pingcap.com/tidb-in-kubernetes/
Apache License 2.0
1.2k stars 490 forks source link

Add support to customize spare replicas during VolumeReplace (#5666) #5674

Closed ti-chi-bot closed 1 week ago

ti-chi-bot commented 1 week ago

This is an automated cherry-pick of #5666

What problem does this PR solve?

Currently the VolumeReplace feature assumes a default spare replica of 1 for PD & TiKV. Sometimes it is useful to change this number. Setting a larger spare replica number helps for faster tikv region transfer In multi-az setups, it is possible to get zone skewness with only a single replica, which will cause issues during scale down of spare replica.

Example multi-az senario: 3 zones , 6 replicas, initial zones per replica: 1,2,3,1,2,3 After adding 1 spare replica: 1,2,3,1,2,3,1 Now replace will start replacing from start, but now the new disks can get different zones, example: after replacing first disk it could now become 2,2,3,1,2,3,1 After this if we scale down the spare replica (last one), it will become 2,2,3,1,2,3 which is zone-skewed and can be blocked depending on configured topology constraints.

In this case setting spareReplicas to 3 will avoid this issue

What is changed and how does it work?

Add a config option in TidbCluster spec, inside TiKVSpec and PDSpec to configure spare replicas

Code changes

Tests

Re ran the manual test described in : https://github.com/pingcap/tidb-operator/pull/5150 Ran once as it is, and observed default spare replica of 1 was used. Ran once by setting tikv spare replicas to 3, and observed 3 spare replicas was used

Side effects

Related changes

Release Notes

Please refer to Release Notes Language Style Guide before writing the release note.

VolumeReplace feature now supports customizing the number of spare replicas used during TiKV or PD disk replacements inside the TidbCluster spec.
ti-chi-bot[bot] commented 1 week ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please ask for approval from csuzhangxc, ensuring that each of them provides their approval before proceeding. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/pingcap/tidb-operator/blob/release-1.5/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment