diff --git a/pkg/controller/tidbcluster/tidb_cluster_control.go b/pkg/controller/tidbcluster/tidb_cluster_control.go index ac9fec3c7a..abb1757d65 100644 --- a/pkg/controller/tidbcluster/tidb_cluster_control.go +++ b/pkg/controller/tidbcluster/tidb_cluster_control.go @@ -24,7 +24,6 @@ import ( "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1/defaulting" v1alpha1validation "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1/validation" "github.com/pingcap/tidb-operator/pkg/controller" - "github.com/pingcap/tidb-operator/pkg/features" "github.com/pingcap/tidb-operator/pkg/manager" "github.com/pingcap/tidb-operator/pkg/manager/member" "github.com/pingcap/tidb-operator/pkg/manager/volumes" @@ -283,11 +282,9 @@ func (c *defaultTidbClusterControl) updateTidbCluster(tc *v1alpha1.TidbCluster) } // modify volumes if necessary - if features.DefaultFeatureGate.Enabled(features.VolumeModifying) { - if err := c.pvcModifier.Sync(tc); err != nil { - metrics.ClusterUpdateErrors.WithLabelValues(ns, tcName, "pvc_modifier").Inc() - return err - } + if err := c.pvcModifier.Sync(tc); err != nil { + metrics.ClusterUpdateErrors.WithLabelValues(ns, tcName, "pvc_modifier").Inc() + return err } // syncing the some tidbcluster status attributes diff --git a/pkg/features/features.go b/pkg/features/features.go index c1488b0d7f..ff57a15afd 100644 --- a/pkg/features/features.go +++ b/pkg/features/features.go @@ -48,6 +48,7 @@ const ( AutoScaling string = "AutoScaling" // VolumeModifying controls whether allow to modify volumes + // NOTE: volume resize is always allowed even if this feature is disabled VolumeModifying string = "VolumeModifying" ) diff --git a/pkg/manager/member/tikv_upgrader.go b/pkg/manager/member/tikv_upgrader.go index 976ecd3f1f..06e6dd69f1 100644 --- a/pkg/manager/member/tikv_upgrader.go +++ b/pkg/manager/member/tikv_upgrader.go @@ -22,7 +22,6 @@ import ( "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1" "github.com/pingcap/tidb-operator/pkg/controller" - "github.com/pingcap/tidb-operator/pkg/features" mngerutils "github.com/pingcap/tidb-operator/pkg/manager/utils" "github.com/pingcap/tidb-operator/pkg/manager/volumes" "github.com/pingcap/tidb-operator/pkg/pdapi" @@ -211,14 +210,12 @@ func (u *tikvUpgrader) upgradeTiKVPod(tc *v1alpha1.TidbCluster, ordinal int32, n return controller.RequeueErrorf("upgradeTiKVPod: evicting leader of pod %s for tc %s/%s", upgradePodName, ns, tcName) } - if features.DefaultFeatureGate.Enabled(features.VolumeModifying) { - done, err = u.modifyVolumesBeforeUpgrade(tc, upgradePod) - if err != nil { - return fmt.Errorf("upgradeTiKVPod: failed to modify volumes of pod %s for tc %s/%s, error: %s", upgradePodName, ns, tcName, err) - } - if !done { - return controller.RequeueErrorf("upgradeTiKVPod: modifying volumes of pod %s for tc %s/%s", upgradePodName, ns, tcName) - } + done, err = u.modifyVolumesBeforeUpgrade(tc, upgradePod) + if err != nil { + return fmt.Errorf("upgradeTiKVPod: failed to modify volumes of pod %s for tc %s/%s, error: %s", upgradePodName, ns, tcName, err) + } + if !done { + return controller.RequeueErrorf("upgradeTiKVPod: modifying volumes of pod %s for tc %s/%s", upgradePodName, ns, tcName) } mngerutils.SetUpgradePartition(newSet, ordinal) diff --git a/pkg/manager/volumes/pod_vol_modifier.go b/pkg/manager/volumes/pod_vol_modifier.go index b7aa4bf67d..250acdb141 100644 --- a/pkg/manager/volumes/pod_vol_modifier.go +++ b/pkg/manager/volumes/pod_vol_modifier.go @@ -29,6 +29,7 @@ import ( "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1" "github.com/pingcap/tidb-operator/pkg/controller" + "github.com/pingcap/tidb-operator/pkg/features" "github.com/pingcap/tidb-operator/pkg/manager/volumes/delegation" "github.com/pingcap/tidb-operator/pkg/manager/volumes/delegation/aws" ) @@ -90,12 +91,15 @@ type podVolModifier struct { } func NewPodVolumeModifier(deps *controller.Dependencies) PodVolumeModifier { - return &podVolModifier{ - deps: deps, - modifiers: map[string]delegation.VolumeModifier{ - "ebs.csi.aws.com": aws.NewEBSModifier(deps.AWSConfig), - }, + m := &podVolModifier{ + deps: deps, + modifiers: map[string]delegation.VolumeModifier{}, } + if features.DefaultFeatureGate.Enabled(features.VolumeModifying) { + m.modifiers["ebs.csi.aws.com"] = aws.NewEBSModifier(deps.AWSConfig) + } + + return m } func (p *podVolModifier) ShouldModify(actual []ActualVolume) bool {