Commit 9e9ebc04 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #53195 from dixudx/add_timeout_for_openstack_cloudprovider

Automatic merge from submit-queue (batch tested with PRs 51750, 53195, 53384, 53410). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. add http request timeout for OpenStack cloud provider **What this PR does / why we need it**: **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #53191 **Special notes for your reviewer**: /assign @NickrenREN @dims @FengyunPan **Release note**: ```release-note None ```
parents ecfff662 fe92a554
...@@ -52,6 +52,7 @@ import ( ...@@ -52,6 +52,7 @@ import (
const ( const (
ProviderName = "openstack" ProviderName = "openstack"
AvailabilityZone = "availability_zone" AvailabilityZone = "availability_zone"
defaultTimeOut = 60 * time.Second
) )
var ErrNotFound = errors.New("Failed to find object") var ErrNotFound = errors.New("Failed to find object")
...@@ -101,7 +102,8 @@ type RouterOpts struct { ...@@ -101,7 +102,8 @@ type RouterOpts struct {
} }
type MetadataOpts struct { type MetadataOpts struct {
SearchOrder string `gcfg:"search-order"` SearchOrder string `gcfg:"search-order"`
RequestTimeout MyDuration `gcfg:"request-timeout"`
} }
// OpenStack is an implementation of cloud provider Interface for OpenStack. // OpenStack is an implementation of cloud provider Interface for OpenStack.
...@@ -290,6 +292,12 @@ func newOpenStack(cfg Config) (*OpenStack, error) { ...@@ -290,6 +292,12 @@ func newOpenStack(cfg Config) (*OpenStack, error) {
return nil, err 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{ os := OpenStack{
provider: provider, provider: provider,
region: cfg.Global.Region, region: cfg.Global.Region,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment