Merge pull request #20936 from mesosphere/jdef_fix_panic_in_procurement

Auto commit by PR queue bot
This commit is contained in:
k8s-merge-robot 2016-02-09 19:58:25 -08:00
commit 8084479be2
2 changed files with 7 additions and 1 deletions

View File

@ -99,6 +99,9 @@ func New(
// "backs off" when it can't find an offer that matches up with a pod. // "backs off" when it can't find an offer that matches up with a pod.
// The backoff period for a pod can terminate sooner if an offer becomes // The backoff period for a pod can terminate sooner if an offer becomes
// available that matches up. // available that matches up.
// TODO(jdef) this will never match for a pod that uses a node selector,
// since we're passing a nil *api.Node here.
return !task.Has(podtask.Launched) && ps.Fit(task, offer, nil) return !task.Has(podtask.Launched) && ps.Fit(task, offer, nil)
default: default:
// no point in continuing to check for matching offers // no point in continuing to check for matching offers

View File

@ -61,6 +61,8 @@ func NewDefaultProcurement(prototype *mesos.ExecutorInfo, eir executorinfo.Regis
// //
// In contrast T.Spec is meant not to be filled by the procurement chain // In contrast T.Spec is meant not to be filled by the procurement chain
// but rather by a final scheduler instance. // but rather by a final scheduler instance.
//
// api.Node is an optional (possibly nil) param.
type Procurement interface { type Procurement interface {
Procure(*T, *api.Node, *ProcureState) error Procure(*T, *api.Node, *ProcureState) error
} }
@ -129,7 +131,8 @@ func NewNodeProcurement() Procurement {
// check the NodeSelector // check the NodeSelector
if len(t.Pod.Spec.NodeSelector) > 0 { if len(t.Pod.Spec.NodeSelector) > 0 {
if n.Labels == nil { // *api.Node is optional for procurement
if n == nil || n.Labels == nil {
return fmt.Errorf( return fmt.Errorf(
"NodeSelector %v does not match empty labels of pod %s/%s", "NodeSelector %v does not match empty labels of pod %s/%s",
t.Pod.Spec.NodeSelector, t.Pod.Namespace, t.Pod.Name, t.Pod.Spec.NodeSelector, t.Pod.Namespace, t.Pod.Name,