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

Reclaim Enhancement: Add Reclaimable parameter for queue #651

Merged
merged 2 commits into from
Jan 2, 2020
Merged
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
2 changes: 2 additions & 0 deletions pkg/apis/scheduling/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ type QueueSpec struct {
Capability v1.ResourceList
// State controller the status of queue
State QueueState
// Reclaimable indicate whether the queue can be reclaimed by other queue
Reclaimable *bool
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/scheduling/v1alpha1/zz_generated.conversion.go

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

2 changes: 2 additions & 0 deletions pkg/apis/scheduling/v1alpha2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ type QueueSpec struct {
Capability v1.ResourceList `json:"capability,omitempty" protobuf:"bytes,2,opt,name=capability"`
// State controller the status of queue
State QueueState `json:"state,omitempty" protobuf:"bytes,3,opt,name=state"`
// Reclaimable indicate whether the queue can be reclaimed by other queue
Reclaimable *bool `json:"reclaimable,omitempty" protobuf:"bytes,4,opt,name=reclaimable"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/scheduling/v1alpha2/zz_generated.conversion.go

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

5 changes: 5 additions & 0 deletions pkg/apis/scheduling/v1alpha2/zz_generated.deepcopy.go

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

5 changes: 5 additions & 0 deletions pkg/apis/scheduling/zz_generated.deepcopy.go

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

4 changes: 4 additions & 0 deletions pkg/scheduler/actions/reclaim/reclaim.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ func (alloc *reclaimAction) Execute(ssn *framework.Session) {
if j, found := ssn.Jobs[task.Job]; !found {
continue
} else if j.Queue != job.Queue {
q := ssn.Queues[j.Queue]
if !q.Reclaimable() {
continue
}
// Clone task to avoid modify Task's status on node.
reclaimees = append(reclaimees, task.Clone())
}
Expand Down
17 changes: 17 additions & 0 deletions pkg/scheduler/api/queue_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,20 @@ func (q *QueueInfo) Clone() *QueueInfo {
Queue: q.Queue,
}
}

// Reclaimable return whether queue is reclaimable
func (q *QueueInfo) Reclaimable() bool {
if q == nil {
return false
}

if q.Queue == nil {
return false
}

if q.Queue.Spec.Reclaimable == nil {
return true
}

return *q.Queue.Spec.Reclaimable
}