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
```
pull/6/head
Kubernetes Submit Queue 2017-10-05 06:08:58 -07:00 committed by GitHub
commit 9e9ebc04fb
1 changed files with 9 additions and 1 deletions

View File

@ -52,6 +52,7 @@ import (
const (
ProviderName = "openstack"
AvailabilityZone = "availability_zone"
defaultTimeOut = 60 * time.Second
)
var ErrNotFound = errors.New("Failed to find object")
@ -101,7 +102,8 @@ type RouterOpts 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.
@ -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,