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
1a91ffde
Unverified
Commit
1a91ffde
authored
Mar 21, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Mar 21, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #74927 from jiayingz/automated-cherry-pick-of-#73824-upstream-release-1.13
Automated cherry pick of #73824: Checks whether we have cached runtime state before starting a
parents
748dd2ce
b1e7ef42
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
4 deletions
+25
-4
manager.go
pkg/kubelet/cm/devicemanager/manager.go
+24
-4
kubelet_node_status.go
pkg/kubelet/kubelet_node_status.go
+1
-0
No files found.
pkg/kubelet/cm/devicemanager/manager.go
View file @
1a91ffde
...
@@ -311,10 +311,7 @@ func (m *ManagerImpl) isVersionCompatibleWithPlugin(versions []string) bool {
...
@@ -311,10 +311,7 @@ func (m *ManagerImpl) isVersionCompatibleWithPlugin(versions []string) bool {
return
false
return
false
}
}
// Allocate is the call that you can use to allocate a set of devices
func
(
m
*
ManagerImpl
)
allocatePodResources
(
pod
*
v1
.
Pod
)
error
{
// from the registered device plugins.
func
(
m
*
ManagerImpl
)
Allocate
(
node
*
schedulercache
.
NodeInfo
,
attrs
*
lifecycle
.
PodAdmitAttributes
)
error
{
pod
:=
attrs
.
Pod
devicesToReuse
:=
make
(
map
[
string
]
sets
.
String
)
devicesToReuse
:=
make
(
map
[
string
]
sets
.
String
)
for
_
,
container
:=
range
pod
.
Spec
.
InitContainers
{
for
_
,
container
:=
range
pod
.
Spec
.
InitContainers
{
if
err
:=
m
.
allocateContainerResources
(
pod
,
&
container
,
devicesToReuse
);
err
!=
nil
{
if
err
:=
m
.
allocateContainerResources
(
pod
,
&
container
,
devicesToReuse
);
err
!=
nil
{
...
@@ -328,6 +325,18 @@ func (m *ManagerImpl) Allocate(node *schedulercache.NodeInfo, attrs *lifecycle.P
...
@@ -328,6 +325,18 @@ func (m *ManagerImpl) Allocate(node *schedulercache.NodeInfo, attrs *lifecycle.P
}
}
m
.
podDevices
.
removeContainerAllocatedResources
(
string
(
pod
.
UID
),
container
.
Name
,
devicesToReuse
)
m
.
podDevices
.
removeContainerAllocatedResources
(
string
(
pod
.
UID
),
container
.
Name
,
devicesToReuse
)
}
}
return
nil
}
// Allocate is the call that you can use to allocate a set of devices
// from the registered device plugins.
func
(
m
*
ManagerImpl
)
Allocate
(
node
*
schedulercache
.
NodeInfo
,
attrs
*
lifecycle
.
PodAdmitAttributes
)
error
{
pod
:=
attrs
.
Pod
err
:=
m
.
allocatePodResources
(
pod
)
if
err
!=
nil
{
klog
.
Errorf
(
"Failed to allocate device plugin resource for pod %s: %v"
,
string
(
pod
.
UID
),
err
)
return
err
}
m
.
mutex
.
Lock
()
m
.
mutex
.
Lock
()
defer
m
.
mutex
.
Unlock
()
defer
m
.
mutex
.
Unlock
()
...
@@ -717,6 +726,7 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
...
@@ -717,6 +726,7 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
func
(
m
*
ManagerImpl
)
GetDeviceRunContainerOptions
(
pod
*
v1
.
Pod
,
container
*
v1
.
Container
)
(
*
DeviceRunContainerOptions
,
error
)
{
func
(
m
*
ManagerImpl
)
GetDeviceRunContainerOptions
(
pod
*
v1
.
Pod
,
container
*
v1
.
Container
)
(
*
DeviceRunContainerOptions
,
error
)
{
podUID
:=
string
(
pod
.
UID
)
podUID
:=
string
(
pod
.
UID
)
contName
:=
container
.
Name
contName
:=
container
.
Name
needsReAllocate
:=
false
for
k
:=
range
container
.
Resources
.
Limits
{
for
k
:=
range
container
.
Resources
.
Limits
{
resource
:=
string
(
k
)
resource
:=
string
(
k
)
if
!
m
.
isDevicePluginResource
(
resource
)
{
if
!
m
.
isDevicePluginResource
(
resource
)
{
...
@@ -726,6 +736,16 @@ func (m *ManagerImpl) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Co
...
@@ -726,6 +736,16 @@ func (m *ManagerImpl) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Co
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
// This is a device plugin resource yet we don't have cached
// resource state. This is likely due to a race during node
// restart. We re-issue allocate request to cover this race.
if
m
.
podDevices
.
containerDevices
(
podUID
,
contName
,
resource
)
==
nil
{
needsReAllocate
=
true
}
}
if
needsReAllocate
{
klog
.
V
(
2
)
.
Infof
(
"needs re-allocate device plugin resources for pod %s"
,
podUID
)
m
.
allocatePodResources
(
pod
)
}
}
m
.
mutex
.
Lock
()
m
.
mutex
.
Lock
()
defer
m
.
mutex
.
Unlock
()
defer
m
.
mutex
.
Unlock
()
...
...
pkg/kubelet/kubelet_node_status.go
View file @
1a91ffde
...
@@ -134,6 +134,7 @@ func (kl *Kubelet) reconcileExtendedResource(initialNode, node *v1.Node) bool {
...
@@ -134,6 +134,7 @@ func (kl *Kubelet) reconcileExtendedResource(initialNode, node *v1.Node) bool {
requiresUpdate
:=
false
requiresUpdate
:=
false
for
k
:=
range
node
.
Status
.
Capacity
{
for
k
:=
range
node
.
Status
.
Capacity
{
if
v1helper
.
IsExtendedResourceName
(
k
)
{
if
v1helper
.
IsExtendedResourceName
(
k
)
{
klog
.
Infof
(
"Zero out resource %s capacity in existing node."
,
k
)
node
.
Status
.
Capacity
[
k
]
=
*
resource
.
NewQuantity
(
int64
(
0
),
resource
.
DecimalSI
)
node
.
Status
.
Capacity
[
k
]
=
*
resource
.
NewQuantity
(
int64
(
0
),
resource
.
DecimalSI
)
node
.
Status
.
Allocatable
[
k
]
=
*
resource
.
NewQuantity
(
int64
(
0
),
resource
.
DecimalSI
)
node
.
Status
.
Allocatable
[
k
]
=
*
resource
.
NewQuantity
(
int64
(
0
),
resource
.
DecimalSI
)
requiresUpdate
=
true
requiresUpdate
=
true
...
...
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