mirror of https://github.com/k3s-io/k3s
Merge pull request #22416 from mikedanese/ds-fixer
Fix daemonset flapping when using a host portpull/6/head
commit
1e70f17c6a
|
@ -601,6 +601,11 @@ func (dsc *DaemonSetsController) nodeShouldRunDaemonPod(node *api.Node, ds *exte
|
||||||
if pod.Spec.NodeName != node.Name {
|
if pod.Spec.NodeName != node.Name {
|
||||||
continue
|
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 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
pods = append(pods, pod)
|
pods = append(pods, pod)
|
||||||
}
|
}
|
||||||
_, notFittingCPU, notFittingMemory := predicates.CheckPodsExceedingFreeResources(pods, node.Status.Allocatable)
|
_, notFittingCPU, notFittingMemory := predicates.CheckPodsExceedingFreeResources(pods, node.Status.Allocatable)
|
||||||
|
|
|
@ -284,6 +284,36 @@ func TestPortConflictNodeDaemonDoesNotLaunchPod(t *testing.T) {
|
||||||
manager.podStore.Add(&api.Pod{
|
manager.podStore.Add(&api.Pod{
|
||||||
Spec: podSpec,
|
Spec: podSpec,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ds := newDaemonSet("foo")
|
||||||
|
ds.Spec.Template.Spec = podSpec
|
||||||
|
manager.dsStore.Add(ds)
|
||||||
|
syncAndValidateDaemonSets(t, manager, ds, podControl, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that if the node is already scheduled with a pod using a host port
|
||||||
|
// but belonging to the same daemonset, we don't delete that pod
|
||||||
|
//
|
||||||
|
// Issue: https://github.com/kubernetes/kubernetes/issues/22309
|
||||||
|
func TestPortConflictWithSameDaemonPodDoesNotDeletePod(t *testing.T) {
|
||||||
|
podSpec := api.PodSpec{
|
||||||
|
NodeName: "port-conflict",
|
||||||
|
Containers: []api.Container{{
|
||||||
|
Ports: []api.ContainerPort{{
|
||||||
|
HostPort: 666,
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
}
|
||||||
|
manager, podControl := newTestController()
|
||||||
|
node := newNode("port-conflict", nil)
|
||||||
|
manager.nodeStore.Add(node)
|
||||||
|
manager.podStore.Add(&api.Pod{
|
||||||
|
ObjectMeta: api.ObjectMeta{
|
||||||
|
Labels: simpleDaemonSetLabel,
|
||||||
|
Namespace: api.NamespaceDefault,
|
||||||
|
},
|
||||||
|
Spec: podSpec,
|
||||||
|
})
|
||||||
ds := newDaemonSet("foo")
|
ds := newDaemonSet("foo")
|
||||||
ds.Spec.Template.Spec = podSpec
|
ds.Spec.Template.Spec = podSpec
|
||||||
manager.dsStore.Add(ds)
|
manager.dsStore.Add(ds)
|
||||||
|
|
Loading…
Reference in New Issue