mirror of https://github.com/k3s-io/k3s
Move run logic into package
parent
65d6280936
commit
e74ac01a62
|
@ -29,7 +29,6 @@ import (
|
|||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/controller"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
"github.com/coreos/go-etcd/etcd"
|
||||
)
|
||||
|
||||
|
@ -53,7 +52,6 @@ func main() {
|
|||
Host: "http://" + *master,
|
||||
})
|
||||
|
||||
go util.Forever(func() { controllerManager.Synchronize() }, 20*time.Second)
|
||||
go util.Forever(func() { controllerManager.WatchControllers() }, 20*time.Second)
|
||||
controllerManager.Run(10 * time.Second)
|
||||
select {}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,13 @@ func MakeReplicationManager(etcdClient *etcd.Client, kubeClient client.ClientInt
|
|||
}
|
||||
}
|
||||
|
||||
func (rm *ReplicationManager) WatchControllers() {
|
||||
// Begin watching and syncing.
|
||||
func (rm *ReplicationManager) Run(period time.Duration) {
|
||||
go util.Forever(func() { rm.synchronize() }, period)
|
||||
go util.Forever(func() { rm.watchControllers() }, period)
|
||||
}
|
||||
|
||||
func (rm *ReplicationManager) watchControllers() {
|
||||
watchChannel := make(chan *etcd.Response)
|
||||
go func() {
|
||||
defer util.HandleCrash()
|
||||
|
@ -166,8 +172,7 @@ func (rm *ReplicationManager) syncReplicationController(controllerSpec api.Repli
|
|||
return nil
|
||||
}
|
||||
|
||||
func (rm *ReplicationManager) Synchronize() {
|
||||
for {
|
||||
func (rm *ReplicationManager) synchronize() {
|
||||
response, err := rm.etcdClient.Get("/registry/controllers", false, false)
|
||||
if err != nil {
|
||||
log.Printf("Synchronization error %#v", err)
|
||||
|
@ -194,6 +199,4 @@ func (rm *ReplicationManager) Synchronize() {
|
|||
}
|
||||
}
|
||||
}
|
||||
time.Sleep(10 * time.Second)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue