File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 77- [ index] Add include_type_name for compatibility between ESv6/7
88
99### Fixed
10+ - [ provider] Add a timeout for pinging ES in case of no network access.
1011
1112
1213## [ 2.0.0-beta.1] - 2021-08-30
Original file line number Diff line number Diff line change @@ -26,6 +26,13 @@ import (
2626 elastic6 "gopkg.in/olivere/elastic.v6"
2727)
2828
29+ const (
30+ // DefaultVersionPingTimeout is the time the ping to check the cluster
31+ // version waits for a response from Elasticsearch on startup, i.e. when
32+ // creating a provider.
33+ DefaultVersionPingTimeout = 5 * time .Second
34+ )
35+
2936var awsUrlRegexp = regexp .MustCompile (`([a-z0-9-]+).es.amazonaws.com$` )
3037
3138type ProviderConf struct {
@@ -299,7 +306,9 @@ func getClient(conf *ProviderConf) (interface{}, error) {
299306 // Use the v7 client to ping the cluster to determine the version if one was not provided
300307 if conf .esVersion == "" {
301308 log .Printf ("[INFO] Pinging url to determine version %+v" , conf .rawUrl )
302- info , httpStatus , err := client .Ping (conf .rawUrl ).Do (context .TODO ())
309+ ctx , cancel := context .WithTimeout (context .Background (), DefaultVersionPingTimeout )
310+ defer cancel ()
311+ info , httpStatus , err := client .Ping (conf .rawUrl ).Do (ctx )
303312 if httpStatus == http .StatusForbidden {
304313 return nil , errors .New ("HTTP 403 Forbidden: Permission denied. Please ensure that the correct credentials are being used to access the cluster." )
305314 }
You can’t perform that action at this time.
0 commit comments