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
57670edc
Commit
57670edc
authored
Mar 04, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #22345 from fgrzadkowski/hpa_events
Auto commit by PR queue bot
parents
627edd25
69b3c6aa
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
9 deletions
+21
-9
controllermanager.go
cmd/kube-controller-manager/app/controllermanager.go
+2
-2
controllermanager.go
contrib/mesos/pkg/controllermanager/controllermanager.go
+2
-2
horizontal.go
pkg/controller/podautoscaler/horizontal.go
+0
-0
horizontal_test.go
pkg/controller/podautoscaler/horizontal_test.go
+17
-5
No files found.
cmd/kube-controller-manager/app/controllermanager.go
View file @
57670edc
...
...
@@ -293,8 +293,8 @@ func StartControllers(s *options.CMServer, kubeClient *client.Client, kubeconfig
metrics
.
DefaultHeapsterService
,
metrics
.
DefaultHeapsterPort
,
)
podautoscaler
.
NewHorizontalController
(
hpaClient
.
Core
(),
hpaClient
.
Extensions
(),
hpaClient
,
metricsClient
)
.
Run
(
s
.
HorizontalPodAutoscalerSyncPeriod
.
Duration
)
go
podautoscaler
.
NewHorizontalController
(
hpaClient
.
Core
(),
hpaClient
.
Extensions
(),
hpaClient
,
metricsClient
,
s
.
HorizontalPodAutoscalerSyncPeriod
.
Duration
)
.
Run
(
wait
.
NeverStop
)
}
if
containsResource
(
resources
,
"daemonsets"
)
{
...
...
contrib/mesos/pkg/controllermanager/controllermanager.go
View file @
57670edc
...
...
@@ -240,8 +240,8 @@ func (s *CMServer) Run(_ []string) error {
metrics
.
DefaultHeapsterService
,
metrics
.
DefaultHeapsterPort
,
)
podautoscaler
.
NewHorizontalController
(
hpaClient
.
Core
(),
hpaClient
.
Extensions
(),
hpaClient
,
metricsClient
)
.
Run
(
s
.
HorizontalPodAutoscalerSyncPeriod
.
Duration
)
go
podautoscaler
.
NewHorizontalController
(
hpaClient
.
Core
(),
hpaClient
.
Extensions
(),
hpaClient
,
metricsClient
,
s
.
HorizontalPodAutoscalerSyncPeriod
.
Duration
)
.
Run
(
wait
.
NeverStop
)
}
if
containsResource
(
resources
,
"daemonsets"
)
{
...
...
pkg/controller/podautoscaler/horizontal.go
View file @
57670edc
This diff is collapsed.
Click to expand it.
pkg/controller/podautoscaler/horizontal_test.go
View file @
57670edc
...
...
@@ -33,6 +33,7 @@ import (
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/controller/podautoscaler/metrics"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch"
heapster
"k8s.io/heapster/api/v1/types"
...
...
@@ -71,6 +72,8 @@ type testCase struct {
statusUpdated
bool
eventCreated
bool
verifyEvents
bool
// Channel with names of HPA objects which we have reconciled.
processed
chan
string
}
func
(
tc
*
testCase
)
computeCPUCurrent
()
{
...
...
@@ -97,6 +100,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
tc
.
scaleUpdated
=
false
tc
.
statusUpdated
=
false
tc
.
eventCreated
=
false
tc
.
processed
=
make
(
chan
string
,
100
)
tc
.
computeCPUCurrent
()
fakeClient
:=
&
fake
.
Clientset
{}
...
...
@@ -215,11 +219,13 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
assert
.
Equal
(
t
,
namespace
,
obj
.
Namespace
)
assert
.
Equal
(
t
,
hpaName
,
obj
.
Name
)
assert
.
Equal
(
t
,
tc
.
desiredReplicas
,
obj
.
Status
.
DesiredReplicas
)
tc
.
statusUpdated
=
true
if
tc
.
verifyCPUCurrent
{
assert
.
NotNil
(
t
,
obj
.
Status
.
CurrentCPUUtilizationPercentage
)
assert
.
Equal
(
t
,
tc
.
CPUCurrent
,
*
obj
.
Status
.
CurrentCPUUtilizationPercentage
)
}
tc
.
statusUpdated
=
true
// Every time we reconcile HPA object we are updating status.
tc
.
processed
<-
obj
.
Name
return
true
,
obj
,
nil
})
...
...
@@ -227,12 +233,15 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
obj
:=
action
.
(
testclient
.
CreateAction
)
.
GetObject
()
.
(
*
api
.
Event
)
if
tc
.
verifyEvents
{
assert
.
Equal
(
t
,
"SuccessfulRescale"
,
obj
.
Reason
)
assert
.
Equal
(
t
,
fmt
.
Sprintf
(
"New size: %d"
,
tc
.
desiredReplicas
),
obj
.
Message
)
assert
.
Equal
(
t
,
fmt
.
Sprintf
(
"New size: %d
; reason: CPU utilization above target
"
,
tc
.
desiredReplicas
),
obj
.
Message
)
}
tc
.
eventCreated
=
true
return
true
,
obj
,
nil
})
fakeWatch
:=
watch
.
NewFake
()
fakeClient
.
AddWatchReactor
(
"*"
,
core
.
DefaultWatchReactor
(
fakeWatch
,
nil
))
return
fakeClient
}
...
...
@@ -247,13 +256,16 @@ func (tc *testCase) verifyResults(t *testing.T) {
func
(
tc
*
testCase
)
runTest
(
t
*
testing
.
T
)
{
testClient
:=
tc
.
prepareTestClient
(
t
)
metricsClient
:=
metrics
.
NewHeapsterMetricsClient
(
testClient
,
metrics
.
DefaultHeapsterNamespace
,
metrics
.
DefaultHeapsterScheme
,
metrics
.
DefaultHeapsterService
,
metrics
.
DefaultHeapsterPort
)
hpaController
:=
NewHorizontalController
(
testClient
.
Core
(),
testClient
.
Extensions
(),
testClient
.
Extensions
(),
metricsClient
)
err
:=
hpaController
.
reconcileAutoscalers
()
assert
.
Equal
(
t
,
nil
,
err
)
hpaController
:=
NewHorizontalController
(
testClient
.
Core
(),
testClient
.
Extensions
(),
testClient
.
Extensions
(),
metricsClient
,
0
)
stop
:=
make
(
chan
struct
{})
defer
close
(
stop
)
go
hpaController
.
Run
(
stop
)
if
tc
.
verifyEvents
{
// We need to wait for events to be broadcasted (sleep for longer than record.sleepDuration).
time
.
Sleep
(
12
*
time
.
Second
)
}
// Wait for HPA to be processed.
<-
tc
.
processed
tc
.
verifyResults
(
t
)
}
...
...
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