Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
cd6c288d
Commit
cd6c288d
authored
Mar 02, 2016
by
Mike Danese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix daemonset flapping when using a host port
parent
5214ae1c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
controller.go
pkg/controller/daemon/controller.go
+5
-0
controller_test.go
pkg/controller/daemon/controller_test.go
+30
-0
No files found.
pkg/controller/daemon/controller.go
View file @
cd6c288d
...
@@ -601,6 +601,11 @@ func (dsc *DaemonSetsController) nodeShouldRunDaemonPod(node *api.Node, ds *exte
...
@@ -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
)
...
...
pkg/controller/daemon/controller_test.go
View file @
cd6c288d
...
@@ -284,6 +284,36 @@ func TestPortConflictNodeDaemonDoesNotLaunchPod(t *testing.T) {
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment