Skip to content

Commit 6093332

Browse files
apply NoExecuteTaintEvictionPurgeMode value to the taint-manager when handle with clusterResourceBinding
Signed-off-by: changzhen <[email protected]>
1 parent 0b75a70 commit 6093332

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

pkg/controllers/cluster/taint_manager.go

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
clusterv1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1"
3636
policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
3737
workv1alpha2 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2"
38-
"github.com/karmada-io/karmada/pkg/features"
3938
"github.com/karmada-io/karmada/pkg/sharedcli/ratelimiterflag"
4039
"github.com/karmada-io/karmada/pkg/util"
4140
"github.com/karmada-io/karmada/pkg/util/fedinformer/keys"
@@ -189,17 +188,11 @@ func (tc *NoExecuteTaintManager) syncBindingEviction(key util.QueueKey) error {
189188
// Case 3: Tolerate forever, we do nothing.
190189
if needEviction || tolerationTime == 0 {
191190
// update final result to evict the target cluster
192-
if features.FeatureGate.Enabled(features.GracefulEviction) {
193-
binding.Spec.GracefulEvictCluster(cluster, workv1alpha2.NewTaskOptions(
194-
workv1alpha2.WithPurgeMode(purgeMode),
195-
workv1alpha2.WithProducer(workv1alpha2.EvictionProducerTaintManager),
196-
workv1alpha2.WithReason(workv1alpha2.EvictionReasonTaintUntolerated)))
197-
} else {
198-
binding.Spec.GracefulEvictCluster(cluster, workv1alpha2.NewTaskOptions(
199-
workv1alpha2.WithPurgeMode(purgeMode),
200-
workv1alpha2.WithProducer(workv1alpha2.EvictionProducerTaintManager),
201-
workv1alpha2.WithReason(workv1alpha2.EvictionReasonTaintUntolerated)))
202-
}
191+
binding.Spec.GracefulEvictCluster(cluster, workv1alpha2.NewTaskOptions(
192+
workv1alpha2.WithPurgeMode(purgeMode),
193+
workv1alpha2.WithProducer(workv1alpha2.EvictionProducerTaintManager),
194+
workv1alpha2.WithReason(workv1alpha2.EvictionReasonTaintUntolerated)))
195+
203196
if err = tc.Update(context.TODO(), binding); err != nil {
204197
helper.EmitClusterEvictionEventForResourceBinding(binding, cluster, tc.EventRecorder, err)
205198
klog.ErrorS(err, "Failed to update binding", "binding", klog.KObj(binding))
@@ -242,22 +235,25 @@ func (tc *NoExecuteTaintManager) syncClusterBindingEviction(key util.QueueKey) e
242235
return err
243236
}
244237

238+
var purgeMode policyv1alpha1.PurgeMode
239+
if needEviction {
240+
switch tc.NoExecuteTaintEvictionPurgeMode {
241+
case "Gracefully":
242+
purgeMode = policyv1alpha1.Graciously
243+
case "Directly":
244+
purgeMode = policyv1alpha1.Immediately
245+
}
246+
}
247+
245248
// Case 1: Need eviction now.
246249
// Case 2: Need eviction after toleration time. If time is up, do eviction right now.
247250
// Case 3: Tolerate forever, we do nothing.
248251
if needEviction || tolerationTime == 0 {
249252
// update final result to evict the target cluster
250-
if features.FeatureGate.Enabled(features.GracefulEviction) {
251-
binding.Spec.GracefulEvictCluster(cluster, workv1alpha2.NewTaskOptions(
252-
workv1alpha2.WithPurgeMode(policyv1alpha1.Graciously),
253-
workv1alpha2.WithProducer(workv1alpha2.EvictionProducerTaintManager),
254-
workv1alpha2.WithReason(workv1alpha2.EvictionReasonTaintUntolerated)))
255-
} else {
256-
binding.Spec.GracefulEvictCluster(cluster, workv1alpha2.NewTaskOptions(
257-
workv1alpha2.WithPurgeMode(policyv1alpha1.Immediately),
258-
workv1alpha2.WithProducer(workv1alpha2.EvictionProducerTaintManager),
259-
workv1alpha2.WithReason(workv1alpha2.EvictionReasonTaintUntolerated)))
260-
}
253+
binding.Spec.GracefulEvictCluster(cluster, workv1alpha2.NewTaskOptions(
254+
workv1alpha2.WithPurgeMode(purgeMode),
255+
workv1alpha2.WithProducer(workv1alpha2.EvictionProducerTaintManager),
256+
workv1alpha2.WithReason(workv1alpha2.EvictionReasonTaintUntolerated)))
261257
if err = tc.Update(context.TODO(), binding); err != nil {
262258
helper.EmitClusterEvictionEventForClusterResourceBinding(binding, cluster, tc.EventRecorder, err)
263259
klog.ErrorS(err, "Failed to update cluster binding", "binding", binding.Name)

0 commit comments

Comments
 (0)