Skip to content

Commit

Permalink
only include running and pending pods in daemonset should place calcu…
Browse files Browse the repository at this point in the history
…lation
  • Loading branch information
mikedanese committed Apr 6, 2016
1 parent 4f32951 commit 1428429
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/controller/daemon/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,9 @@ func (dsc *DaemonSetsController) nodeShouldRunDaemonPod(node *api.Node, ds *exte
if pod.Spec.NodeName != node.Name {
continue
}
if pod.Status.Phase == api.PodSucceeded || pod.Status.Phase == api.PodFailed {
continue
}
// ignore pods that belong to the daemonset when taking into account wheter
// a daemonset should bind to a node.
if pds := dsc.getPodDaemonSet(pod); pds != nil && ds.Name == pds.Name {
Expand Down
29 changes: 29 additions & 0 deletions pkg/controller/daemon/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,35 @@ func TestInsufficentCapacityNodeDaemonDoesNotLaunchPod(t *testing.T) {
syncAndValidateDaemonSets(t, manager, ds, podControl, 0, 0)
}

func TestSufficentCapacityWithTerminatedPodsDaemonLaunchesPod(t *testing.T) {
podSpec := api.PodSpec{
NodeName: "too-much-mem",
Containers: []api.Container{{
Resources: api.ResourceRequirements{
Requests: api.ResourceList{
api.ResourceMemory: resource.MustParse("75M"),
api.ResourceCPU: resource.MustParse("75m"),
},
},
}},
}
manager, podControl := newTestController()
node := newNode("too-much-mem", nil)
node.Status.Allocatable = api.ResourceList{
api.ResourceMemory: resource.MustParse("100M"),
api.ResourceCPU: resource.MustParse("200m"),
}
manager.nodeStore.Add(node)
manager.podStore.Add(&api.Pod{
Spec: podSpec,
Status: api.PodStatus{Phase: api.PodSucceeded},
})
ds := newDaemonSet("foo")
ds.Spec.Template.Spec = podSpec
manager.dsStore.Add(ds)
syncAndValidateDaemonSets(t, manager, ds, podControl, 1, 0)
}

// DaemonSets should place onto nodes with sufficient free resource
func TestSufficentCapacityNodeDaemonLaunchesPod(t *testing.T) {
podSpec := api.PodSpec{
Expand Down

1 comment on commit 1428429

@k8s-teamcity-mesosphere

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity OSS :: Kubernetes Mesos :: 4 - Smoke Tests Build 20708 outcome was SUCCESS
Summary: Tests passed: 1, ignored: 269 Build time: 00:08:19

Please sign in to comment.