diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-08-24 09:35:57 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-24 09:35:57 -0400 |
commit | 0f92cf22a69876975ca6ad97a08751bf2008e257 (patch) | |
tree | c2d7c6316570b0d4e20350f8152e9b08ef66a36e /libpod/plugin | |
parent | 67c4068bb35fd1aad95b1701c94ed11183d0fd66 (diff) | |
parent | 0f739355635d5bc4d538cf88009d7af533e7c289 (diff) | |
download | podman-0f92cf22a69876975ca6ad97a08751bf2008e257.tar.gz podman-0f92cf22a69876975ca6ad97a08751bf2008e257.tar.bz2 podman-0f92cf22a69876975ca6ad97a08751bf2008e257.zip |
Merge pull request #15437 from mheon/default_volume_timeout
Add support for containers.conf volume timeouts
Diffstat (limited to 'libpod/plugin')
-rw-r--r-- | libpod/plugin/volume_api.go | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/libpod/plugin/volume_api.go b/libpod/plugin/volume_api.go index 0a5eaae53..b13578388 100644 --- a/libpod/plugin/volume_api.go +++ b/libpod/plugin/volume_api.go @@ -3,6 +3,7 @@ package plugin import ( "bytes" "context" + "errors" "fmt" "io/ioutil" "net" @@ -13,8 +14,7 @@ import ( "sync" "time" - "errors" - + "github.com/containers/common/pkg/config" "github.com/containers/podman/v4/libpod/define" "github.com/docker/go-plugins-helpers/sdk" "github.com/docker/go-plugins-helpers/volume" @@ -40,7 +40,6 @@ var ( ) const ( - defaultTimeout = 5 * time.Second volumePluginType = "VolumeDriver" ) @@ -129,7 +128,7 @@ func validatePlugin(newPlugin *VolumePlugin) error { // GetVolumePlugin gets a single volume plugin, with the given name, at the // given path. -func GetVolumePlugin(name string, path string, timeout int) (*VolumePlugin, error) { +func GetVolumePlugin(name string, path string, timeout *uint, cfg *config.Config) (*VolumePlugin, error) { pluginsLock.Lock() defer pluginsLock.Unlock() @@ -152,13 +151,11 @@ func GetVolumePlugin(name string, path string, timeout int) (*VolumePlugin, erro // Need an HTTP client to force a Unix connection. // And since we can reuse it, might as well cache it. client := new(http.Client) - client.Timeout = defaultTimeout - // if the user specified a non-zero timeout, use their value. Else, keep the default. - if timeout != 0 { - if time.Duration(timeout)*time.Second < defaultTimeout { - logrus.Warnf("the default timeout for volume creation is %d seconds, setting a time less than that may break this feature.", defaultTimeout) - } - client.Timeout = time.Duration(timeout) * time.Second + client.Timeout = 5 * time.Second + if timeout != nil { + client.Timeout = time.Duration(*timeout) * time.Second + } else if cfg != nil { + client.Timeout = time.Duration(cfg.Engine.VolumePluginTimeout) * time.Second } // This bit borrowed from pkg/bindings/connection.go client.Transport = &http.Transport{ |