Skip to content

Commit

Permalink
tc level flag to enablePVCReplace feature (#5670)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajsuvariya authored Jun 27, 2024
1 parent 2bc2eee commit dfd5ac2
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 2 deletions.
26 changes: 26 additions & 0 deletions docs/api-references/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1984,6 +1984,19 @@ Optional: Defaults to false</p>
</tr>
<tr>
<td>
<code>enablePVCReplace</code></br>
<em>
bool
</em>
</td>
<td>
<em>(Optional)</em>
<p>Whether enable PVC replace to recreate the PVC with different specs
Optional: Defaults to false</p>
</td>
</tr>
<tr>
<td>
<code>tlsCluster</code></br>
<em>
<a href="#tlscluster">
Expand Down Expand Up @@ -24403,6 +24416,19 @@ Optional: Defaults to false</p>
</tr>
<tr>
<td>
<code>enablePVCReplace</code></br>
<em>
bool
</em>
</td>
<td>
<em>(Optional)</em>
<p>Whether enable PVC replace to recreate the PVC with different specs
Optional: Defaults to false</p>
</td>
</tr>
<tr>
<td>
<code>tlsCluster</code></br>
<em>
<a href="#tlscluster">
Expand Down
2 changes: 2 additions & 0 deletions manifests/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22150,6 +22150,8 @@ spec:
type: string
enableDynamicConfiguration:
type: boolean
enablePVCReplace:
type: boolean
enablePVReclaim:
type: boolean
helper:
Expand Down
2 changes: 2 additions & 0 deletions manifests/crd/v1/pingcap.com_tidbclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3096,6 +3096,8 @@ spec:
type: string
enableDynamicConfiguration:
type: boolean
enablePVCReplace:
type: boolean
enablePVReclaim:
type: boolean
helper:
Expand Down
7 changes: 7 additions & 0 deletions pkg/apis/pingcap/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions pkg/apis/pingcap/v1alpha1/tidbcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
defaultSeparateRocksDBLog = false
defaultSeparateRaftLog = false
defaultEnablePVReclaim = false
defaultEnablePVCReplace = false
// defaultEvictLeaderTimeout is the timeout limit of evict leader
defaultEvictLeaderTimeout = 1500 * time.Minute
defaultWaitLeaderTransferBackTimeout = 400 * time.Second
Expand Down Expand Up @@ -1063,6 +1064,14 @@ func (tc *TidbCluster) IsPVReclaimEnabled() bool {
return *enabled
}

func (tc *TidbCluster) IsPVCReplaceEnabled() bool {
enabled := tc.Spec.EnablePVCReplace
if enabled == nil {
return defaultEnablePVCReplace
}
return *enabled
}

func (tc *TidbCluster) IsTiDBBinlogEnabled() bool {
var binlogEnabled *bool
if tc.Spec.TiDB != nil {
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/pingcap/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ type TidbClusterSpec struct {
// +optional
EnablePVReclaim *bool `json:"enablePVReclaim,omitempty"`

// Whether enable PVC replace to recreate the PVC with different specs
// Optional: Defaults to false
// +optional
EnablePVCReplace *bool `json:"enablePVCReplace,omitempty"`

// Whether enable the TLS connection between TiDB server components
// Optional: Defaults to nil
// +optional
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/pingcap/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/controller/tidbcluster/tidb_cluster_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (c *defaultTidbClusterControl) updateTidbCluster(tc *v1alpha1.TidbCluster)
return err
}

if features.DefaultFeatureGate.Enabled(features.VolumeReplacing) {
if features.DefaultFeatureGate.Enabled(features.VolumeReplacing) || tc.IsPVCReplaceEnabled() {
if err := c.pvcReplacer.UpdateStatus(tc); err != nil {
metrics.ClusterUpdateErrors.WithLabelValues(ns, tcName, "pvc_replacer_updatestatus").Inc()
return err
Expand Down Expand Up @@ -306,7 +306,7 @@ func (c *defaultTidbClusterControl) updateTidbCluster(tc *v1alpha1.TidbCluster)
}

// Replace volumes if necessary. Note: if enabled, takes precedence over pvcModifier.
if features.DefaultFeatureGate.Enabled(features.VolumeReplacing) {
if features.DefaultFeatureGate.Enabled(features.VolumeReplacing) || tc.IsPVCReplaceEnabled() {
if err := c.pvcReplacer.Sync(tc); err != nil {
metrics.ClusterUpdateErrors.WithLabelValues(ns, tcName, "pvc_replacer_sync").Inc()
return err
Expand Down

0 comments on commit dfd5ac2

Please sign in to comment.