mirror of https://github.com/k3s-io/k3s
add timeout for Openstack cloud provider
parent
3eb5ba805c
commit
fe92a55425
|
@ -52,6 +52,7 @@ import (
|
|||
const (
|
||||
ProviderName = "openstack"
|
||||
AvailabilityZone = "availability_zone"
|
||||
defaultTimeOut = 60 * time.Second
|
||||
)
|
||||
|
||||
var ErrNotFound = errors.New("Failed to find object")
|
||||
|
@ -102,6 +103,7 @@ type RouterOpts struct {
|
|||
|
||||
type MetadataOpts struct {
|
||||
SearchOrder string `gcfg:"search-order"`
|
||||
RequestTimeout MyDuration `gcfg:"request-timeout"`
|
||||
}
|
||||
|
||||
// OpenStack is an implementation of cloud provider Interface for OpenStack.
|
||||
|
@ -290,6 +292,12 @@ func newOpenStack(cfg Config) (*OpenStack, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
emptyDuration := MyDuration{}
|
||||
if cfg.Metadata.RequestTimeout == emptyDuration {
|
||||
cfg.Metadata.RequestTimeout.Duration = time.Duration(defaultTimeOut)
|
||||
}
|
||||
provider.HTTPClient.Timeout = cfg.Metadata.RequestTimeout.Duration
|
||||
|
||||
os := OpenStack{
|
||||
provider: provider,
|
||||
region: cfg.Global.Region,
|
||||
|
|
Loading…
Reference in New Issue