Skip to content

Commit 4662b20

Browse files
committed
Get Elasticsearch version from any node. Fixes issue #743.
1 parent 83788e7 commit 4662b20

3 files changed

Lines changed: 13 additions & 14 deletions

File tree

docker/release/.tag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rwynn/monstache:6.7.20
1+
rwynn/monstache:6.7.21

docker/release/.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.7.20
1+
6.7.21

monstache.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var chunksRegex = regexp.MustCompile(`\.chunks$`)
8787
var systemsRegex = regexp.MustCompile(`system\..+$`)
8888
var exitStatus = 0
8989

90-
const version = "6.7.20"
90+
const version = "6.7.21"
9191
const mongoURLDefault string = "mongodb://localhost:27017"
9292
const resumeNameDefault string = "default"
9393
const elasticMaxConnsDefault int = 4
@@ -730,15 +730,16 @@ func (config *configOptions) newElasticClient() (client *elastic.Client, err err
730730
return elastic.NewClient(clientOptions...)
731731
}
732732

733-
func (config *configOptions) testElasticsearchConn(client *elastic.Client) (err error) {
734-
var number string
735-
url := config.ElasticUrls[0]
736-
number, err = client.ElasticsearchVersion(url)
737-
if err == nil {
738-
infoLog.Printf("Successfully connected to Elasticsearch version %s", number)
739-
err = config.parseElasticsearchVersion(number)
733+
func (config *configOptions) getElasticsearchVersion(client *elastic.Client) {
734+
for _, url := range config.ElasticUrls {
735+
version, err := client.ElasticsearchVersion(url)
736+
if err == nil {
737+
if err = config.parseElasticsearchVersion(version); err == nil {
738+
infoLog.Printf("Successfully connected to Elasticsearch version %s", version)
739+
break
740+
}
741+
}
740742
}
741-
return
742743
}
743744

744745
func (ic *indexClient) deleteIndexes(db string) (err error) {
@@ -5323,9 +5324,7 @@ func buildElasticClient(config *configOptions) *elastic.Client {
53235324
errorLog.Fatalf("Unable to create Elasticsearch client: %s", err)
53245325
}
53255326
if config.ElasticVersion == "" {
5326-
if err := config.testElasticsearchConn(elasticClient); err != nil {
5327-
errorLog.Fatalf("Unable to validate connection to Elasticsearch: %s", err)
5328-
}
5327+
config.getElasticsearchVersion(elasticClient)
53295328
} else {
53305329
if err := config.parseElasticsearchVersion(config.ElasticVersion); err != nil {
53315330
errorLog.Fatalf("Elasticsearch version must conform to major.minor.fix: %s", err)

0 commit comments

Comments
 (0)