summaryrefslogtreecommitdiff
path: root/libpod/plugin
diff options
context:
space:
mode:
authorcdoern <cdoern@redhat.com>2022-06-01 16:02:39 -0400
committercdoern <cdoern@redhat.com>2022-06-09 16:44:21 -0400
commit7b3e43c1f6cf27a1cde96c0f650a793a56cebc4c (patch)
tree0b460b5067c72f31999399bd3eb83bce8268dfdb /libpod/plugin
parentf808907d85204a2a5606067eb31400aa12233635 (diff)
downloadpodman-7b3e43c1f6cf27a1cde96c0f650a793a56cebc4c.tar.gz
podman-7b3e43c1f6cf27a1cde96c0f650a793a56cebc4c.tar.bz2
podman-7b3e43c1f6cf27a1cde96c0f650a793a56cebc4c.zip
podman volume create --opt=o=timeout...
add an option to configure the driver timeout when creating a volume. The default is 5 seconds but this value is too small for some custom drivers. Signed-off-by: cdoern <cdoern@redhat.com>
Diffstat (limited to 'libpod/plugin')
-rw-r--r--libpod/plugin/volume_api.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/libpod/plugin/volume_api.go b/libpod/plugin/volume_api.go
index 2818e70c1..2587bd571 100644
--- a/libpod/plugin/volume_api.go
+++ b/libpod/plugin/volume_api.go
@@ -129,7 +129,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) (*VolumePlugin, error) {
+func GetVolumePlugin(name string, path string, timeout int) (*VolumePlugin, error) {
pluginsLock.Lock()
defer pluginsLock.Unlock()
@@ -153,6 +153,13 @@ func GetVolumePlugin(name string, path string) (*VolumePlugin, error) {
// 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
+ }
// This bit borrowed from pkg/bindings/connection.go
client.Transport = &http.Transport{
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {