@@ -35,7 +35,6 @@ import (
35
35
clusterv1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1"
36
36
policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
37
37
workv1alpha2 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2"
38
- "github.com/karmada-io/karmada/pkg/features"
39
38
"github.com/karmada-io/karmada/pkg/sharedcli/ratelimiterflag"
40
39
"github.com/karmada-io/karmada/pkg/util"
41
40
"github.com/karmada-io/karmada/pkg/util/fedinformer/keys"
@@ -189,17 +188,11 @@ func (tc *NoExecuteTaintManager) syncBindingEviction(key util.QueueKey) error {
189
188
// Case 3: Tolerate forever, we do nothing.
190
189
if needEviction || tolerationTime == 0 {
191
190
// 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
+
203
196
if err = tc .Update (context .TODO (), binding ); err != nil {
204
197
helper .EmitClusterEvictionEventForResourceBinding (binding , cluster , tc .EventRecorder , err )
205
198
klog .ErrorS (err , "Failed to update binding" , "binding" , klog .KObj (binding ))
@@ -242,22 +235,25 @@ func (tc *NoExecuteTaintManager) syncClusterBindingEviction(key util.QueueKey) e
242
235
return err
243
236
}
244
237
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
+
245
248
// Case 1: Need eviction now.
246
249
// Case 2: Need eviction after toleration time. If time is up, do eviction right now.
247
250
// Case 3: Tolerate forever, we do nothing.
248
251
if needEviction || tolerationTime == 0 {
249
252
// 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 )))
261
257
if err = tc .Update (context .TODO (), binding ); err != nil {
262
258
helper .EmitClusterEvictionEventForClusterResourceBinding (binding , cluster , tc .EventRecorder , err )
263
259
klog .ErrorS (err , "Failed to update cluster binding" , "binding" , binding .Name )
0 commit comments