Skip to content

Commit

Permalink
Proposing preserve API to support migration sceanrios
Browse files Browse the repository at this point in the history
Signed-off-by: RainbowMango <qdurenhongcai@gmail.com>
  • Loading branch information
RainbowMango committed Sep 20, 2024
1 parent b8edec1 commit aa61791
Show file tree
Hide file tree
Showing 13 changed files with 147 additions and 0 deletions.
12 changes: 12 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -19098,6 +19098,10 @@
"Never"
]
},
"preserveResourcesOnDeletion": {
"description": "PreserveResourcesOnDeletion controls whether resources should be preserved on the member clusters when the resource template is deleted. If set to true, resources will be preserved on the member clusters. Default is false, which means resources will be deleted along with the resource template.\n\nThis setting is particularly useful during workload migration scenarios to ensure that rollback can occur quickly without affecting the workloads running on the member clusters.\n\nAdditionally, this setting applies uniformly across all member clusters and will not selectively control preservation on only some clusters.\n\nNote: This setting does not apply to the deletion of the policy itself. When the policy is deleted, the resource templates and their corresponding propagated resources in member clusters will remain unchanged unless explicitly deleted.",
"type": "boolean"
},
"priority": {
"description": "Priority indicates the importance of a policy(PropagationPolicy or ClusterPropagationPolicy). A policy will be applied for the matched resource templates if there is no other policies with higher priority at the point of the resource template be processed. Once a resource template has been claimed by a policy, by default it will not be preempted by following policies even with a higher priority. See Preemption for more details.\n\nIn case of two policies have the same priority, the one with a more precise matching rules in ResourceSelectors wins: - matching by name(resourceSelector.name) has higher priority than\n by selector(resourceSelector.labelSelector)\n- matching by selector(resourceSelector.labelSelector) has higher priority\n than by APIVersion(resourceSelector.apiVersion) and Kind(resourceSelector.kind).\nIf there is still no winner at this point, the one with the lower alphabetic order wins, e.g. policy 'bar' has higher priority than 'foo'.\n\nThe higher the value, the higher the priority. Defaults to zero.",
"type": "integer",
Expand Down Expand Up @@ -19752,6 +19756,10 @@
"description": "WorkSpec defines the desired state of Work.",
"type": "object",
"properties": {
"preserveResourcesOnDeletion": {
"description": "PreserveResourcesOnDeletion controls whether resources should be preserved on the member cluster when the Work object is deleted. If set to true, resources will be preserved on the member cluster. Default is false, which means resources will be deleted along with the Work object.",
"type": "boolean"
},
"suspendDispatching": {
"description": "SuspendDispatching controls whether dispatching should be suspended, nil means not suspend. Note: true means stop propagating to all clusters.",
"type": "boolean"
Expand Down Expand Up @@ -20174,6 +20182,10 @@
"description": "Placement represents the rule for select clusters to propagate resources.",
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.Placement"
},
"preserveResourcesOnDeletion": {
"description": "PreserveResourcesOnDeletion controls whether resources should be preserved on the member clusters when the binding object is deleted. If set to true, resources will be preserved on the member clusters. Default is false, which means resources will be deleted along with the binding object. This setting applies to all Work objects created under this binding object.",
"type": "boolean"
},
"propagateDeps": {
"description": "PropagateDeps tells if relevant resources should be propagated automatically. It is inherited from PropagationPolicy or ClusterPropagationPolicy. default false.",
"type": "boolean"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,27 @@ spec:
- Always
- Never
type: string
preserveResourcesOnDeletion:
description: |-
PreserveResourcesOnDeletion controls whether resources should be preserved on the
member clusters when the resource template is deleted.
If set to true, resources will be preserved on the member clusters.
Default is false, which means resources will be deleted along with the resource template.
This setting is particularly useful during workload migration scenarios to ensure
that rollback can occur quickly without affecting the workloads running on the
member clusters.
Additionally, this setting applies uniformly across all member clusters and will not
selectively control preservation on only some clusters.
Note: This setting does not apply to the deletion of the policy itself.
When the policy is deleted, the resource templates and their corresponding
propagated resources in member clusters will remain unchanged unless explicitly deleted.
type: boolean
priority:
default: 0
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,27 @@ spec:
- Always
- Never
type: string
preserveResourcesOnDeletion:
description: |-
PreserveResourcesOnDeletion controls whether resources should be preserved on the
member clusters when the resource template is deleted.
If set to true, resources will be preserved on the member clusters.
Default is false, which means resources will be deleted along with the resource template.
This setting is particularly useful during workload migration scenarios to ensure
that rollback can occur quickly without affecting the workloads running on the
member clusters.
Additionally, this setting applies uniformly across all member clusters and will not
selectively control preservation on only some clusters.
Note: This setting does not apply to the deletion of the policy itself.
When the policy is deleted, the resource templates and their corresponding
propagated resources in member clusters will remain unchanged unless explicitly deleted.
type: boolean
priority:
default: 0
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,14 @@ spec:
type: object
type: array
type: object
preserveResourcesOnDeletion:
description: |-
PreserveResourcesOnDeletion controls whether resources should be preserved on the
member clusters when the binding object is deleted.
If set to true, resources will be preserved on the member clusters.
Default is false, which means resources will be deleted along with the binding object.
This setting applies to all Work objects created under this binding object.
type: boolean
propagateDeps:
description: |-
PropagateDeps tells if relevant resources should be propagated automatically.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,14 @@ spec:
type: object
type: array
type: object
preserveResourcesOnDeletion:
description: |-
PreserveResourcesOnDeletion controls whether resources should be preserved on the
member clusters when the binding object is deleted.
If set to true, resources will be preserved on the member clusters.
Default is false, which means resources will be deleted along with the binding object.
This setting applies to all Work objects created under this binding object.
type: boolean
propagateDeps:
description: |-
PropagateDeps tells if relevant resources should be propagated automatically.
Expand Down
7 changes: 7 additions & 0 deletions charts/karmada/_crds/bases/work/work.karmada.io_works.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ spec:
spec:
description: Spec represents the desired behavior of Work.
properties:
preserveResourcesOnDeletion:
description: |-
PreserveResourcesOnDeletion controls whether resources should be preserved on the
member cluster when the Work object is deleted.
If set to true, resources will be preserved on the member cluster.
Default is false, which means resources will be deleted along with the Work object.
type: boolean
suspendDispatching:
description: |-
SuspendDispatching controls whether dispatching should
Expand Down
19 changes: 19 additions & 0 deletions pkg/apis/policy/v1alpha1/propagation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,25 @@ type PropagationSpec struct {
// nil means no suspension. no default values.
// +optional
Suspension *Suspension `json:"suspension,omitempty"`

// PreserveResourcesOnDeletion controls whether resources should be preserved on the
// member clusters when the resource template is deleted.
// If set to true, resources will be preserved on the member clusters.
// Default is false, which means resources will be deleted along with the resource template.
//
// This setting is particularly useful during workload migration scenarios to ensure
// that rollback can occur quickly without affecting the workloads running on the
// member clusters.
//
// Additionally, this setting applies uniformly across all member clusters and will not
// selectively control preservation on only some clusters.
//
// Note: This setting does not apply to the deletion of the policy itself.
// When the policy is deleted, the resource templates and their corresponding
// propagated resources in member clusters will remain unchanged unless explicitly deleted.
//
// +optional
PreserveResourcesOnDeletion *bool `json:"preserveResourcesOnDeletion,omitempty"`
}

// ResourceSelector the resources will be selected.
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/policy/v1alpha1/zz_generated.deepcopy.go

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

7 changes: 7 additions & 0 deletions pkg/apis/work/v1alpha1/work_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ type WorkSpec struct {
// Note: true means stop propagating to all clusters.
// +optional
SuspendDispatching *bool `json:"suspendDispatching,omitempty"`

// PreserveResourcesOnDeletion controls whether resources should be preserved on the
// member cluster when the Work object is deleted.
// If set to true, resources will be preserved on the member cluster.
// Default is false, which means resources will be deleted along with the Work object.
// +optional
PreserveResourcesOnDeletion *bool `json:"preserveResourcesOnDeletion,omitempty"`
}

// WorkloadTemplate represents the manifest workload to be deployed on managed cluster.
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/work/v1alpha1/zz_generated.deepcopy.go

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

8 changes: 8 additions & 0 deletions pkg/apis/work/v1alpha2/binding_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ type ResourceBindingSpec struct {
// nil means no suspension. no default values.
// +optional
Suspension *policyv1alpha1.Suspension `json:"suspension,omitempty"`

// PreserveResourcesOnDeletion controls whether resources should be preserved on the
// member clusters when the binding object is deleted.
// If set to true, resources will be preserved on the member clusters.
// Default is false, which means resources will be deleted along with the binding object.
// This setting applies to all Work objects created under this binding object.
// +optional
PreserveResourcesOnDeletion *bool `json:"preserveResourcesOnDeletion,omitempty"`
}

// ObjectReference contains enough information to locate the referenced object inside current cluster.
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/work/v1alpha2/zz_generated.deepcopy.go

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

21 changes: 21 additions & 0 deletions pkg/generated/openapi/zz_generated.openapi.go

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

0 comments on commit aa61791

Please sign in to comment.