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
40238163
Unverified
Commit
40238163
authored
Jun 19, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Jun 19, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #78665 from benmoss/automated-cherry-pick-of-#78594-upstream-release-1.14
Automated cherry pick of #78594: Fix memory leak from not closing hcs container handles
parents
d1c99590
b9ab3692
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
9 deletions
+24
-9
cri_stats_provider_windows.go
pkg/kubelet/stats/cri_stats_provider_windows.go
+24
-9
No files found.
pkg/kubelet/stats/cri_stats_provider_windows.go
View file @
40238163
...
...
@@ -19,6 +19,7 @@ limitations under the License.
package
stats
import
(
"fmt"
"time"
"github.com/Microsoft/hcsshim"
...
...
@@ -40,18 +41,11 @@ func (p *criStatsProvider) listContainerNetworkStats() (map[string]*statsapi.Net
stats
:=
make
(
map
[
string
]
*
statsapi
.
NetworkStats
)
for
_
,
c
:=
range
containers
{
c
ontainer
,
err
:=
hcsshim
.
OpenContainer
(
c
.
ID
)
c
stats
,
err
:=
fetchContainerStats
(
c
)
if
err
!=
nil
{
klog
.
V
(
4
)
.
Infof
(
"Failed to
open
container %q with error '%v', continue to get stats for other containers"
,
c
.
ID
,
err
)
klog
.
V
(
4
)
.
Infof
(
"Failed to
fetch statistics for
container %q with error '%v', continue to get stats for other containers"
,
c
.
ID
,
err
)
continue
}
cstats
,
err
:=
container
.
Statistics
()
if
err
!=
nil
{
klog
.
V
(
4
)
.
Infof
(
"Failed to get statistics for container %q with error '%v', continue to get stats for other containers"
,
c
.
ID
,
err
)
continue
}
if
len
(
cstats
.
Network
)
>
0
{
stats
[
c
.
ID
]
=
hcsStatsToNetworkStats
(
cstats
.
Timestamp
,
cstats
.
Network
)
}
...
...
@@ -60,6 +54,27 @@ func (p *criStatsProvider) listContainerNetworkStats() (map[string]*statsapi.Net
return
stats
,
nil
}
func
fetchContainerStats
(
c
hcsshim
.
ContainerProperties
)
(
stats
hcsshim
.
Statistics
,
err
error
)
{
var
(
container
hcsshim
.
Container
)
container
,
err
=
hcsshim
.
OpenContainer
(
c
.
ID
)
if
err
!=
nil
{
return
}
defer
func
()
{
if
closeErr
:=
container
.
Close
();
closeErr
!=
nil
{
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"failed to close container after error %v; close error: %v"
,
err
,
closeErr
)
}
else
{
err
=
closeErr
}
}
}()
return
container
.
Statistics
()
}
// hcsStatsToNetworkStats converts hcsshim.Statistics.Network to statsapi.NetworkStats
func
hcsStatsToNetworkStats
(
timestamp
time
.
Time
,
hcsStats
[]
hcsshim
.
NetworkStats
)
*
statsapi
.
NetworkStats
{
result
:=
&
statsapi
.
NetworkStats
{
...
...
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