Skip to content

Commit 77e252e

Browse files
authored
fix(api,cdn): set timeout for swift client (#6614)
1 parent 2c8cc0f commit 77e252e

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

engine/api/objectstore/swift.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ func newSwiftStore(ctx context.Context, integration sdk.ProjectIntegration, conf
2626
log.Info(ctx, "ObjectStore> Initialize Swift driver on url: %s", conf.Address)
2727
s := &SwiftStore{
2828
Connection: swift.Connection{
29-
AuthUrl: conf.Address,
30-
Region: conf.Region,
31-
Tenant: conf.Tenant,
32-
Domain: conf.Domain,
33-
UserName: conf.Username,
34-
ApiKey: conf.Password,
29+
AuthUrl: conf.Address,
30+
Region: conf.Region,
31+
Tenant: conf.Tenant,
32+
Domain: conf.Domain,
33+
UserName: conf.Username,
34+
ApiKey: conf.Password,
35+
ConnectTimeout: time.Minute * 1,
36+
Timeout: time.Minute * 10,
3537
},
3638
containerPrefix: conf.ContainerPrefix,
3739
disableTempURL: conf.DisableTempURL,

engine/cdn/storage/swift/swift.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"io"
77
"net/url"
88
"strings"
9+
"time"
910

1011
"github.com/go-gorp/gorp"
1112
"github.com/ncw/swift"
@@ -46,12 +47,14 @@ func (s *Swift) Init(_ context.Context, cfg interface{}) error {
4647
s.config = *config
4748
s.ConvergentEncryption = encryption.New(config.Encryption)
4849
s.client = swift.Connection{
49-
AuthUrl: config.Address,
50-
Region: config.Region,
51-
Tenant: config.Tenant,
52-
Domain: config.Domain,
53-
UserName: config.Username,
54-
ApiKey: config.Password,
50+
AuthUrl: config.Address,
51+
Region: config.Region,
52+
Tenant: config.Tenant,
53+
Domain: config.Domain,
54+
UserName: config.Username,
55+
ApiKey: config.Password,
56+
ConnectTimeout: time.Minute * 1,
57+
Timeout: time.Minute * 10,
5558
}
5659
return sdk.WithStack(s.client.Authenticate())
5760
}

0 commit comments

Comments
 (0)