Skip to content

Commit

Permalink
Merge pull request kubernetes#53195 from dixudx/add_timeout_for_opens…
Browse files Browse the repository at this point in the history
…tack_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 kubernetes#53191

**Special notes for your reviewer**:
/assign @NickrenREN @dims @FengyunPan 

**Release note**:

```release-note
None
```
  • Loading branch information
Kubernetes Submit Queue authored Oct 5, 2017
2 parents ecfff66 + fe92a55 commit 9e9ebc0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/cloudprovider/providers/openstack/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import (
const (
ProviderName = "openstack"
AvailabilityZone = "availability_zone"
defaultTimeOut = 60 * time.Second
)

var ErrNotFound = errors.New("Failed to find object")
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 9e9ebc0

Please sign in to comment.