From eb22c8c14c7a43ded22dd66c6572259259dd2969 Mon Sep 17 00:00:00 2001 From: James DeFelice Date: Tue, 9 Feb 2016 23:33:17 +0000 Subject: [PATCH] handle nil *api.Node in procurement and added TODO for a better long term fix --- contrib/mesos/pkg/scheduler/components/scheduler.go | 3 +++ contrib/mesos/pkg/scheduler/podtask/procurement.go | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/mesos/pkg/scheduler/components/scheduler.go b/contrib/mesos/pkg/scheduler/components/scheduler.go index d1a57c6e1dd..2cffea9bd77 100644 --- a/contrib/mesos/pkg/scheduler/components/scheduler.go +++ b/contrib/mesos/pkg/scheduler/components/scheduler.go @@ -99,6 +99,9 @@ func New( // "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 // 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) default: // no point in continuing to check for matching offers diff --git a/contrib/mesos/pkg/scheduler/podtask/procurement.go b/contrib/mesos/pkg/scheduler/podtask/procurement.go index c86699332e3..652c2233cf6 100644 --- a/contrib/mesos/pkg/scheduler/podtask/procurement.go +++ b/contrib/mesos/pkg/scheduler/podtask/procurement.go @@ -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 // but rather by a final scheduler instance. +// +// api.Node is an optional (possibly nil) param. type Procurement interface { Procure(*T, *api.Node, *ProcureState) error } @@ -129,7 +131,8 @@ func NewNodeProcurement() Procurement { // check the NodeSelector 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( "NodeSelector %v does not match empty labels of pod %s/%s", t.Pod.Spec.NodeSelector, t.Pod.Namespace, t.Pod.Name,