Retry registering a volume driver
Signed-off-by: Stephen Rust <srust@blockbridge.com>
This commit is contained in:
parent
65841492f0
commit
7eb8f570af
1 changed files with 33 additions and 14 deletions
|
@ -25,6 +25,7 @@ package plugins
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/docker/pkg/tlsconfig"
|
"github.com/docker/docker/pkg/tlsconfig"
|
||||||
|
@ -109,18 +110,35 @@ func (p *Plugin) activateWithLock() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func load(name string) (*Plugin, error) {
|
func load(name string) (*Plugin, error) {
|
||||||
storage.Lock()
|
return loadWithRetry(name, true)
|
||||||
registry := newLocalRegistry()
|
}
|
||||||
pl, err := registry.Plugin(name)
|
|
||||||
if err == nil {
|
|
||||||
storage.plugins[name] = pl
|
|
||||||
}
|
|
||||||
storage.Unlock()
|
|
||||||
|
|
||||||
|
func loadWithRetry(name string, retry bool) (*Plugin, error) {
|
||||||
|
registry := newLocalRegistry()
|
||||||
|
start := time.Now()
|
||||||
|
|
||||||
|
var retries int
|
||||||
|
for {
|
||||||
|
pl, err := registry.Plugin(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if !retry {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timeOff := backoff(retries)
|
||||||
|
if abort(start, timeOff) {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
retries++
|
||||||
|
logrus.Warnf("Unable to locate plugin: %s, retrying in %v", name, timeOff)
|
||||||
|
time.Sleep(timeOff)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
storage.Lock()
|
||||||
|
storage.plugins[name] = pl
|
||||||
|
storage.Unlock()
|
||||||
|
|
||||||
err = pl.activate()
|
err = pl.activate()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -130,6 +148,7 @@ func load(name string) (*Plugin, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return pl, err
|
return pl, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func get(name string) (*Plugin, error) {
|
func get(name string) (*Plugin, error) {
|
||||||
|
|
Loading…
Reference in a new issue