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
a482789c
Commit
a482789c
authored
Feb 29, 2016
by
gmarek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Workaround proxy deadlock in metrics gatherer.
parent
38a30490
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
9 deletions
+28
-9
kubelet_metrics.go
pkg/metrics/kubelet_metrics.go
+23
-9
metrics_grabber.go
pkg/metrics/metrics_grabber.go
+5
-0
No files found.
pkg/metrics/kubelet_metrics.go
View file @
a482789c
...
...
@@ -18,6 +18,7 @@ package metrics
import
(
"fmt"
"time"
"k8s.io/kubernetes/pkg/util/sets"
...
...
@@ -133,14 +134,27 @@ func parseKubeletMetrics(data string) (KubeletMetrics, error) {
}
func
(
g
*
MetricsGrabber
)
getMetricsFromNode
(
nodeName
string
,
kubeletPort
int
)
(
string
,
error
)
{
rawOutput
,
err
:=
g
.
client
.
Get
()
.
Prefix
(
"proxy"
)
.
Resource
(
"nodes"
)
.
Name
(
fmt
.
Sprintf
(
"%v:%v"
,
nodeName
,
kubeletPort
))
.
Suffix
(
"metrics"
)
.
Do
()
.
Raw
()
if
err
!=
nil
{
return
""
,
err
// There's a problem with timing out during proxy. Wrapping this in a goroutine to prevent deadlock.
// Hanging goroutine will be leaked.
finished
:=
make
(
chan
struct
{})
var
err
error
var
rawOutput
[]
byte
go
func
()
{
rawOutput
,
err
=
g
.
client
.
Get
()
.
Prefix
(
"proxy"
)
.
Resource
(
"nodes"
)
.
Name
(
fmt
.
Sprintf
(
"%v:%v"
,
nodeName
,
kubeletPort
))
.
Suffix
(
"metrics"
)
.
Do
()
.
Raw
()
finished
<-
struct
{}{}
}()
select
{
case
<-
time
.
After
(
ProxyTimeout
)
:
return
""
,
fmt
.
Errorf
(
"Timed out when waiting for proxy to gather metrics from %v"
,
nodeName
)
case
<-
finished
:
if
err
!=
nil
{
return
""
,
err
}
return
string
(
rawOutput
),
nil
}
return
string
(
rawOutput
),
nil
}
pkg/metrics/metrics_grabber.go
View file @
a482789c
...
...
@@ -19,6 +19,7 @@ package metrics
import
(
"fmt"
"strings"
"time"
"k8s.io/kubernetes/pkg/api"
client
"k8s.io/kubernetes/pkg/client/unversioned"
...
...
@@ -29,6 +30,10 @@ import (
"github.com/golang/glog"
)
const
(
ProxyTimeout
=
2
*
time
.
Minute
)
type
MetricsCollection
struct
{
ApiServerMetrics
ApiServerMetrics
ControllerManagerMetrics
ControllerManagerMetrics
...
...
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