When a plugin has an activation error, it was not being checked in the
`waitActive` loop. This means it will just wait forever for a manifest
to be populated even though it may never come.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
| ... | ... |
@@ -1,6 +1,7 @@ |
| 1 | 1 |
package plugins |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
+ "errors" |
|
| 4 | 5 |
"path/filepath" |
| 5 | 6 |
"runtime" |
| 6 | 7 |
"sync" |
| ... | ... |
@@ -20,6 +21,12 @@ func TestPluginAddHandler(t *testing.T) {
|
| 20 | 20 |
testActive(t, p) |
| 21 | 21 |
} |
| 22 | 22 |
|
| 23 |
+func TestPluginWaitBadPlugin(t *testing.T) {
|
|
| 24 |
+ p := &Plugin{activateWait: sync.NewCond(&sync.Mutex{})}
|
|
| 25 |
+ p.activateErr = errors.New("some junk happened")
|
|
| 26 |
+ testActive(t, p) |
|
| 27 |
+} |
|
| 28 |
+ |
|
| 23 | 29 |
func testActive(t *testing.T, p *Plugin) {
|
| 24 | 30 |
done := make(chan struct{})
|
| 25 | 31 |
go func() {
|
| ... | ... |
@@ -169,7 +169,7 @@ func (p *Plugin) activateWithLock() error {
|
| 169 | 169 |
|
| 170 | 170 |
func (p *Plugin) waitActive() error {
|
| 171 | 171 |
p.activateWait.L.Lock() |
| 172 |
- for !p.activated() {
|
|
| 172 |
+ for !p.activated() && p.activateErr == nil {
|
|
| 173 | 173 |
p.activateWait.Wait() |
| 174 | 174 |
} |
| 175 | 175 |
p.activateWait.L.Unlock() |