Proposing PropagationPolicy Preemption API.

Signed-off-by: RainbowMango <qdurenhongcai@gmail.com>
This commit is contained in:
RainbowMango 2023-07-12 18:16:28 +08:00
parent 2d22b74dfc
commit 122d6c0904
5 changed files with 87 additions and 22 deletions

View File

@ -15875,8 +15875,16 @@
"default": {},
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.Placement"
},
"preemption": {
"description": "Preemption declares the behaviors for preempting. Valid options are \"Always\" and \"Never\".\n\n\nPossible enum values:\n - `\"Always\"` means that preemption is allowed. If it is applied to a PropagationPolicy, it can preempt any resource as per Priority, regardless of whether it has been claimed by a PropagationPolicy or a ClusterPropagationPolicy, as long as it can match the rules defined in ResourceSelector. In addition, if a resource has already been claimed by a ClusterPropagationPolicy, the PropagationPolicy can still preempt it without considering Priority. If it is applied to a ClusterPropagationPolicy, it can only preempt from ClusterPropagationPolicy, and from PropagationPolicy is not allowed.\n - `\"Never\"` means that a PropagationPolicy(ClusterPropagationPolicy) never preempts resources.",
"type": "string",
"enum": [
"Always",
"Never"
]
},
"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.\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.",
"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",
"format": "int32"
},

View File

@ -620,6 +620,14 @@ spec:
type: object
type: array
type: object
preemption:
default: Never
description: Preemption declares the behaviors for preempting. Valid
options are "Always" and "Never".
enum:
- Always
- Never
type: string
priority:
default: 0
description: "Priority indicates the importance of a policy(PropagationPolicy
@ -627,16 +635,16 @@ spec:
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. \n
In 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 by selector(resourceSelector.labelSelector)
- matching by selector(resourceSelector.labelSelector) has higher
priority than by APIVersion(resourceSelector.apiVersion) and Kind(resourceSelector.kind).
If 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 The higher the value, the higher the priority. Defaults
to zero."
preempted by following policies even with a higher priority. See
Preemption for more details. \n In 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 by selector(resourceSelector.labelSelector) - matching by selector(resourceSelector.labelSelector)
has higher priority than by APIVersion(resourceSelector.apiVersion)
and Kind(resourceSelector.kind). If 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 The higher the value, the
higher the priority. Defaults to zero."
format: int32
type: integer
propagateDeps:

View File

@ -616,6 +616,14 @@ spec:
type: object
type: array
type: object
preemption:
default: Never
description: Preemption declares the behaviors for preempting. Valid
options are "Always" and "Never".
enum:
- Always
- Never
type: string
priority:
default: 0
description: "Priority indicates the importance of a policy(PropagationPolicy
@ -623,16 +631,16 @@ spec:
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. \n
In 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 by selector(resourceSelector.labelSelector)
- matching by selector(resourceSelector.labelSelector) has higher
priority than by APIVersion(resourceSelector.apiVersion) and Kind(resourceSelector.kind).
If 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 The higher the value, the higher the priority. Defaults
to zero."
preempted by following policies even with a higher priority. See
Preemption for more details. \n In 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 by selector(resourceSelector.labelSelector) - matching by selector(resourceSelector.labelSelector)
has higher priority than by APIVersion(resourceSelector.apiVersion)
and Kind(resourceSelector.kind). If 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 The higher the value, the
higher the priority. Defaults to zero."
format: int32
type: integer
propagateDeps:

View File

@ -76,6 +76,7 @@ type PropagationSpec struct {
// 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.
//
// In case of two policies have the same priority, the one with a more precise
// matching rules in ResourceSelectors wins:
@ -91,6 +92,14 @@ type PropagationSpec struct {
// +kubebuilder:default=0
Priority *int32 `json:"priority,omitempty"`
// Preemption declares the behaviors for preempting.
// Valid options are "Always" and "Never".
//
// +kubebuilder:default="Never"
// +kubebuilder:validation:Enum=Always;Never
// +optional
Preemption PreemptionBehavior `json:"preemption,omitempty"`
// DependentOverrides represents the list of overrides(OverridePolicy)
// which must present before the current PropagationPolicy takes effect.
//
@ -443,6 +452,30 @@ const (
DynamicWeightByAvailableReplicas DynamicWeightFactor = "AvailableReplicas"
)
// PreemptionBehavior describes whether and how to preempt resources that are
// claimed by lower-priority PropagationPolicy(ClusterPropagationPolicy).
// +enum
type PreemptionBehavior string
const (
// PreemptAlways means that preemption is allowed.
//
// If it is applied to a PropagationPolicy, it can preempt any resource as
// per Priority, regardless of whether it has been claimed by a PropagationPolicy
// or a ClusterPropagationPolicy, as long as it can match the rules defined
// in ResourceSelector. In addition, if a resource has already been claimed
// by a ClusterPropagationPolicy, the PropagationPolicy can still preempt it
// without considering Priority.
//
// If it is applied to a ClusterPropagationPolicy, it can only preempt from
// ClusterPropagationPolicy, and from PropagationPolicy is not allowed.
PreemptAlways PreemptionBehavior = "Always"
// PreemptNever means that a PropagationPolicy(ClusterPropagationPolicy) never
// preempts resources.
PreemptNever PreemptionBehavior = "Never"
)
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// PropagationPolicyList contains a list of PropagationPolicy.

View File

@ -4282,11 +4282,19 @@ func schema_pkg_apis_policy_v1alpha1_PropagationSpec(ref common.ReferenceCallbac
},
"priority": {
SchemaProps: spec.SchemaProps{
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.\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.",
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: []string{"integer"},
Format: "int32",
},
},
"preemption": {
SchemaProps: spec.SchemaProps{
Description: "Preemption declares the behaviors for preempting. Valid options are \"Always\" and \"Never\".\n\n\nPossible enum values:\n - `\"Always\"` means that preemption is allowed. If it is applied to a PropagationPolicy, it can preempt any resource as per Priority, regardless of whether it has been claimed by a PropagationPolicy or a ClusterPropagationPolicy, as long as it can match the rules defined in ResourceSelector. In addition, if a resource has already been claimed by a ClusterPropagationPolicy, the PropagationPolicy can still preempt it without considering Priority. If it is applied to a ClusterPropagationPolicy, it can only preempt from ClusterPropagationPolicy, and from PropagationPolicy is not allowed.\n - `\"Never\"` means that a PropagationPolicy(ClusterPropagationPolicy) never preempts resources.",
Type: []string{"string"},
Format: "",
Enum: []interface{}{"Always", "Never"},
},
},
"dependentOverrides": {
SchemaProps: spec.SchemaProps{
Description: "DependentOverrides represents the list of overrides(OverridePolicy) which must present before the current PropagationPolicy takes effect.\n\nIt used to explicitly specify overrides which current PropagationPolicy rely on. A typical scenario is the users create OverridePolicy(ies) and resources at the same time, they want to ensure the new-created policies would be adopted.\n\nNote: For the overrides, OverridePolicy(ies) in current namespace and ClusterOverridePolicy(ies), which not present in this list will still be applied if they matches the resources.",