Merge pull request #579 from vmarmol/master
Start() exits gracefully when there are no factories.
This commit is contained in:
commit
e685067a04
@ -48,6 +48,14 @@ func RegisterContainerHandlerFactory(factory ContainerHandlerFactory) {
|
|||||||
factories = append(factories, factory)
|
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.
|
// Create a new ContainerHandler for the specified container.
|
||||||
func NewContainerHandler(name string) (ContainerHandler, error) {
|
func NewContainerHandler(name string) (ContainerHandler, error) {
|
||||||
factoriesLock.RLock()
|
factoriesLock.RLock()
|
||||||
|
@ -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.
|
// Create root and then recover all containers.
|
||||||
err := self.createContainer("/")
|
err = self.createContainer("/")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -206,10 +217,6 @@ func (self *manager) Start() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
self.quitChannels = append(self.quitChannels, quitWatcher)
|
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.
|
// Look for new containers in the main housekeeping thread.
|
||||||
quitGlobalHousekeeping := make(chan error)
|
quitGlobalHousekeeping := make(chan error)
|
||||||
|
Loading…
Reference in New Issue
Block a user