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
7d14d539
Unverified
Commit
7d14d539
authored
May 01, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
May 01, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #77162 from klueska/upstream-cpu-manager-find-init-containers
Add ability to find init Container IDs in cpumanager reconcileState()
parents
ef99b770
ef27f5f1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
2 deletions
+60
-2
cpu_manager.go
pkg/kubelet/cm/cpumanager/cpu_manager.go
+3
-1
cpu_manager_test.go
pkg/kubelet/cm/cpumanager/cpu_manager_test.go
+57
-1
No files found.
pkg/kubelet/cm/cpumanager/cpu_manager.go
View file @
7d14d539
...
@@ -294,7 +294,9 @@ func (m *manager) reconcileState() (success []reconciledContainer, failure []rec
...
@@ -294,7 +294,9 @@ func (m *manager) reconcileState() (success []reconciledContainer, failure []rec
}
}
func
findContainerIDByName
(
status
*
v1
.
PodStatus
,
name
string
)
(
string
,
error
)
{
func
findContainerIDByName
(
status
*
v1
.
PodStatus
,
name
string
)
(
string
,
error
)
{
for
_
,
container
:=
range
status
.
ContainerStatuses
{
allStatuses
:=
status
.
InitContainerStatuses
allStatuses
=
append
(
allStatuses
,
status
.
ContainerStatuses
...
)
for
_
,
container
:=
range
allStatuses
{
if
container
.
Name
==
name
&&
container
.
ContainerID
!=
""
{
if
container
.
Name
==
name
&&
container
.
ContainerID
!=
""
{
cid
:=
&
kubecontainer
.
ContainerID
{}
cid
:=
&
kubecontainer
.
ContainerID
{}
err
:=
cid
.
ParseString
(
container
.
ContainerID
)
err
:=
cid
.
ParseString
(
container
.
ContainerID
)
...
...
pkg/kubelet/cm/cpumanager/cpu_manager_test.go
View file @
7d14d539
...
@@ -359,6 +359,7 @@ func TestReconcileState(t *testing.T) {
...
@@ -359,6 +359,7 @@ func TestReconcileState(t *testing.T) {
stAssignments
state
.
ContainerCPUAssignments
stAssignments
state
.
ContainerCPUAssignments
stDefaultCPUSet
cpuset
.
CPUSet
stDefaultCPUSet
cpuset
.
CPUSet
updateErr
error
updateErr
error
expectSucceededContainerName
string
expectFailedContainerName
string
expectFailedContainerName
string
}{
}{
{
{
...
@@ -392,6 +393,41 @@ func TestReconcileState(t *testing.T) {
...
@@ -392,6 +393,41 @@ func TestReconcileState(t *testing.T) {
},
},
stDefaultCPUSet
:
cpuset
.
NewCPUSet
(
3
,
4
,
5
,
6
,
7
),
stDefaultCPUSet
:
cpuset
.
NewCPUSet
(
3
,
4
,
5
,
6
,
7
),
updateErr
:
nil
,
updateErr
:
nil
,
expectSucceededContainerName
:
"fakeName"
,
expectFailedContainerName
:
""
,
},
{
description
:
"cpu manager reconcile init container - no error"
,
activePods
:
[]
*
v1
.
Pod
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"fakePodName"
,
UID
:
"fakeUID"
,
},
Spec
:
v1
.
PodSpec
{
InitContainers
:
[]
v1
.
Container
{
{
Name
:
"fakeName"
,
},
},
},
},
},
pspPS
:
v1
.
PodStatus
{
InitContainerStatuses
:
[]
v1
.
ContainerStatus
{
{
Name
:
"fakeName"
,
ContainerID
:
"docker://fakeID"
,
},
},
},
pspFound
:
true
,
stAssignments
:
state
.
ContainerCPUAssignments
{
"fakeID"
:
cpuset
.
NewCPUSet
(
1
,
2
),
},
stDefaultCPUSet
:
cpuset
.
NewCPUSet
(
3
,
4
,
5
,
6
,
7
),
updateErr
:
nil
,
expectSucceededContainerName
:
"fakeName"
,
expectFailedContainerName
:
""
,
expectFailedContainerName
:
""
,
},
},
{
{
...
@@ -416,6 +452,7 @@ func TestReconcileState(t *testing.T) {
...
@@ -416,6 +452,7 @@ func TestReconcileState(t *testing.T) {
stAssignments
:
state
.
ContainerCPUAssignments
{},
stAssignments
:
state
.
ContainerCPUAssignments
{},
stDefaultCPUSet
:
cpuset
.
NewCPUSet
(),
stDefaultCPUSet
:
cpuset
.
NewCPUSet
(),
updateErr
:
nil
,
updateErr
:
nil
,
expectSucceededContainerName
:
""
,
expectFailedContainerName
:
"fakeName"
,
expectFailedContainerName
:
"fakeName"
,
},
},
{
{
...
@@ -447,6 +484,7 @@ func TestReconcileState(t *testing.T) {
...
@@ -447,6 +484,7 @@ func TestReconcileState(t *testing.T) {
stAssignments
:
state
.
ContainerCPUAssignments
{},
stAssignments
:
state
.
ContainerCPUAssignments
{},
stDefaultCPUSet
:
cpuset
.
NewCPUSet
(),
stDefaultCPUSet
:
cpuset
.
NewCPUSet
(),
updateErr
:
nil
,
updateErr
:
nil
,
expectSucceededContainerName
:
""
,
expectFailedContainerName
:
"fakeName"
,
expectFailedContainerName
:
"fakeName"
,
},
},
{
{
...
@@ -480,6 +518,7 @@ func TestReconcileState(t *testing.T) {
...
@@ -480,6 +518,7 @@ func TestReconcileState(t *testing.T) {
},
},
stDefaultCPUSet
:
cpuset
.
NewCPUSet
(
1
,
2
,
3
,
4
,
5
,
6
,
7
),
stDefaultCPUSet
:
cpuset
.
NewCPUSet
(
1
,
2
,
3
,
4
,
5
,
6
,
7
),
updateErr
:
nil
,
updateErr
:
nil
,
expectSucceededContainerName
:
""
,
expectFailedContainerName
:
"fakeName"
,
expectFailedContainerName
:
"fakeName"
,
},
},
{
{
...
@@ -513,6 +552,7 @@ func TestReconcileState(t *testing.T) {
...
@@ -513,6 +552,7 @@ func TestReconcileState(t *testing.T) {
},
},
stDefaultCPUSet
:
cpuset
.
NewCPUSet
(
3
,
4
,
5
,
6
,
7
),
stDefaultCPUSet
:
cpuset
.
NewCPUSet
(
3
,
4
,
5
,
6
,
7
),
updateErr
:
fmt
.
Errorf
(
"fake container update error"
),
updateErr
:
fmt
.
Errorf
(
"fake container update error"
),
expectSucceededContainerName
:
""
,
expectFailedContainerName
:
"fakeName"
,
expectFailedContainerName
:
"fakeName"
,
},
},
}
}
...
@@ -538,7 +578,22 @@ func TestReconcileState(t *testing.T) {
...
@@ -538,7 +578,22 @@ func TestReconcileState(t *testing.T) {
},
},
}
}
_
,
failure
:=
mgr
.
reconcileState
()
success
,
failure
:=
mgr
.
reconcileState
()
if
testCase
.
expectSucceededContainerName
!=
""
{
// Search succeeded reconciled containers for the supplied name.
foundSucceededContainer
:=
false
for
_
,
reconciled
:=
range
success
{
if
reconciled
.
containerName
==
testCase
.
expectSucceededContainerName
{
foundSucceededContainer
=
true
break
}
}
if
!
foundSucceededContainer
{
t
.
Errorf
(
"%v"
,
testCase
.
description
)
t
.
Errorf
(
"Expected reconciliation success for container: %s"
,
testCase
.
expectSucceededContainerName
)
}
}
if
testCase
.
expectFailedContainerName
!=
""
{
if
testCase
.
expectFailedContainerName
!=
""
{
// Search failed reconciled containers for the supplied name.
// Search failed reconciled containers for the supplied name.
...
@@ -550,6 +605,7 @@ func TestReconcileState(t *testing.T) {
...
@@ -550,6 +605,7 @@ func TestReconcileState(t *testing.T) {
}
}
}
}
if
!
foundFailedContainer
{
if
!
foundFailedContainer
{
t
.
Errorf
(
"%v"
,
testCase
.
description
)
t
.
Errorf
(
"Expected reconciliation failure for container: %s"
,
testCase
.
expectFailedContainerName
)
t
.
Errorf
(
"Expected reconciliation failure for container: %s"
,
testCase
.
expectFailedContainerName
)
}
}
}
}
...
...
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