Skip to content

Commit

Permalink
Add Priority and PreemptionPolicy fields in ResourceBinding
Browse files Browse the repository at this point in the history
Signed-off-by: wei-chenglai <[email protected]>
  • Loading branch information
seanlaii committed Jan 19, 2025
1 parent 5bfdf61 commit 787679a
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 1 deletion.
19 changes: 19 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -20389,6 +20389,10 @@
"default": {},
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.work.v1alpha2.ObjectReference"
},
"schedulePriority": {
"description": "SchedulePriority represents the scheduling priority and preemption policy of workloads.",
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.work.v1alpha2.SchedulePriority"
},
"schedulerName": {
"description": "SchedulerName represents which scheduler to proceed the scheduling. It inherits directly from the associated PropagationPolicy(or ClusterPropagationPolicy).",
"type": "string"
Expand Down Expand Up @@ -20434,6 +20438,21 @@
}
}
},
"com.github.karmada-io.karmada.pkg.apis.work.v1alpha2.SchedulePriority": {
"description": "SchedulePriority represents the scheduling priority and preemption policy of workloads.",
"type": "object",
"properties": {
"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"
},
"priority": {
"description": "Priority represents the scheduling priority of the binding. Higher values indicate higher priority. If not specified, the priority value is set to 0.",
"type": "integer",
"format": "int32"
}
}
},
"com.github.karmada-io.karmada.pkg.apis.work.v1alpha2.Suspension": {
"description": "Suspension defines the policy for suspending dispatching and scheduling.",
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,30 @@ spec:
- kind
- name
type: object
schedulePriority:
description: SchedulePriority represents the scheduling priority and
preemption policy of workloads.
properties:
preemptionPolicy:
default: Never
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
enum:
- Never
- PreemptLowerPriority
type: string
priority:
default: 0
description: |-
Priority represents the scheduling priority of the binding.
Higher values indicate higher priority.
If not specified, the priority value is set to 0.
format: int32
type: integer
type: object
schedulerName:
description: |-
SchedulerName represents which scheduler to proceed the scheduling.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,30 @@ spec:
- kind
- name
type: object
schedulePriority:
description: SchedulePriority represents the scheduling priority and
preemption policy of workloads.
properties:
preemptionPolicy:
default: Never
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
enum:
- Never
- PreemptLowerPriority
type: string
priority:
default: 0
description: |-
Priority represents the scheduling priority of the binding.
Higher values indicate higher priority.
If not specified, the priority value is set to 0.
format: int32
type: integer
type: object
schedulerName:
description: |-
SchedulerName represents which scheduler to proceed the scheduling.
Expand Down
33 changes: 33 additions & 0 deletions pkg/apis/work/v1alpha2/binding_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ type ResourceBindingSpec struct {
// This setting applies to all Work objects created under this binding object.
// +optional
PreserveResourcesOnDeletion *bool `json:"preserveResourcesOnDeletion,omitempty"`

// SchedulePriority represents the scheduling priority and preemption policy of workloads.
// +optional
SchedulePriority *SchedulePriority `json:"schedulePriority,omitempty"`
}

// ObjectReference contains enough information to locate the referenced object inside current cluster.
Expand Down Expand Up @@ -337,6 +341,35 @@ type Suspension struct {
Scheduling *bool `json:"scheduling,omitempty"`
}

// SchedulePriority represents the scheduling priority and preemption policy of workloads.
type SchedulePriority struct {
// Priority represents the scheduling priority of the binding.
// Higher values indicate higher priority.
// If not specified, the priority value is set to 0.
// +kubebuilder:default=0
// +optional
Priority int32 `json:"priority,omitempty"`

// 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
// +kubebuilder:default=Never
// +kubebuilder:validation:Enum=Never;PreemptLowerPriority
// +optional
PreemptionPolicy PreemptionPolicy `json:"preemptionPolicy,omitempty"`
}

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

const (
// PreemptLowerPriority indicates that binding can preempt lower priority bindings
PreemptLowerPriority PreemptionPolicy = "PreemptLowerPriority"
// PreemptNever indicates that binding will never preempt other bindings
PreemptNever PreemptionPolicy = "Never"
)

// ResourceBindingStatus represents the overall status of the strategy as well as the referenced resources.
type ResourceBindingStatus struct {
// SchedulerObservedGeneration is the generation(.metadata.generation) observed by the scheduler.
Expand Down
21 changes: 21 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.

36 changes: 35 additions & 1 deletion 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 787679a

Please sign in to comment.