Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.

Commit 47f71bb

Browse files
author
Kubernetes Submit Queue
authored
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 ```
2 parents 2ec6023 + 28cad7a commit 47f71bb

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

pkg/cloudprovider/providers/openstack/openstack.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import (
5252
const (
5353
ProviderName = "openstack"
5454
AvailabilityZone = "availability_zone"
55+
defaultTimeOut = 60 * time.Second
5556
)
5657

5758
var ErrNotFound = errors.New("Failed to find object")
@@ -101,7 +102,8 @@ type RouterOpts struct {
101102
}
102103

103104
type MetadataOpts struct {
104-
SearchOrder string `gcfg:"search-order"`
105+
SearchOrder string `gcfg:"search-order"`
106+
RequestTimeout MyDuration `gcfg:"request-timeout"`
105107
}
106108

107109
// OpenStack is an implementation of cloud provider Interface for OpenStack.
@@ -290,6 +292,12 @@ func newOpenStack(cfg Config) (*OpenStack, error) {
290292
return nil, err
291293
}
292294

295+
emptyDuration := MyDuration{}
296+
if cfg.Metadata.RequestTimeout == emptyDuration {
297+
cfg.Metadata.RequestTimeout.Duration = time.Duration(defaultTimeOut)
298+
}
299+
provider.HTTPClient.Timeout = cfg.Metadata.RequestTimeout.Duration
300+
293301
os := OpenStack{
294302
provider: provider,
295303
region: cfg.Global.Region,

0 commit comments

Comments
 (0)