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
31a78c3e
Commit
31a78c3e
authored
Jul 28, 2014
by
Daniel Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #619 from brendandburns/controller
Make individual controller actions asynchronous.
parents
1d4ed339
1a3e4f8b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
8 deletions
+30
-8
replication_controller.go
pkg/controller/replication_controller.go
+14
-2
fake_docker_client.go
pkg/kubelet/fake_docker_client.go
+2
-0
pod_registry.go
pkg/registry/pod_registry.go
+14
-6
No files found.
pkg/controller/replication_controller.go
View file @
31a78c3e
...
...
@@ -183,15 +183,27 @@ func (rm *ReplicationManager) syncReplicationController(controllerSpec api.Repli
diff
:=
len
(
filteredList
)
-
controllerSpec
.
DesiredState
.
Replicas
if
diff
<
0
{
diff
*=
-
1
wait
:=
sync
.
WaitGroup
{}
wait
.
Add
(
diff
)
glog
.
Infof
(
"Too few replicas, creating %d
\n
"
,
diff
)
for
i
:=
0
;
i
<
diff
;
i
++
{
rm
.
podControl
.
createReplica
(
controllerSpec
)
go
func
()
{
defer
wait
.
Done
()
rm
.
podControl
.
createReplica
(
controllerSpec
)
}()
}
wait
.
Wait
()
}
else
if
diff
>
0
{
glog
.
Infof
(
"Too many replicas, deleting %d
\n
"
,
diff
)
wait
:=
sync
.
WaitGroup
{}
wait
.
Add
(
diff
)
for
i
:=
0
;
i
<
diff
;
i
++
{
rm
.
podControl
.
deletePod
(
filteredList
[
i
]
.
ID
)
go
func
(
ix
int
)
{
defer
wait
.
Done
()
rm
.
podControl
.
deletePod
(
filteredList
[
ix
]
.
ID
)
}(
i
)
}
wait
.
Wait
()
}
return
nil
}
...
...
pkg/kubelet/fake_docker_client.go
View file @
31a78c3e
...
...
@@ -36,6 +36,8 @@ type FakeDockerClient struct {
}
func
(
f
*
FakeDockerClient
)
clearCalls
()
{
f
.
lock
.
Lock
()
defer
f
.
lock
.
Unlock
()
f
.
called
=
[]
string
{}
}
...
...
pkg/registry/pod_registry.go
View file @
31a78c3e
...
...
@@ -19,6 +19,7 @@ package registry
import
(
"fmt"
"strings"
"sync"
"time"
"code.google.com/p/go-uuid/uuid"
...
...
@@ -40,6 +41,7 @@ type PodRegistryStorage struct {
minionLister
scheduler
.
MinionLister
cloud
cloudprovider
.
Interface
podPollPeriod
time
.
Duration
lock
sync
.
Mutex
}
// MakePodRegistryStorage makes a RESTStorage object for a pod registry.
...
...
@@ -193,6 +195,17 @@ func (storage *PodRegistryStorage) Extract(body []byte) (interface{}, error) {
return
pod
,
err
}
func
(
storage
*
PodRegistryStorage
)
scheduleAndCreatePod
(
pod
api
.
Pod
)
error
{
storage
.
lock
.
Lock
()
defer
storage
.
lock
.
Unlock
()
// TODO(lavalamp): Separate scheduler more cleanly.
machine
,
err
:=
storage
.
scheduler
.
Schedule
(
pod
,
storage
.
minionLister
)
if
err
!=
nil
{
return
err
}
return
storage
.
registry
.
CreatePod
(
machine
,
pod
)
}
func
(
storage
*
PodRegistryStorage
)
Create
(
obj
interface
{})
(
<-
chan
interface
{},
error
)
{
pod
:=
obj
.
(
api
.
Pod
)
if
len
(
pod
.
ID
)
==
0
{
...
...
@@ -201,12 +214,7 @@ func (storage *PodRegistryStorage) Create(obj interface{}) (<-chan interface{},
pod
.
DesiredState
.
Manifest
.
ID
=
pod
.
ID
return
apiserver
.
MakeAsync
(
func
()
(
interface
{},
error
)
{
// TODO(lavalamp): Separate scheduler more cleanly.
machine
,
err
:=
storage
.
scheduler
.
Schedule
(
pod
,
storage
.
minionLister
)
if
err
!=
nil
{
return
nil
,
err
}
err
=
storage
.
registry
.
CreatePod
(
machine
,
pod
)
err
:=
storage
.
scheduleAndCreatePod
(
pod
)
if
err
!=
nil
{
return
nil
,
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