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
289a60ad
Unverified
Commit
289a60ad
authored
Feb 13, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Feb 13, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #72709 from changyaowei/pleg_relist
When pleg channel is full, discard events and record its count
parents
a92729a3
19f73899
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
2 deletions
+82
-2
metrics.go
pkg/kubelet/metrics/metrics.go
+10
-0
generic.go
pkg/kubelet/pleg/generic.go
+6
-1
generic_test.go
pkg/kubelet/pleg/generic_test.go
+66
-1
No files found.
pkg/kubelet/metrics/metrics.go
View file @
289a60ad
...
@@ -39,6 +39,7 @@ const (
...
@@ -39,6 +39,7 @@ const (
CgroupManagerOperationsKey
=
"cgroup_manager_latency_microseconds"
CgroupManagerOperationsKey
=
"cgroup_manager_latency_microseconds"
PodWorkerStartLatencyKey
=
"pod_worker_start_latency_microseconds"
PodWorkerStartLatencyKey
=
"pod_worker_start_latency_microseconds"
PLEGRelistLatencyKey
=
"pleg_relist_latency_microseconds"
PLEGRelistLatencyKey
=
"pleg_relist_latency_microseconds"
PLEGDiscardEventsKey
=
"pleg_discard_events"
PLEGRelistIntervalKey
=
"pleg_relist_interval_microseconds"
PLEGRelistIntervalKey
=
"pleg_relist_interval_microseconds"
EvictionStatsAgeKey
=
"eviction_stats_age_microseconds"
EvictionStatsAgeKey
=
"eviction_stats_age_microseconds"
VolumeStatsCapacityBytesKey
=
"volume_stats_capacity_bytes"
VolumeStatsCapacityBytesKey
=
"volume_stats_capacity_bytes"
...
@@ -124,6 +125,14 @@ var (
...
@@ -124,6 +125,14 @@ var (
Help
:
"Latency in microseconds for relisting pods in PLEG."
,
Help
:
"Latency in microseconds for relisting pods in PLEG."
,
},
},
)
)
PLEGDiscardEvents
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Subsystem
:
KubeletSubsystem
,
Name
:
PLEGDiscardEventsKey
,
Help
:
"The number of discard events in PLEG."
,
},
[]
string
{},
)
PLEGRelistInterval
=
prometheus
.
NewSummary
(
PLEGRelistInterval
=
prometheus
.
NewSummary
(
prometheus
.
SummaryOpts
{
prometheus
.
SummaryOpts
{
Subsystem
:
KubeletSubsystem
,
Subsystem
:
KubeletSubsystem
,
...
@@ -246,6 +255,7 @@ func Register(containerCache kubecontainer.RuntimeCache, collectors ...prometheu
...
@@ -246,6 +255,7 @@ func Register(containerCache kubecontainer.RuntimeCache, collectors ...prometheu
prometheus
.
MustRegister
(
ContainersPerPodCount
)
prometheus
.
MustRegister
(
ContainersPerPodCount
)
prometheus
.
MustRegister
(
newPodAndContainerCollector
(
containerCache
))
prometheus
.
MustRegister
(
newPodAndContainerCollector
(
containerCache
))
prometheus
.
MustRegister
(
PLEGRelistLatency
)
prometheus
.
MustRegister
(
PLEGRelistLatency
)
prometheus
.
MustRegister
(
PLEGDiscardEvents
)
prometheus
.
MustRegister
(
PLEGRelistInterval
)
prometheus
.
MustRegister
(
PLEGRelistInterval
)
prometheus
.
MustRegister
(
RuntimeOperations
)
prometheus
.
MustRegister
(
RuntimeOperations
)
prometheus
.
MustRegister
(
RuntimeOperationsLatency
)
prometheus
.
MustRegister
(
RuntimeOperationsLatency
)
...
...
pkg/kubelet/pleg/generic.go
View file @
289a60ad
...
@@ -265,7 +265,12 @@ func (g *GenericPLEG) relist() {
...
@@ -265,7 +265,12 @@ func (g *GenericPLEG) relist() {
if
events
[
i
]
.
Type
==
ContainerChanged
{
if
events
[
i
]
.
Type
==
ContainerChanged
{
continue
continue
}
}
g
.
eventChannel
<-
events
[
i
]
select
{
case
g
.
eventChannel
<-
events
[
i
]
:
default
:
metrics
.
PLEGDiscardEvents
.
WithLabelValues
()
.
Inc
()
klog
.
Error
(
"event channel is full, discard this relist() cycle event"
)
}
}
}
}
}
...
...
pkg/kubelet/pleg/generic_test.go
View file @
289a60ad
...
@@ -34,6 +34,8 @@ import (
...
@@ -34,6 +34,8 @@ import (
const
(
const
(
testContainerRuntimeType
=
"fooRuntime"
testContainerRuntimeType
=
"fooRuntime"
// largeChannelCap is a large enough capacity to hold all events in a single test.
largeChannelCap
=
100
)
)
type
TestGenericPLEG
struct
{
type
TestGenericPLEG
struct
{
...
@@ -43,6 +45,10 @@ type TestGenericPLEG struct {
...
@@ -43,6 +45,10 @@ type TestGenericPLEG struct {
}
}
func
newTestGenericPLEG
()
*
TestGenericPLEG
{
func
newTestGenericPLEG
()
*
TestGenericPLEG
{
return
newTestGenericPLEGWithChannelSize
(
largeChannelCap
)
}
func
newTestGenericPLEGWithChannelSize
(
eventChannelCap
int
)
*
TestGenericPLEG
{
fakeRuntime
:=
&
containertest
.
FakeRuntime
{}
fakeRuntime
:=
&
containertest
.
FakeRuntime
{}
clock
:=
clock
.
NewFakeClock
(
time
.
Time
{})
clock
:=
clock
.
NewFakeClock
(
time
.
Time
{})
// The channel capacity should be large enough to hold all events in a
// The channel capacity should be large enough to hold all events in a
...
@@ -50,7 +56,7 @@ func newTestGenericPLEG() *TestGenericPLEG {
...
@@ -50,7 +56,7 @@ func newTestGenericPLEG() *TestGenericPLEG {
pleg
:=
&
GenericPLEG
{
pleg
:=
&
GenericPLEG
{
relistPeriod
:
time
.
Hour
,
relistPeriod
:
time
.
Hour
,
runtime
:
fakeRuntime
,
runtime
:
fakeRuntime
,
eventChannel
:
make
(
chan
*
PodLifecycleEvent
,
100
),
eventChannel
:
make
(
chan
*
PodLifecycleEvent
,
eventChannelCap
),
podRecords
:
make
(
podRecords
),
podRecords
:
make
(
podRecords
),
clock
:
clock
,
clock
:
clock
,
}
}
...
@@ -157,6 +163,65 @@ func TestRelisting(t *testing.T) {
...
@@ -157,6 +163,65 @@ func TestRelisting(t *testing.T) {
verifyEvents
(
t
,
expected
,
actual
)
verifyEvents
(
t
,
expected
,
actual
)
}
}
// TestEventChannelFull test when channel is full, the events will be discard.
func
TestEventChannelFull
(
t
*
testing
.
T
)
{
testPleg
:=
newTestGenericPLEGWithChannelSize
(
4
)
pleg
,
runtime
:=
testPleg
.
pleg
,
testPleg
.
runtime
ch
:=
pleg
.
Watch
()
// The first relist should send a PodSync event to each pod.
runtime
.
AllPodList
=
[]
*
containertest
.
FakePod
{
{
Pod
:
&
kubecontainer
.
Pod
{
ID
:
"1234"
,
Containers
:
[]
*
kubecontainer
.
Container
{
createTestContainer
(
"c1"
,
kubecontainer
.
ContainerStateExited
),
createTestContainer
(
"c2"
,
kubecontainer
.
ContainerStateRunning
),
createTestContainer
(
"c3"
,
kubecontainer
.
ContainerStateUnknown
),
},
}},
{
Pod
:
&
kubecontainer
.
Pod
{
ID
:
"4567"
,
Containers
:
[]
*
kubecontainer
.
Container
{
createTestContainer
(
"c1"
,
kubecontainer
.
ContainerStateExited
),
},
}},
}
pleg
.
relist
()
// Report every running/exited container if we see them for the first time.
expected
:=
[]
*
PodLifecycleEvent
{
{
ID
:
"1234"
,
Type
:
ContainerStarted
,
Data
:
"c2"
},
{
ID
:
"4567"
,
Type
:
ContainerDied
,
Data
:
"c1"
},
{
ID
:
"1234"
,
Type
:
ContainerDied
,
Data
:
"c1"
},
}
actual
:=
getEventsFromChannel
(
ch
)
verifyEvents
(
t
,
expected
,
actual
)
runtime
.
AllPodList
=
[]
*
containertest
.
FakePod
{
{
Pod
:
&
kubecontainer
.
Pod
{
ID
:
"1234"
,
Containers
:
[]
*
kubecontainer
.
Container
{
createTestContainer
(
"c2"
,
kubecontainer
.
ContainerStateExited
),
createTestContainer
(
"c3"
,
kubecontainer
.
ContainerStateRunning
),
},
}},
{
Pod
:
&
kubecontainer
.
Pod
{
ID
:
"4567"
,
Containers
:
[]
*
kubecontainer
.
Container
{
createTestContainer
(
"c4"
,
kubecontainer
.
ContainerStateRunning
),
},
}},
}
pleg
.
relist
()
// event channel is full, discard events
expected
=
[]
*
PodLifecycleEvent
{
{
ID
:
"1234"
,
Type
:
ContainerRemoved
,
Data
:
"c1"
},
{
ID
:
"1234"
,
Type
:
ContainerDied
,
Data
:
"c2"
},
{
ID
:
"1234"
,
Type
:
ContainerStarted
,
Data
:
"c3"
},
{
ID
:
"4567"
,
Type
:
ContainerRemoved
,
Data
:
"c1"
},
}
actual
=
getEventsFromChannel
(
ch
)
verifyEvents
(
t
,
expected
,
actual
)
}
func
TestDetectingContainerDeaths
(
t
*
testing
.
T
)
{
func
TestDetectingContainerDeaths
(
t
*
testing
.
T
)
{
// Vary the number of relists after the container started and before the
// Vary the number of relists after the container started and before the
// container died to account for the changes in pleg's internal states.
// container died to account for the changes in pleg's internal states.
...
...
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