Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1630 from piosz/events
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

[rescheduler] actually wait for pod to be scheduled

kubernetes/kubernetes#29023
  • Loading branch information
Kubernetes Submit Queue authored Aug 26, 2016
2 parents 234456b + 0ee0795 commit 3bdca8e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions hack/verify-flags/known-flags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ default-ssl-certificate
housekeeping-interval
system-namespace
initial-delay
pod-scheduled-timeout
netrc-dir
publish-command
triager-url
24 changes: 20 additions & 4 deletions rescheduler/rescheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
kube_client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fields"
kubectl_util "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"

"github.com/golang/glog"
Expand Down Expand Up @@ -57,6 +58,10 @@ var (
initialDelay = flags.Duration("initial-delay", 2*time.Minute,
`How long should rescheduler wait after start to make sure
all critical addons had a chance to start.`)

podScheduledTimeout = flags.Duration("pod-scheduled-timeout", 10*time.Minute,
`How long should rescheduler wait for critical pod to be scheduled
after evicting pods to make a spot for it.`)
)

func main() {
Expand Down Expand Up @@ -119,7 +124,7 @@ func main() {
glog.Warningf("%+v", err)
} else {
podsBeingProcessed.Add(pod)
go waitForScheduled(podsBeingProcessed, pod)
go waitForScheduled(kubeClient, podsBeingProcessed, pod)
}
}
}
Expand All @@ -130,10 +135,21 @@ func main() {
}
}

func waitForScheduled(podsBeingProcessed *podSet, pod *kube_api.Pod) {
// TODO(piosz): periodically check whether pod is actually scheduled
func waitForScheduled(client *kube_client.Client, podsBeingProcessed *podSet, pod *kube_api.Pod) {
glog.Infof("Waiting for pod %s to be scheduled", podId(pod))
time.Sleep(10 * time.Minute)
err := wait.Poll(time.Second, *podScheduledTimeout, func() (bool, error) {
p, err := client.Pods(pod.Namespace).Get(pod.Name)
if err != nil {
glog.Warningf("Error while getting pod %s: %v", podId(pod), err)
return false, nil
}
return p.Spec.NodeName != "", nil
})
if err != nil {
glog.Warningf("Timeout while waiting for pod %s to be scheduled after %v.", podId(pod), *podScheduledTimeout)
} else {
glog.Infof("Pod %v was successfully scheduled.", podId(pod))
}
podsBeingProcessed.Remove(pod)
}

Expand Down

0 comments on commit 3bdca8e

Please sign in to comment.