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
8749c5c9
Commit
8749c5c9
authored
Dec 18, 2017
by
vikaschoudhary16
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert back #57278
parent
cdbfff07
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
10 deletions
+15
-10
manager.go
pkg/kubelet/cm/deviceplugin/manager.go
+5
-4
manager_test.go
pkg/kubelet/cm/deviceplugin/manager_test.go
+10
-6
No files found.
pkg/kubelet/cm/deviceplugin/manager.go
View file @
8749c5c9
...
...
@@ -550,10 +550,11 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
podUID
:=
string
(
pod
.
UID
)
contName
:=
container
.
Name
allocatedDevicesUpdated
:=
false
// NOTE: Skipping the Resources.Limits is safe here because:
// 1. If container Spec mentions Limits only, implicitly Requests, equal to Limits, will get added to the Spec.
// 2. If container Spec mentions Limits, which are greater than or less than Requests, will fail at validation.
for
k
,
v
:=
range
container
.
Resources
.
Requests
{
// Extended resources are not allowed to be overcommitted.
// Since device plugin advertises extended resources,
// therefore Requests must be equal to Limits and iterating
// over the Limits should be sufficient.
for
k
,
v
:=
range
container
.
Resources
.
Limits
{
resource
:=
string
(
k
)
needed
:=
int
(
v
.
Value
())
glog
.
V
(
3
)
.
Infof
(
"needs %d %s"
,
needed
,
resource
)
...
...
pkg/kubelet/cm/deviceplugin/manager_test.go
View file @
8749c5c9
...
...
@@ -366,7 +366,7 @@ func (m *MockEndpoint) allocate(devs []string) (*pluginapi.AllocateResponse, err
return
nil
,
nil
}
func
makePod
(
reques
ts
v1
.
ResourceList
)
*
v1
.
Pod
{
func
makePod
(
limi
ts
v1
.
ResourceList
)
*
v1
.
Pod
{
return
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
UID
:
uuid
.
NewUUID
(),
...
...
@@ -375,7 +375,7 @@ func makePod(requests v1.ResourceList) *v1.Pod {
Containers
:
[]
v1
.
Container
{
{
Resources
:
v1
.
ResourceRequirements
{
Requests
:
reques
ts
,
Limits
:
limi
ts
,
},
},
},
...
...
@@ -616,7 +616,7 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
{
Name
:
string
(
uuid
.
NewUUID
()),
Resources
:
v1
.
ResourceRequirements
{
Reques
ts
:
v1
.
ResourceList
{
Limi
ts
:
v1
.
ResourceList
{
v1
.
ResourceName
(
res1
.
resourceName
)
:
res2
.
resourceQuantity
,
},
},
...
...
@@ -624,7 +624,7 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
{
Name
:
string
(
uuid
.
NewUUID
()),
Resources
:
v1
.
ResourceRequirements
{
Reques
ts
:
v1
.
ResourceList
{
Limi
ts
:
v1
.
ResourceList
{
v1
.
ResourceName
(
res1
.
resourceName
)
:
res1
.
resourceQuantity
,
},
},
...
...
@@ -634,7 +634,7 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
{
Name
:
string
(
uuid
.
NewUUID
()),
Resources
:
v1
.
ResourceRequirements
{
Reques
ts
:
v1
.
ResourceList
{
Limi
ts
:
v1
.
ResourceList
{
v1
.
ResourceName
(
res1
.
resourceName
)
:
res2
.
resourceQuantity
,
v1
.
ResourceName
(
res2
.
resourceName
)
:
res2
.
resourceQuantity
,
},
...
...
@@ -643,7 +643,7 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
{
Name
:
string
(
uuid
.
NewUUID
()),
Resources
:
v1
.
ResourceRequirements
{
Reques
ts
:
v1
.
ResourceList
{
Limi
ts
:
v1
.
ResourceList
{
v1
.
ResourceName
(
res1
.
resourceName
)
:
res2
.
resourceQuantity
,
v1
.
ResourceName
(
res2
.
resourceName
)
:
res2
.
resourceQuantity
,
},
...
...
@@ -664,6 +664,10 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
initCont2Devices
:=
testManager
.
podDevices
.
containerDevices
(
podUID
,
initCont2
,
res1
.
resourceName
)
normalCont1Devices
:=
testManager
.
podDevices
.
containerDevices
(
podUID
,
normalCont1
,
res1
.
resourceName
)
normalCont2Devices
:=
testManager
.
podDevices
.
containerDevices
(
podUID
,
normalCont2
,
res1
.
resourceName
)
as
.
Equal
(
1
,
initCont1Devices
.
Len
())
as
.
Equal
(
2
,
initCont2Devices
.
Len
())
as
.
Equal
(
1
,
normalCont1Devices
.
Len
())
as
.
Equal
(
1
,
normalCont2Devices
.
Len
())
as
.
True
(
initCont2Devices
.
IsSuperset
(
initCont1Devices
))
as
.
True
(
initCont2Devices
.
IsSuperset
(
normalCont1Devices
))
as
.
True
(
initCont2Devices
.
IsSuperset
(
normalCont2Devices
))
...
...
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