Split rkt context initialization

This commit is contained in:
Jordan Liggitt 2019-04-09 21:28:46 +00:00
parent 7dc4594b32
commit 6757727a00
2 changed files with 6 additions and 9 deletions

View File

@ -19,6 +19,7 @@ import (
"github.com/google/cadvisor/fs"
info "github.com/google/cadvisor/info/v1"
"github.com/google/cadvisor/watcher"
"k8s.io/klog"
)
// NewPlugin returns an implementation of container.Plugin suitable for passing to container.RegisterPlugin()
@ -29,6 +30,11 @@ func NewPlugin() container.Plugin {
type plugin struct{}
func (p *plugin) InitializeFSContext(context *fs.Context) error {
if tmpRktPath, err := RktPath(); err != nil {
klog.V(5).Infof("Rkt not connected: %v", err)
} else {
context.RktPath = tmpRktPath
}
return nil
}

View File

@ -33,7 +33,6 @@ import (
"github.com/google/cadvisor/container/crio"
"github.com/google/cadvisor/container/docker"
"github.com/google/cadvisor/container/raw"
"github.com/google/cadvisor/container/rkt"
"github.com/google/cadvisor/events"
"github.com/google/cadvisor/fs"
info "github.com/google/cadvisor/info/v1"
@ -152,18 +151,11 @@ func New(memoryCache *memory.InMemoryCache, sysfs sysfs.SysFs, maxHousekeepingIn
var (
dockerStatus info.DockerStatus
rktPath string
)
docker.SetTimeout(dockerClientTimeout)
// Try to connect to docker indefinitely on startup.
dockerStatus = retryDockerStatus()
if tmpRktPath, err := rkt.RktPath(); err != nil {
klog.V(5).Infof("Rkt not connected: %v", err)
} else {
rktPath = tmpRktPath
}
crioClient, err := crio.Client()
if err != nil {
return nil, err
@ -179,7 +171,6 @@ func New(memoryCache *memory.InMemoryCache, sysfs sysfs.SysFs, maxHousekeepingIn
Driver: dockerStatus.Driver,
DriverStatus: dockerStatus.DriverStatus,
},
RktPath: rktPath,
Crio: fs.CrioContext{
Root: crioInfo.StorageRoot,
},