Merge pull request #87936 from Huang-Wei/waitingPods-glitch

Refine WaitingPod interface for scheduler Permit plugin
This commit is contained in:
Kubernetes Prow Robot 2020-02-10 09:23:54 -08:00 committed by GitHub
commit db9123e50e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 15 deletions

View File

@ -202,11 +202,9 @@ type WaitingPod interface {
// Allow declares the waiting pod is allowed to be scheduled by plugin pluginName.
// If this is the last remaining plugin to allow, then a success signal is delivered
// to unblock the pod.
// Returns true if the allow signal was successfully dealt with, false otherwise.
Allow(pluginName string) bool
// Reject declares the waiting pod unschedulable. Returns true if the reject signal
// was successfully delivered, false otherwise.
Reject(msg string) bool
Allow(pluginName string)
// Reject declares the waiting pod unschedulable.
Reject(msg string)
}
// Plugin is the parent type for all the scheduling framework plugins.

View File

@ -121,8 +121,7 @@ func (w *waitingPod) GetPendingPlugins() []string {
// Allow declares the waiting pod is allowed to be scheduled by plugin pluginName.
// If this is the last remaining plugin to allow, then a success signal is delivered
// to unblock the pod.
// Returns true if the allow signal was successfully dealt with, false otherwise.
func (w *waitingPod) Allow(pluginName string) bool {
func (w *waitingPod) Allow(pluginName string) {
w.mu.Lock()
defer w.mu.Unlock()
if timer, exist := w.pendingPlugins[pluginName]; exist {
@ -132,30 +131,29 @@ func (w *waitingPod) Allow(pluginName string) bool {
// Only signal success status after all plugins have allowed
if len(w.pendingPlugins) != 0 {
return true
return
}
// The select clause works as a non-blocking send.
// If there is no receiver, it's a no-op (default case).
select {
case w.s <- NewStatus(Success, ""):
return true
default:
return false
}
}
// Reject declares the waiting pod unschedulable. Returns true if the reject signal
// was successfully delivered, false otherwise.
func (w *waitingPod) Reject(msg string) bool {
// Reject declares the waiting pod unschedulable.
func (w *waitingPod) Reject(msg string) {
w.mu.RLock()
defer w.mu.RUnlock()
for _, timer := range w.pendingPlugins {
timer.Stop()
}
// The select clause works as a non-blocking send.
// If there is no receiver, it's a no-op (default case).
select {
case w.s <- NewStatus(Unschedulable, msg):
return true
default:
return false
}
}