@@ -4,12 +4,19 @@ package volumedrivers
44
55import (
66 "errors"
7+ "time"
78
9+ "github.com/docker/docker/pkg/plugins"
810 "github.com/docker/docker/volume"
911)
1012
13+ const (
14+ longTimeout = 2 * time .Minute
15+ shortTimeout = 1 * time .Minute
16+ )
17+
1118type client interface {
12- Call (string , interface {}, interface {}) error
19+ CallWithOptions (string , interface {}, interface {}, ... func ( * plugins. RequestOpts ) ) error
1320}
1421
1522type volumeDriverProxy struct {
@@ -33,7 +40,8 @@ func (pp *volumeDriverProxy) Create(name string, opts map[string]string) (err er
3340
3441 req .Name = name
3542 req .Opts = opts
36- if err = pp .Call ("VolumeDriver.Create" , req , & ret ); err != nil {
43+
44+ if err = pp .CallWithOptions ("VolumeDriver.Create" , req , & ret , plugins .WithRequestTimeout (longTimeout )); err != nil {
3745 return
3846 }
3947
@@ -59,7 +67,8 @@ func (pp *volumeDriverProxy) Remove(name string) (err error) {
5967 )
6068
6169 req .Name = name
62- if err = pp .Call ("VolumeDriver.Remove" , req , & ret ); err != nil {
70+
71+ if err = pp .CallWithOptions ("VolumeDriver.Remove" , req , & ret , plugins .WithRequestTimeout (shortTimeout )); err != nil {
6372 return
6473 }
6574
@@ -86,7 +95,8 @@ func (pp *volumeDriverProxy) Path(name string) (mountpoint string, err error) {
8695 )
8796
8897 req .Name = name
89- if err = pp .Call ("VolumeDriver.Path" , req , & ret ); err != nil {
98+
99+ if err = pp .CallWithOptions ("VolumeDriver.Path" , req , & ret , plugins .WithRequestTimeout (shortTimeout )); err != nil {
90100 return
91101 }
92102
@@ -117,7 +127,8 @@ func (pp *volumeDriverProxy) Mount(name string, id string) (mountpoint string, e
117127
118128 req .Name = name
119129 req .ID = id
120- if err = pp .Call ("VolumeDriver.Mount" , req , & ret ); err != nil {
130+
131+ if err = pp .CallWithOptions ("VolumeDriver.Mount" , req , & ret , plugins .WithRequestTimeout (longTimeout )); err != nil {
121132 return
122133 }
123134
@@ -147,7 +158,8 @@ func (pp *volumeDriverProxy) Unmount(name string, id string) (err error) {
147158
148159 req .Name = name
149160 req .ID = id
150- if err = pp .Call ("VolumeDriver.Unmount" , req , & ret ); err != nil {
161+
162+ if err = pp .CallWithOptions ("VolumeDriver.Unmount" , req , & ret , plugins .WithRequestTimeout (shortTimeout )); err != nil {
151163 return
152164 }
153165
@@ -172,7 +184,7 @@ func (pp *volumeDriverProxy) List() (volumes []*proxyVolume, err error) {
172184 ret volumeDriverProxyListResponse
173185 )
174186
175- if err = pp .Call ("VolumeDriver.List" , req , & ret ); err != nil {
187+ if err = pp .CallWithOptions ("VolumeDriver.List" , req , & ret , plugins . WithRequestTimeout ( shortTimeout ) ); err != nil {
176188 return
177189 }
178190
@@ -201,7 +213,8 @@ func (pp *volumeDriverProxy) Get(name string) (volume *proxyVolume, err error) {
201213 )
202214
203215 req .Name = name
204- if err = pp .Call ("VolumeDriver.Get" , req , & ret ); err != nil {
216+
217+ if err = pp .CallWithOptions ("VolumeDriver.Get" , req , & ret , plugins .WithRequestTimeout (shortTimeout )); err != nil {
205218 return
206219 }
207220
@@ -228,7 +241,7 @@ func (pp *volumeDriverProxy) Capabilities() (capabilities volume.Capability, err
228241 ret volumeDriverProxyCapabilitiesResponse
229242 )
230243
231- if err = pp .Call ("VolumeDriver.Capabilities" , req , & ret ); err != nil {
244+ if err = pp .CallWithOptions ("VolumeDriver.Capabilities" , req , & ret , plugins . WithRequestTimeout ( shortTimeout ) ); err != nil {
232245 return
233246 }
234247
0 commit comments