Load cadvisor connection in background.

This commit is contained in:
Daniel Smith
2014-10-08 17:05:04 -07:00
parent 5d24820dd5
commit 1fc92bef53
2 changed files with 46 additions and 16 deletions

View File

@@ -131,11 +131,6 @@ func main() {
glog.Fatal("Couldn't connect to docker.")
}
cadvisorClient, err := cadvisor.NewClient("http://127.0.0.1:4194")
if err != nil {
glog.Errorf("Error on creating cadvisor client: %v", err)
}
hostname := getHostname()
if *rootDirectory == "" {
@@ -182,7 +177,6 @@ func main() {
k := kubelet.NewMainKubelet(
getHostname(),
dockerClient,
cadvisorClient,
etcdClient,
*rootDirectory,
*networkContainerImage,
@@ -190,6 +184,19 @@ func main() {
float32(*registryPullQPS),
*registryBurst)
go func() {
defer util.HandleCrash()
// TODO: Monitor this connection, reconnect if needed?
glog.V(1).Infof("Trying to create cadvisor client.")
cadvisorClient, err := cadvisor.NewClient("http://127.0.0.1:4194")
if err != nil {
glog.Errorf("Error on creating cadvisor client: %v", err)
return
}
glog.V(1).Infof("Successfully created cadvisor client.")
k.SetCadvisorClient(cadvisorClient)
}()
// TODO: These should probably become more plugin-ish: register a factory func
// in each checker's init(), iterate those here.
health.AddHealthChecker(health.NewExecHealthChecker(k))