Skip to content

Commit 2e78926

Browse files
author
Julian Hjortshoj
committed
retest driver connections during driver discovery to make sure we can recover from hung requests to voldrivers [#154852943](https://www.pivotaltracker.com/story/show/154852943)
1 parent 1044021 commit 2e78926

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

vollocal/docker_driver_discoverer.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"path/filepath"
77
"regexp"
88
"runtime"
9-
9+
"errors"
1010
"context"
1111

1212
"code.cloudfoundry.org/lager"
@@ -135,6 +135,16 @@ func (r *dockerDriverDiscoverer) insertIfAliveAndNotFound(logger lager.Logger, e
135135
logger.Info("existing-driver-mismatch", lager.Data{"specName": specName, "address": driverSpec.Address, "tls": driverSpec.TLSConfig})
136136
plugin = nil
137137
}
138+
if plugin != nil {
139+
dockerPlugin := plugin.(*driverhttp.DockerDriverPlugin)
140+
dockerDriver := dockerPlugin.DockerDriver.(voldriver.Driver)
141+
env := driverhttp.NewHttpDriverEnv(logger, context.Background())
142+
resp := dockerDriver.Activate(env)
143+
if resp.Err != "" {
144+
logger.Error("existing-driver-unreachable", errors.New(resp.Err), lager.Data{"specName": specName, "address": driverSpec.Address, "tls": driverSpec.TLSConfig})
145+
plugin = nil
146+
}
147+
}
138148
}
139149

140150
if plugin == nil {

vollocal/docker_driver_discoverer_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,17 @@ var _ = Describe("Docker Driver Discoverer", func() {
109109
// Expect SetDrivers not to be called
110110
Expect(len(drivers)).To(Equal(1))
111111
Expect(fakeDriverFactory.DockerDriverCallCount()).To(Equal(1))
112-
Expect(fakeDriver.ActivateCallCount()).To(Equal(1))
112+
Expect(fakeDriver.ActivateCallCount()).To(Equal(2))
113+
})
114+
Context("when the existing driver connection is broken", func(){
115+
BeforeEach(func(){
116+
fakeDriver.ActivateReturnsOnCall(1, voldriver.ActivateResponse{Err: "badness"})
117+
})
118+
It("should replace the driver in the registry", func() {
119+
Expect(len(drivers)).To(Equal(1))
120+
Expect(fakeDriverFactory.DockerDriverCallCount()).To(Equal(2))
121+
Expect(fakeDriver.ActivateCallCount()).To(Equal(3))
122+
})
113123
})
114124
})
115125

0 commit comments

Comments
 (0)