fix #45780 slightly differently

This commit is contained in:
Mike Danese 2017-06-28 11:42:49 +02:00
parent d462b4cbc8
commit 1aede99aba

View File

@ -1111,12 +1111,13 @@ func (dsc *DaemonSetsController) nodeShouldRunDaemonPod(node *v1.Node, ds *exten
return false, false, false, err return false, false, false, err
} }
var insufficientResourceErr error
for _, r := range reasons { for _, r := range reasons {
glog.V(4).Infof("DaemonSet Predicates failed on node %s for ds '%s/%s' for reason: %v", node.Name, ds.ObjectMeta.Namespace, ds.ObjectMeta.Name, r.GetReason()) glog.V(4).Infof("DaemonSet Predicates failed on node %s for ds '%s/%s' for reason: %v", node.Name, ds.ObjectMeta.Namespace, ds.ObjectMeta.Name, r.GetReason())
switch reason := r.(type) { switch reason := r.(type) {
case *predicates.InsufficientResourceError: case *predicates.InsufficientResourceError:
dsc.eventRecorder.Eventf(ds, v1.EventTypeWarning, FailedPlacementReason, "failed to place pod on %q: %s", node.ObjectMeta.Name, reason.Error()) insufficientResourceErr = reason
shouldSchedule = false
case *predicates.PredicateFailureError: case *predicates.PredicateFailureError:
var emitEvent bool var emitEvent bool
// we try to partition predicates into two partitions here: intentional on the part of the operator and not. // we try to partition predicates into two partitions here: intentional on the part of the operator and not.
@ -1128,10 +1129,11 @@ func (dsc *DaemonSetsController) nodeShouldRunDaemonPod(node *v1.Node, ds *exten
predicates.ErrNodeLabelPresenceViolated, predicates.ErrNodeLabelPresenceViolated,
// this one is probably intentional since it's a workaround for not having // this one is probably intentional since it's a workaround for not having
// pod hard anti affinity. // pod hard anti affinity.
predicates.ErrPodNotFitsHostPorts, predicates.ErrPodNotFitsHostPorts:
// DaemonSet is expected to respect taints and tolerations
predicates.ErrTaintsTolerationsNotMatch:
wantToRun, shouldSchedule, shouldContinueRunning = false, false, false wantToRun, shouldSchedule, shouldContinueRunning = false, false, false
case predicates.ErrTaintsTolerationsNotMatch:
// DaemonSet is expected to respect taints and tolerations
wantToRun, shouldSchedule, shouldContinueRunning = false, false, true
// unintentional // unintentional
case case
predicates.ErrDiskConflict, predicates.ErrDiskConflict,
@ -1160,6 +1162,12 @@ func (dsc *DaemonSetsController) nodeShouldRunDaemonPod(node *v1.Node, ds *exten
} }
} }
} }
// only emit this event if insufficient resource is the only thing
// preventing the daemon pod from scheduling
if shouldSchedule && insufficientResourceErr != nil {
dsc.eventRecorder.Eventf(ds, v1.EventTypeWarning, FailedPlacementReason, "failed to place pod on %q: %s", node.ObjectMeta.Name, insufficientResourceErr.Error())
shouldSchedule = false
}
return return
} }