Skip to content

Commit 4418fb0

Browse files
authored
Merge pull request #6387 from XiShanYongYe-Chang/deprecated-some-purgemode
Introduced Directly, Gracefully PurgeMode, and deprecated Immediately and Graciously PurgeMode
2 parents f85bf8f + c3e5b1d commit 4418fb0

26 files changed

+167
-105
lines changed

api/openapi-spec/swagger.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19187,7 +19187,7 @@
1918719187
"format": "int32"
1918819188
},
1918919189
"purgeMode": {
19190-
"description": "PurgeMode represents how to deal with the legacy applications on the cluster from which the application is migrated. Valid options are \"Immediately\", \"Graciously\" and \"Never\". Defaults to \"Graciously\".",
19190+
"description": "PurgeMode represents how to deal with the legacy applications on the cluster from which the application is migrated. Valid options are \"Directly\", \"Gracefully\", \"Never\", \"Immediately\"(deprecated), and \"Graciously\"(deprecated). Defaults to \"Gracefully\".",
1919119191
"type": "string"
1919219192
},
1919319193
"statePreservation": {
@@ -21248,7 +21248,7 @@
2124821248
"default": ""
2124921249
},
2125021250
"purgeMode": {
21251-
"description": "PurgeMode represents how to deal with the legacy applications on the cluster from which the application is migrated. Valid options are \"Immediately\", \"Graciously\" and \"Never\".",
21251+
"description": "PurgeMode represents how to deal with the legacy applications on the cluster from which the application is migrated. Valid options are \"Immediately\", \"Directly\", \"Graciously\", \"Gracefully\" and \"Never\".",
2125221252
"type": "string"
2125321253
},
2125421254
"reason": {

charts/karmada/_crds/bases/policy/policy.karmada.io_clusterpropagationpolicies.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,19 @@ spec:
153153
format: int32
154154
type: integer
155155
purgeMode:
156-
default: Graciously
156+
default: Gracefully
157157
description: |-
158158
PurgeMode represents how to deal with the legacy applications on the
159159
cluster from which the application is migrated.
160-
Valid options are "Immediately", "Graciously" and "Never".
161-
Defaults to "Graciously".
160+
Valid options are "Directly", "Gracefully", "Never", "Immediately"(deprecated),
161+
and "Graciously"(deprecated).
162+
Defaults to "Gracefully".
162163
enum:
164+
- Directly
165+
- Gracefully
166+
- Never
163167
- Immediately
164168
- Graciously
165-
- Never
166169
type: string
167170
statePreservation:
168171
description: |-

charts/karmada/_crds/bases/policy/policy.karmada.io_propagationpolicies.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,19 @@ spec:
150150
format: int32
151151
type: integer
152152
purgeMode:
153-
default: Graciously
153+
default: Gracefully
154154
description: |-
155155
PurgeMode represents how to deal with the legacy applications on the
156156
cluster from which the application is migrated.
157-
Valid options are "Immediately", "Graciously" and "Never".
158-
Defaults to "Graciously".
157+
Valid options are "Directly", "Gracefully", "Never", "Immediately"(deprecated),
158+
and "Graciously"(deprecated).
159+
Defaults to "Gracefully".
159160
enum:
161+
- Directly
162+
- Gracefully
163+
- Never
160164
- Immediately
161165
- Graciously
162-
- Never
163166
type: string
164167
statePreservation:
165168
description: |-

charts/karmada/_crds/bases/work/work.karmada.io_clusterresourcebindings.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,16 +510,19 @@ spec:
510510
format: int32
511511
type: integer
512512
purgeMode:
513-
default: Graciously
513+
default: Gracefully
514514
description: |-
515515
PurgeMode represents how to deal with the legacy applications on the
516516
cluster from which the application is migrated.
517-
Valid options are "Immediately", "Graciously" and "Never".
518-
Defaults to "Graciously".
517+
Valid options are "Directly", "Gracefully", "Never", "Immediately"(deprecated),
518+
and "Graciously"(deprecated).
519+
Defaults to "Gracefully".
519520
enum:
521+
- Directly
522+
- Gracefully
523+
- Never
520524
- Immediately
521525
- Graciously
522-
- Never
523526
type: string
524527
statePreservation:
525528
description: |-
@@ -649,10 +652,12 @@ spec:
649652
description: |-
650653
PurgeMode represents how to deal with the legacy applications on the
651654
cluster from which the application is migrated.
652-
Valid options are "Immediately", "Graciously" and "Never".
655+
Valid options are "Immediately", "Directly", "Graciously", "Gracefully" and "Never".
653656
enum:
654657
- Immediately
658+
- Directly
655659
- Graciously
660+
- Gracefully
656661
- Never
657662
type: string
658663
reason:

charts/karmada/_crds/bases/work/work.karmada.io_resourcebindings.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,16 +510,19 @@ spec:
510510
format: int32
511511
type: integer
512512
purgeMode:
513-
default: Graciously
513+
default: Gracefully
514514
description: |-
515515
PurgeMode represents how to deal with the legacy applications on the
516516
cluster from which the application is migrated.
517-
Valid options are "Immediately", "Graciously" and "Never".
518-
Defaults to "Graciously".
517+
Valid options are "Directly", "Gracefully", "Never", "Immediately"(deprecated),
518+
and "Graciously"(deprecated).
519+
Defaults to "Gracefully".
519520
enum:
521+
- Directly
522+
- Gracefully
523+
- Never
520524
- Immediately
521525
- Graciously
522-
- Never
523526
type: string
524527
statePreservation:
525528
description: |-
@@ -649,10 +652,12 @@ spec:
649652
description: |-
650653
PurgeMode represents how to deal with the legacy applications on the
651654
cluster from which the application is migrated.
652-
Valid options are "Immediately", "Graciously" and "Never".
655+
Valid options are "Immediately", "Directly", "Graciously", "Gracefully" and "Never".
653656
enum:
654657
- Immediately
658+
- Directly
655659
- Graciously
660+
- Gracefully
656661
- Never
657662
type: string
658663
reason:

pkg/apis/policy/v1alpha1/propagation_types.go

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,40 @@ const (
289289
// at the same time. During a failover, it is crucial to ensure that the old
290290
// application is removed before creating a new one to avoid duplicate
291291
// processing and maintaining state consistency.
292+
//
293+
// Deprecated: The term `Immediately` may be confusing when used alongside
294+
// `GracePeriodSeconds`, which specifies that resources are removed after
295+
// a grace period rather than at once.
296+
// `Immediately` is replaced by `Directly` for clarity. This term remains
297+
// functional in the current API version for backward compatibility and will
298+
// be removed when PropagationPolicy advances to alpha2 or beta.
292299
Immediately PurgeMode = "Immediately"
293300
// Graciously represents that Karmada will wait for the application to
294301
// come back to healthy on the new cluster or after a timeout is reached
295302
// before evicting the application.
303+
//
304+
// Deprecated: The term `Graciously` is replaced by `Gracefully` for correct
305+
// English usage. This term remains functional in the current API version for
306+
// backward compatibility and will be removed when PropagationPolicy advances
307+
// to alpha2 or beta.
296308
Graciously PurgeMode = "Graciously"
297309
// Never represents that Karmada will not evict the application and
298310
// users manually confirms how to clean up redundant copies.
299311
Never PurgeMode = "Never"
312+
313+
// PurgeModeDirectly represents that Karmada will directly evict the legacy
314+
// application. This is useful in scenarios where an application can not
315+
// tolerate two instances running simultaneously.
316+
// For example, the Flink application supports exactly-once state consistency,
317+
// which means it requires that no two instances of the application are running
318+
// at the same time. During a failover, it is crucial to ensure that the old
319+
// application is removed before creating a new one to avoid duplicate
320+
// processing and maintaining state consistency.
321+
PurgeModeDirectly PurgeMode = "Directly"
322+
// PurgeModeGracefully represents that Karmada will wait for the application to
323+
// come back to healthy on the new cluster or after a timeout is reached
324+
// before evicting the application.
325+
PurgeModeGracefully PurgeMode = "Gracefully"
300326
)
301327

302328
// FailoverBehavior indicates failover behaviors in case of an application or
@@ -326,10 +352,11 @@ type ApplicationFailoverBehavior struct {
326352

327353
// PurgeMode represents how to deal with the legacy applications on the
328354
// cluster from which the application is migrated.
329-
// Valid options are "Immediately", "Graciously" and "Never".
330-
// Defaults to "Graciously".
331-
// +kubebuilder:validation:Enum=Immediately;Graciously;Never
332-
// +kubebuilder:default=Graciously
355+
// Valid options are "Directly", "Gracefully", "Never", "Immediately"(deprecated),
356+
// and "Graciously"(deprecated).
357+
// Defaults to "Gracefully".
358+
// +kubebuilder:validation:Enum=Directly;Gracefully;Never;Immediately;Graciously
359+
// +kubebuilder:default=Gracefully
333360
// +optional
334361
PurgeMode PurgeMode `json:"purgeMode,omitempty"`
335362

pkg/apis/work/v1alpha2/binding_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ type GracefulEvictionTask struct {
275275

276276
// PurgeMode represents how to deal with the legacy applications on the
277277
// cluster from which the application is migrated.
278-
// Valid options are "Immediately", "Graciously" and "Never".
279-
// +kubebuilder:validation:Enum=Immediately;Graciously;Never
278+
// Valid options are "Immediately", "Directly", "Graciously", "Gracefully" and "Never".
279+
// +kubebuilder:validation:Enum=Immediately;Directly;Graciously;Gracefully;Never
280280
// +optional
281281
PurgeMode policyv1alpha1.PurgeMode `json:"purgeMode,omitempty"`
282282

pkg/apis/work/v1alpha2/binding_types_helper_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
174174
},
175175
EvictEvent: GracefulEvictionTask{
176176
FromCluster: "m1",
177-
PurgeMode: policyv1alpha1.Immediately,
177+
PurgeMode: policyv1alpha1.PurgeModeDirectly,
178178
Reason: EvictionReasonTaintUntolerated,
179179
Message: "graceful eviction",
180180
Producer: EvictionProducerTaintManager,
@@ -184,7 +184,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
184184
GracefulEvictionTasks: []GracefulEvictionTask{
185185
{
186186
FromCluster: "m1",
187-
PurgeMode: policyv1alpha1.Immediately,
187+
PurgeMode: policyv1alpha1.PurgeModeDirectly,
188188
Replicas: ptr.To[int32](1),
189189
Reason: EvictionReasonTaintUntolerated,
190190
Message: "graceful eviction",
@@ -226,7 +226,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
226226
},
227227
EvictEvent: GracefulEvictionTask{
228228
FromCluster: "m3",
229-
PurgeMode: policyv1alpha1.Graciously,
229+
PurgeMode: policyv1alpha1.PurgeModeGracefully,
230230
Reason: EvictionReasonTaintUntolerated,
231231
Message: "graceful eviction",
232232
Producer: EvictionProducerTaintManager,
@@ -236,7 +236,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
236236
GracefulEvictionTasks: []GracefulEvictionTask{
237237
{
238238
FromCluster: "m3",
239-
PurgeMode: policyv1alpha1.Graciously,
239+
PurgeMode: policyv1alpha1.PurgeModeGracefully,
240240
Replicas: ptr.To[int32](3),
241241
Reason: EvictionReasonTaintUntolerated,
242242
Message: "graceful eviction",
@@ -253,7 +253,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
253253
},
254254
EvictEvent: GracefulEvictionTask{
255255
FromCluster: "m3",
256-
PurgeMode: policyv1alpha1.Graciously,
256+
PurgeMode: policyv1alpha1.PurgeModeGracefully,
257257
Reason: EvictionReasonTaintUntolerated,
258258
Message: "graceful eviction",
259259
Producer: EvictionProducerTaintManager,
@@ -266,7 +266,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
266266
},
267267
{
268268
FromCluster: "m3",
269-
PurgeMode: policyv1alpha1.Graciously,
269+
PurgeMode: policyv1alpha1.PurgeModeGracefully,
270270
Replicas: ptr.To[int32](3),
271271
Reason: EvictionReasonTaintUntolerated,
272272
Message: "graceful eviction",
@@ -296,7 +296,7 @@ func TestResourceBindingSpec_GracefulEvictCluster(t *testing.T) {
296296
},
297297
EvictEvent: GracefulEvictionTask{
298298
FromCluster: "m1",
299-
PurgeMode: policyv1alpha1.Graciously,
299+
PurgeMode: policyv1alpha1.PurgeModeGracefully,
300300
Replicas: ptr.To[int32](1),
301301
Reason: EvictionReasonTaintUntolerated,
302302
Message: "graceful eviction v2",

pkg/controllers/applicationfailover/common.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,13 @@ func buildTaskOptions(failoverBehavior *policyv1alpha1.ApplicationFailoverBehavi
211211
}
212212

213213
switch failoverBehavior.PurgeMode {
214-
case policyv1alpha1.Graciously:
214+
//nolint:staticcheck
215+
// disable `deprecation` check for backward compatibility.
216+
case policyv1alpha1.Graciously, policyv1alpha1.PurgeModeGracefully:
215217
if features.FeatureGate.Enabled(features.GracefulEviction) {
216218
taskOpts = append(taskOpts, workv1alpha2.WithGracePeriodSeconds(failoverBehavior.GracePeriodSeconds))
217219
} else {
218-
err := fmt.Errorf("GracefulEviction featureGate must be enabled when purgeMode is %s", policyv1alpha1.Graciously)
220+
err := fmt.Errorf("GracefulEviction featureGate must be enabled when purgeMode is %s", failoverBehavior.PurgeMode)
219221
klog.Error(err)
220222
return nil, err
221223
}

pkg/controllers/applicationfailover/common_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,13 @@ func Test_buildTaskOptions(t *testing.T) {
472472
wantErr assert.ErrorAssertionFunc
473473
}{
474474
{
475-
name: "Graciously purgeMode with ResourceBinding",
475+
name: "Gracefully purgeMode with ResourceBinding",
476476
args: args{
477477
failoverBehavior: &policyv1alpha1.ApplicationFailoverBehavior{
478478
DecisionConditions: policyv1alpha1.DecisionConditions{
479479
TolerationSeconds: ptr.To[int32](100),
480480
},
481-
PurgeMode: policyv1alpha1.Graciously,
481+
PurgeMode: policyv1alpha1.PurgeModeGracefully,
482482
GracePeriodSeconds: ptr.To[int32](120),
483483
StatePreservation: &policyv1alpha1.StatePreservation{
484484
Rules: []policyv1alpha1.StatePreservationRule{
@@ -496,7 +496,7 @@ func Test_buildTaskOptions(t *testing.T) {
496496
clustersBeforeFailover: []string{"c0"},
497497
},
498498
want: *workv1alpha2.NewTaskOptions(
499-
workv1alpha2.WithPurgeMode(policyv1alpha1.Graciously),
499+
workv1alpha2.WithPurgeMode(policyv1alpha1.PurgeModeGracefully),
500500
workv1alpha2.WithProducer(RBApplicationFailoverControllerName),
501501
workv1alpha2.WithReason(workv1alpha2.EvictionReasonApplicationFailure),
502502
workv1alpha2.WithGracePeriodSeconds(ptr.To[int32](120)),
@@ -543,7 +543,7 @@ func Test_buildTaskOptions(t *testing.T) {
543543
DecisionConditions: policyv1alpha1.DecisionConditions{
544544
TolerationSeconds: ptr.To[int32](100),
545545
},
546-
PurgeMode: policyv1alpha1.Immediately,
546+
PurgeMode: policyv1alpha1.PurgeModeDirectly,
547547
StatePreservation: &policyv1alpha1.StatePreservation{
548548
Rules: []policyv1alpha1.StatePreservationRule{
549549
{AliasLabelName: "key-a", JSONPath: "{ .replicas }"},
@@ -560,21 +560,21 @@ func Test_buildTaskOptions(t *testing.T) {
560560
clustersBeforeFailover: []string{"c0"},
561561
},
562562
want: *workv1alpha2.NewTaskOptions(
563-
workv1alpha2.WithPurgeMode(policyv1alpha1.Immediately),
563+
workv1alpha2.WithPurgeMode(policyv1alpha1.PurgeModeDirectly),
564564
workv1alpha2.WithProducer(CRBApplicationFailoverControllerName),
565565
workv1alpha2.WithReason(workv1alpha2.EvictionReasonApplicationFailure),
566566
workv1alpha2.WithPreservedLabelState(map[string]string{"key-a": "2", "key-b": "true"}),
567567
workv1alpha2.WithClustersBeforeFailover([]string{"c0"})),
568568
wantErr: assert.NoError,
569569
},
570570
{
571-
name: "Graciously purgeMode with ResourceBinding, StatePreservation is nil",
571+
name: "Gracefully purgeMode with ResourceBinding, StatePreservation is nil",
572572
args: args{
573573
failoverBehavior: &policyv1alpha1.ApplicationFailoverBehavior{
574574
DecisionConditions: policyv1alpha1.DecisionConditions{
575575
TolerationSeconds: ptr.To[int32](100),
576576
},
577-
PurgeMode: policyv1alpha1.Graciously,
577+
PurgeMode: policyv1alpha1.PurgeModeGracefully,
578578
GracePeriodSeconds: ptr.To[int32](120),
579579
},
580580
aggregatedStatus: []workv1alpha2.AggregatedStatusItem{
@@ -586,20 +586,20 @@ func Test_buildTaskOptions(t *testing.T) {
586586
clustersBeforeFailover: []string{"c0"},
587587
},
588588
want: *workv1alpha2.NewTaskOptions(
589-
workv1alpha2.WithPurgeMode(policyv1alpha1.Graciously),
589+
workv1alpha2.WithPurgeMode(policyv1alpha1.PurgeModeGracefully),
590590
workv1alpha2.WithProducer(RBApplicationFailoverControllerName),
591591
workv1alpha2.WithReason(workv1alpha2.EvictionReasonApplicationFailure),
592592
workv1alpha2.WithGracePeriodSeconds(ptr.To[int32](120))),
593593
wantErr: assert.NoError,
594594
},
595595
{
596-
name: "Graciously purgeMode with ResourceBinding, StatePreservation.Rules is nil",
596+
name: "Gracefully purgeMode with ResourceBinding, StatePreservation.Rules is nil",
597597
args: args{
598598
failoverBehavior: &policyv1alpha1.ApplicationFailoverBehavior{
599599
DecisionConditions: policyv1alpha1.DecisionConditions{
600600
TolerationSeconds: ptr.To[int32](100),
601601
},
602-
PurgeMode: policyv1alpha1.Graciously,
602+
PurgeMode: policyv1alpha1.PurgeModeGracefully,
603603
GracePeriodSeconds: ptr.To[int32](120),
604604
StatePreservation: &policyv1alpha1.StatePreservation{},
605605
},
@@ -612,20 +612,20 @@ func Test_buildTaskOptions(t *testing.T) {
612612
clustersBeforeFailover: []string{"c0"},
613613
},
614614
want: *workv1alpha2.NewTaskOptions(
615-
workv1alpha2.WithPurgeMode(policyv1alpha1.Graciously),
615+
workv1alpha2.WithPurgeMode(policyv1alpha1.PurgeModeGracefully),
616616
workv1alpha2.WithProducer(RBApplicationFailoverControllerName),
617617
workv1alpha2.WithReason(workv1alpha2.EvictionReasonApplicationFailure),
618618
workv1alpha2.WithGracePeriodSeconds(ptr.To[int32](120))),
619619
wantErr: assert.NoError,
620620
},
621621
{
622-
name: "Graciously purgeMode with ResourceBinding, target cluster status in not collected",
622+
name: "Gracefully purgeMode with ResourceBinding, target cluster status in not collected",
623623
args: args{
624624
failoverBehavior: &policyv1alpha1.ApplicationFailoverBehavior{
625625
DecisionConditions: policyv1alpha1.DecisionConditions{
626626
TolerationSeconds: ptr.To[int32](100),
627627
},
628-
PurgeMode: policyv1alpha1.Graciously,
628+
PurgeMode: policyv1alpha1.PurgeModeGracefully,
629629
GracePeriodSeconds: ptr.To[int32](120),
630630
StatePreservation: &policyv1alpha1.StatePreservation{
631631
Rules: []policyv1alpha1.StatePreservationRule{

0 commit comments

Comments
 (0)