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
dca3db0a
Commit
dca3db0a
authored
Mar 12, 2015
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speedup pkg/kubelet/runonce_test.go
parent
a8f01391
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
runonce.go
pkg/kubelet/runonce.go
+5
-5
runonce_test.go
pkg/kubelet/runonce_test.go
+2
-1
No files found.
pkg/kubelet/runonce.go
View file @
dca3db0a
...
@@ -42,7 +42,7 @@ func (kl *Kubelet) RunOnce(updates <-chan PodUpdate) ([]RunPodResult, error) {
...
@@ -42,7 +42,7 @@ func (kl *Kubelet) RunOnce(updates <-chan PodUpdate) ([]RunPodResult, error) {
select
{
select
{
case
u
:=
<-
updates
:
case
u
:=
<-
updates
:
glog
.
Infof
(
"processing manifest with %d pods"
,
len
(
u
.
Pods
))
glog
.
Infof
(
"processing manifest with %d pods"
,
len
(
u
.
Pods
))
result
,
err
:=
kl
.
runOnce
(
u
.
Pods
)
result
,
err
:=
kl
.
runOnce
(
u
.
Pods
,
RunOnceRetryDelay
)
glog
.
Infof
(
"finished processing %d pods"
,
len
(
u
.
Pods
))
glog
.
Infof
(
"finished processing %d pods"
,
len
(
u
.
Pods
))
return
result
,
err
return
result
,
err
case
<-
time
.
After
(
RunOnceManifestDelay
)
:
case
<-
time
.
After
(
RunOnceManifestDelay
)
:
...
@@ -51,7 +51,7 @@ func (kl *Kubelet) RunOnce(updates <-chan PodUpdate) ([]RunPodResult, error) {
...
@@ -51,7 +51,7 @@ func (kl *Kubelet) RunOnce(updates <-chan PodUpdate) ([]RunPodResult, error) {
}
}
// runOnce runs a given set of pods and returns their status.
// runOnce runs a given set of pods and returns their status.
func
(
kl
*
Kubelet
)
runOnce
(
pods
[]
api
.
BoundPod
)
(
results
[]
RunPodResult
,
err
error
)
{
func
(
kl
*
Kubelet
)
runOnce
(
pods
[]
api
.
BoundPod
,
retryDelay
time
.
Duration
)
(
results
[]
RunPodResult
,
err
error
)
{
if
kl
.
dockerPuller
==
nil
{
if
kl
.
dockerPuller
==
nil
{
kl
.
dockerPuller
=
dockertools
.
NewDockerPuller
(
kl
.
dockerClient
,
kl
.
pullQPS
,
kl
.
pullBurst
)
kl
.
dockerPuller
=
dockertools
.
NewDockerPuller
(
kl
.
dockerClient
,
kl
.
pullQPS
,
kl
.
pullBurst
)
}
}
...
@@ -61,7 +61,7 @@ func (kl *Kubelet) runOnce(pods []api.BoundPod) (results []RunPodResult, err err
...
@@ -61,7 +61,7 @@ func (kl *Kubelet) runOnce(pods []api.BoundPod) (results []RunPodResult, err err
for
i
:=
range
pods
{
for
i
:=
range
pods
{
pod
:=
pods
[
i
]
// Make a copy
pod
:=
pods
[
i
]
// Make a copy
go
func
()
{
go
func
()
{
err
:=
kl
.
runPod
(
pod
)
err
:=
kl
.
runPod
(
pod
,
retryDelay
)
ch
<-
RunPodResult
{
&
pod
,
err
}
ch
<-
RunPodResult
{
&
pod
,
err
}
}()
}()
}
}
...
@@ -87,8 +87,8 @@ func (kl *Kubelet) runOnce(pods []api.BoundPod) (results []RunPodResult, err err
...
@@ -87,8 +87,8 @@ func (kl *Kubelet) runOnce(pods []api.BoundPod) (results []RunPodResult, err err
}
}
// runPod runs a single pod and wait until all containers are running.
// runPod runs a single pod and wait until all containers are running.
func
(
kl
*
Kubelet
)
runPod
(
pod
api
.
BoundPod
)
error
{
func
(
kl
*
Kubelet
)
runPod
(
pod
api
.
BoundPod
,
retryDelay
time
.
Duration
)
error
{
delay
:=
RunOnceR
etryDelay
delay
:=
r
etryDelay
retry
:=
0
retry
:=
0
for
{
for
{
dockerContainers
,
err
:=
dockertools
.
GetKubeletDockerContainers
(
kl
.
dockerClient
,
false
)
dockerContainers
,
err
:=
dockertools
.
GetKubeletDockerContainers
(
kl
.
dockerClient
,
false
)
...
...
pkg/kubelet/runonce_test.go
View file @
dca3db0a
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"fmt"
"fmt"
"strconv"
"strconv"
"testing"
"testing"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
...
@@ -140,7 +141,7 @@ func TestRunOnce(t *testing.T) {
...
@@ -140,7 +141,7 @@ func TestRunOnce(t *testing.T) {
},
},
},
},
},
},
})
}
,
time
.
Millisecond
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
}
...
...
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