mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
Merge pull request #8340 from dchen1107/clean
Wait for docker to start cadvisor.
This commit is contained in:
commit
e1a153e841
@ -28,6 +28,10 @@ type Fake struct {
|
||||
|
||||
var _ Interface = new(Fake)
|
||||
|
||||
func (c *Fake) Start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Fake) ContainerInfo(name string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error) {
|
||||
return new(cadvisorApi.ContainerInfo), nil
|
||||
}
|
||||
|
@ -57,10 +57,6 @@ func New(port uint) (Interface, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = m.Start()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cadvisorClient := &cadvisorClient{
|
||||
Manager: m,
|
||||
@ -73,10 +69,13 @@ func New(port uint) (Interface, error) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return cadvisorClient, nil
|
||||
}
|
||||
|
||||
func (cc *cadvisorClient) Start() error {
|
||||
return cc.Manager.Start()
|
||||
}
|
||||
|
||||
func (cc *cadvisorClient) exportHTTP(port uint) error {
|
||||
mux := http.NewServeMux()
|
||||
err := cadvisorHttp.RegisterHandlers(mux, cc, "", "", "", "", "/metrics")
|
||||
|
@ -29,6 +29,11 @@ type Mock struct {
|
||||
|
||||
var _ Interface = new(Mock)
|
||||
|
||||
func (c *Mock) Start() error {
|
||||
args := c.Called()
|
||||
return args.Error(1)
|
||||
}
|
||||
|
||||
// ContainerInfo is a mock implementation of Interface.ContainerInfo.
|
||||
func (c *Mock) ContainerInfo(name string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error) {
|
||||
args := c.Called(name, req)
|
||||
|
@ -37,6 +37,10 @@ func New(port uint) (Interface, error) {
|
||||
|
||||
var unsupportedErr = errors.New("cAdvisor is unsupported in this build")
|
||||
|
||||
func (cu *cadvisorUnsupported) Start() error {
|
||||
return unsupportedErr
|
||||
}
|
||||
|
||||
func (cu *cadvisorUnsupported) DockerContainer(name string, req *cadvisorApi.ContainerInfoRequest) (cadvisorApi.ContainerInfo, error) {
|
||||
return cadvisorApi.ContainerInfo{}, unsupportedErr
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import (
|
||||
|
||||
// Interface is an abstract interface for testability. It abstracts the interface to cAdvisor.
|
||||
type Interface interface {
|
||||
Start() error
|
||||
DockerContainer(name string, req *cadvisorApi.ContainerInfoRequest) (cadvisorApi.ContainerInfo, error)
|
||||
ContainerInfo(name string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error)
|
||||
SubcontainerInfo(name string, req *cadvisorApi.ContainerInfoRequest) (map[string]*cadvisorApi.ContainerInfo, error)
|
||||
|
@ -656,6 +656,12 @@ func (kl *Kubelet) Run(updates <-chan PodUpdate) {
|
||||
glog.Errorf("Failed to start ImageManager, images may not be garbage collected: %v", err)
|
||||
}
|
||||
|
||||
err = kl.cadvisor.Start()
|
||||
if err != nil {
|
||||
kl.recorder.Eventf(kl.nodeRef, "kubeletSetupFailed", "Failed to start CAdvisor %v", err)
|
||||
glog.Errorf("Failed to start CAdvisor, system may not be properly monitored: %v", err)
|
||||
}
|
||||
|
||||
err = kl.containerManager.Start()
|
||||
if err != nil {
|
||||
kl.recorder.Eventf(kl.nodeRef, "kubeletSetupFailed", "Failed to start ContainerManager %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user