Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Priority and PreemptionPolicy fields in ResourceBinding #5963

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -20355,10 +20355,19 @@
"description": "Placement represents the rule for select clusters to propagate resources.",
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.policy.v1alpha1.Placement"
},
"preemptionPolicy": {
"description": "PreemptionPolicy controls the preemption policy of this binding. Valid values are: - Never: (default) prevents the binding from preempting other bindings - PreemptLowerPriority: allows the binding to preempt lower-priority bindings",
"type": "string"
},
"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"
},
"priority": {
"description": "Priority represents the scheduling priority of the binding. Bindings with higher priority values are scheduled ahead of bindings with lower priority values. If not specified, the priority value is set to 0.",
"type": "integer",
"format": "int32"
},
"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 @@ -989,6 +989,13 @@ spec:
type: object
type: array
type: object
preemptionPolicy:
description: |-
PreemptionPolicy controls the preemption policy of this binding.
Valid values are:
- Never: (default) prevents the binding from preempting other bindings
- PreemptLowerPriority: allows the binding to preempt lower-priority bindings
type: string
preserveResourcesOnDeletion:
description: |-
PreserveResourcesOnDeletion controls whether resources should be preserved on the
Expand All @@ -997,6 +1004,13 @@ spec:
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
priority:
description: |-
Priority represents the scheduling priority of the binding.
Bindings with higher priority values are scheduled ahead of bindings with lower priority values.
If not specified, the priority value is set to 0.
format: int32
type: integer
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 @@ -989,6 +989,13 @@ spec:
type: object
type: array
type: object
preemptionPolicy:
description: |-
PreemptionPolicy controls the preemption policy of this binding.
Valid values are:
- Never: (default) prevents the binding from preempting other bindings
- PreemptLowerPriority: allows the binding to preempt lower-priority bindings
type: string
preserveResourcesOnDeletion:
description: |-
PreserveResourcesOnDeletion controls whether resources should be preserved on the
Expand All @@ -997,6 +1004,13 @@ spec:
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
priority:
description: |-
Priority represents the scheduling priority of the binding.
Bindings with higher priority values are scheduled ahead of bindings with lower priority values.
If not specified, the priority value is set to 0.
format: int32
type: integer
propagateDeps:
description: |-
PropagateDeps tells if relevant resources should be propagated automatically.
Expand Down
23 changes: 23 additions & 0 deletions pkg/apis/work/v1alpha2/binding_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ const (
ResourceNamespaceScopedClusterResourceBinding = false
)

// PreemptionPolicy defines the preemption policy for bindings
type PreemptionPolicy string

const (
// PreemptLowerPriority means that binding can preempt other bindings with lower priority.
PreemptLowerPriority PreemptionPolicy = "PreemptLowerPriority"
// PreemptNever means that binding never preempts other bindings with lower priority.
PreemptNever PreemptionPolicy = "Never"
)

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:subresource:status
Expand Down Expand Up @@ -159,6 +169,19 @@ type ResourceBindingSpec struct {
// This setting applies to all Work objects created under this binding object.
// +optional
PreserveResourcesOnDeletion *bool `json:"preserveResourcesOnDeletion,omitempty"`

// Priority represents the scheduling priority of the binding.
// Bindings with higher priority values are scheduled ahead of bindings with lower priority values.
// If not specified, the priority value is set to 0.
// +optional
Priority int32 `json:"priority,omitempty"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we don't allow the user to override the priority in the binding, and the priority value can only be derived by the priority class, I use int32 instead of *int32 for now. Open to discussion.


// PreemptionPolicy controls the preemption policy of this binding.
// Valid values are:
// - Never: (default) prevents the binding from preempting other bindings
// - PreemptLowerPriority: allows the binding to preempt lower-priority bindings
// +optional
PreemptionPolicy PreemptionPolicy `json:"preemptionPolicy,omitempty"`
}

// ObjectReference contains enough information to locate the referenced object inside current cluster.
Expand Down
14 changes: 14 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.