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
79d3d795
Commit
79d3d795
authored
Jun 08, 2017
by
Andrzej Wasylkowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed a race condition from ResourceConsumer.
parent
d16d64f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
autoscaling_utils.go
test/e2e/common/autoscaling_utils.go
+10
-0
No files found.
test/e2e/common/autoscaling_utils.go
View file @
79d3d795
...
...
@@ -20,6 +20,7 @@ import (
"context"
"fmt"
"strconv"
"sync"
"time"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
...
@@ -86,6 +87,7 @@ type ResourceConsumer struct {
stopCPU
chan
int
stopMem
chan
int
stopCustomMetric
chan
int
stopWaitGroup
sync
.
WaitGroup
consumptionTimeInSeconds
int
sleepTime
time
.
Duration
requestSizeInMillicores
int
...
...
@@ -167,6 +169,8 @@ func (rc *ResourceConsumer) ConsumeCustomMetric(amount int) {
func
(
rc
*
ResourceConsumer
)
makeConsumeCPURequests
()
{
defer
GinkgoRecover
()
rc
.
stopWaitGroup
.
Add
(
1
)
defer
rc
.
stopWaitGroup
.
Done
()
sleepTime
:=
time
.
Duration
(
0
)
millicores
:=
0
for
{
...
...
@@ -186,6 +190,8 @@ func (rc *ResourceConsumer) makeConsumeCPURequests() {
func
(
rc
*
ResourceConsumer
)
makeConsumeMemRequests
()
{
defer
GinkgoRecover
()
rc
.
stopWaitGroup
.
Add
(
1
)
defer
rc
.
stopWaitGroup
.
Done
()
sleepTime
:=
time
.
Duration
(
0
)
megabytes
:=
0
for
{
...
...
@@ -205,6 +211,8 @@ func (rc *ResourceConsumer) makeConsumeMemRequests() {
func
(
rc
*
ResourceConsumer
)
makeConsumeCustomMetric
()
{
defer
GinkgoRecover
()
rc
.
stopWaitGroup
.
Add
(
1
)
defer
rc
.
stopWaitGroup
.
Done
()
sleepTime
:=
time
.
Duration
(
0
)
delta
:=
0
for
{
...
...
@@ -364,6 +372,7 @@ func (rc *ResourceConsumer) Pause() {
rc
.
stopCPU
<-
0
rc
.
stopMem
<-
0
rc
.
stopCustomMetric
<-
0
rc
.
stopWaitGroup
.
Wait
()
}
// Pause starts background goroutines responsible for consuming resources.
...
...
@@ -379,6 +388,7 @@ func (rc *ResourceConsumer) CleanUp() {
close
(
rc
.
stopCPU
)
close
(
rc
.
stopMem
)
close
(
rc
.
stopCustomMetric
)
rc
.
stopWaitGroup
.
Wait
()
// Wait some time to ensure all child goroutines are finished.
time
.
Sleep
(
10
*
time
.
Second
)
kind
,
err
:=
kindOf
(
rc
.
kind
)
...
...
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