Skip to content

Commit

Permalink
Split rkt context initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
liggitt committed Apr 11, 2019
1 parent 7dc4594 commit 6757727
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
6 changes: 6 additions & 0 deletions container/rkt/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
}

Expand Down
9 changes: 0 additions & 9 deletions manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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,
},
Expand Down

0 comments on commit 6757727

Please sign in to comment.