Merge pull request #40807 from wpjunior/plugin-feedback
Improve error feedback when plugin does not implement desired interface
This commit is contained in:
commit
de5812c2a1
2 changed files with 20 additions and 7 deletions
|
@ -41,7 +41,11 @@ func ListDrivers() []string {
|
|||
}
|
||||
|
||||
func (lf *logdriverFactory) register(name string, c Creator) error {
|
||||
if lf.driverRegistered(name) {
|
||||
registered, err := lf.driverRegistered(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if registered {
|
||||
return fmt.Errorf("logger: log driver named '%s' is already registered", name)
|
||||
}
|
||||
|
||||
|
@ -51,18 +55,22 @@ func (lf *logdriverFactory) register(name string, c Creator) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (lf *logdriverFactory) driverRegistered(name string) bool {
|
||||
func (lf *logdriverFactory) driverRegistered(name string) (bool, error) {
|
||||
lf.m.Lock()
|
||||
_, ok := lf.registry[name]
|
||||
lf.m.Unlock()
|
||||
if !ok {
|
||||
if pluginGetter != nil { // this can be nil when the init functions are running
|
||||
if l, _ := getPlugin(name, plugingetter.Lookup); l != nil {
|
||||
return true
|
||||
l, err := getPlugin(name, plugingetter.Lookup)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if l != nil {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok
|
||||
return ok, nil
|
||||
}
|
||||
|
||||
func (lf *logdriverFactory) registerLogOptValidator(name string, l LogOptValidator) error {
|
||||
|
@ -147,7 +155,11 @@ func ValidateLogOpts(name string, cfg map[string]string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if !factory.driverRegistered(name) {
|
||||
registered, err := factory.driverRegistered(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !registered {
|
||||
return fmt.Errorf("logger: no log driver named '%s' is registered", name)
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,13 @@ source hack/make/.integration-test-helpers
|
|||
: "${DOCKER_PY_COMMIT:=4.2.1}"
|
||||
|
||||
# custom options to pass py.test
|
||||
# TODO remove these skip once we update to a docker-py version that has https://github.com/docker/docker-py/pull/2549: CreateContainerTest::test_invalid_log_driver_raises_exception
|
||||
#
|
||||
# This option can be used to temporarily skip flaky tests (using the `--deselect`
|
||||
# flag) until they are fixed upstream. For example:
|
||||
# --deselect=tests/integration/api_container_test.py::AttachContainerTest::test_attach_no_stream
|
||||
# TODO re-enable test after https://github.com/docker/docker-py/issues/2513 has been resolved
|
||||
: "${PY_TEST_OPTIONS:=--junitxml=${DEST}/junit-report.xml --deselect=tests/integration/api_container_test.py::AttachContainerTest::test_attach_no_stream}"
|
||||
: "${PY_TEST_OPTIONS:=--junitxml=${DEST}/junit-report.xml --deselect=tests/integration/api_container_test.py::AttachContainerTest::test_attach_no_stream --deselect=tests/integration/api_container_test.py::CreateContainerTest::test_invalid_log_driver_raises_exception}"
|
||||
(
|
||||
bundle .integration-daemon-start
|
||||
|
||||
|
|
Loading…
Reference in a new issue