Skip to content

[release-1.28] fix: add http timeout to avoid connection stuck #8394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/azclient/factory_conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package azclient
import (
"net/http"
"sync"
"time"

"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/policy"
"github.com/Azure/go-armbalancer"
Expand All @@ -37,6 +38,7 @@ func init() {
Transport: utils.DefaultTransport,
PoolSize: 100,
}),
Timeout: time.Minute,
}
})
}
Expand Down
1 change: 1 addition & 0 deletions pkg/azclient/utils/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func GetDefaultOption() *arm.ClientOptions {
},
Transport: &http.Client{
Transport: DefaultTransport,
Timeout: time.Minute,
},
TracingProvider: tracing.NewProvider(func(name, version string) tracing.Tracer {
return tracing.NewTracer(NewOtlpSpan, nil)
Expand Down
5 changes: 3 additions & 2 deletions pkg/provider/azure_instance_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"io"
"net/http"
"strings"
"time"

"k8s.io/klog/v2"

Expand Down Expand Up @@ -189,7 +190,7 @@ func (ims *InstanceMetadataService) getInstanceMetadata(key string) (*InstanceMe
q.Add("api-version", consts.ImdsInstanceAPIVersion)
req.URL.RawQuery = q.Encode()

client := &http.Client{}
client := &http.Client{Timeout: time.Minute}
resp, err := client.Do(req)
if err != nil {
return nil, err
Expand Down Expand Up @@ -227,7 +228,7 @@ func (ims *InstanceMetadataService) getLoadBalancerMetadata() (*LoadBalancerMeta
q.Add("api-version", consts.ImdsLoadBalancerAPIVersion)
req.URL.RawQuery = q.Encode()

client := &http.Client{}
client := &http.Client{Timeout: time.Minute}
resp, err := client.Do(req)
if err != nil {
return nil, err
Expand Down
Loading