Merge pull request #579 from vmarmol/master

Start() exits gracefully when there are no factories.
This commit is contained in:
Rohit Jnagal 2015-03-11 23:24:16 -07:00
commit e685067a04
2 changed files with 20 additions and 5 deletions

View File

@ -48,6 +48,14 @@ func RegisterContainerHandlerFactory(factory ContainerHandlerFactory) {
factories = append(factories, factory)
}
// Returns whether there are any container handler factories registered.
func HasFactories() bool {
factoriesLock.Lock()
defer factoriesLock.Unlock()
return len(factories) != 0
}
// Create a new ContainerHandler for the specified container.
func NewContainerHandler(name string) (ContainerHandler, error) {
factoriesLock.RLock()

View File

@ -187,8 +187,19 @@ func (self *manager) Start() error {
}
}
// Watch for OOMs.
err := self.watchForNewOoms()
if err != nil {
glog.Errorf("Failed to start OOM watcher, will not get OOM events: %v", err)
}
// If there are no factories, don't start any housekeeping and serve the information we do have.
if !container.HasFactories() {
return nil
}
// Create root and then recover all containers.
err := self.createContainer("/")
err = self.createContainer("/")
if err != nil {
return err
}
@ -206,10 +217,6 @@ func (self *manager) Start() error {
return err
}
self.quitChannels = append(self.quitChannels, quitWatcher)
err = self.watchForNewOoms()
if err != nil {
glog.Errorf("Failed to start OOM watcher, will not get OOM events: %v", err)
}
// Look for new containers in the main housekeeping thread.
quitGlobalHousekeeping := make(chan error)