Skip to content

Commit b8e2b0d

Browse files
committed
Refine WaitingPod interface
1 parent 64ba0bf commit b8e2b0d

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

pkg/scheduler/framework/v1alpha1/interface.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,9 @@ type WaitingPod interface {
202202
// Allow declares the waiting pod is allowed to be scheduled by plugin pluginName.
203203
// If this is the last remaining plugin to allow, then a success signal is delivered
204204
// to unblock the pod.
205-
// Returns true if the allow signal was successfully dealt with, false otherwise.
206-
Allow(pluginName string) bool
207-
// Reject declares the waiting pod unschedulable. Returns true if the reject signal
208-
// was successfully delivered, false otherwise.
209-
Reject(msg string) bool
205+
Allow(pluginName string)
206+
// Reject declares the waiting pod unschedulable.
207+
Reject(msg string)
210208
}
211209

212210
// Plugin is the parent type for all the scheduling framework plugins.

pkg/scheduler/framework/v1alpha1/waiting_pods_map.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ func (w *waitingPod) GetPendingPlugins() []string {
121121
// Allow declares the waiting pod is allowed to be scheduled by plugin pluginName.
122122
// If this is the last remaining plugin to allow, then a success signal is delivered
123123
// to unblock the pod.
124-
// Returns true if the allow signal was successfully dealt with, false otherwise.
125-
func (w *waitingPod) Allow(pluginName string) bool {
124+
func (w *waitingPod) Allow(pluginName string) {
126125
w.mu.Lock()
127126
defer w.mu.Unlock()
128127
if timer, exist := w.pendingPlugins[pluginName]; exist {
@@ -132,30 +131,29 @@ func (w *waitingPod) Allow(pluginName string) bool {
132131

133132
// Only signal success status after all plugins have allowed
134133
if len(w.pendingPlugins) != 0 {
135-
return true
134+
return
136135
}
137136

137+
// The select clause works as a non-blocking send.
138+
// If there is no receiver, it's a no-op (default case).
138139
select {
139140
case w.s <- NewStatus(Success, ""):
140-
return true
141141
default:
142-
return false
143142
}
144143
}
145144

146-
// Reject declares the waiting pod unschedulable. Returns true if the reject signal
147-
// was successfully delivered, false otherwise.
148-
func (w *waitingPod) Reject(msg string) bool {
145+
// Reject declares the waiting pod unschedulable.
146+
func (w *waitingPod) Reject(msg string) {
149147
w.mu.RLock()
150148
defer w.mu.RUnlock()
151149
for _, timer := range w.pendingPlugins {
152150
timer.Stop()
153151
}
154152

153+
// The select clause works as a non-blocking send.
154+
// If there is no receiver, it's a no-op (default case).
155155
select {
156156
case w.s <- NewStatus(Unschedulable, msg):
157-
return true
158157
default:
159-
return false
160158
}
161159
}

0 commit comments

Comments
 (0)