Fix Elastic crash with no index (#13406)

Removed naked assert.

Fixes #13389
This commit is contained in:
Klaus Post 2021-10-11 10:07:38 -07:00 committed by GitHub
parent 05fa790584
commit 9f652708ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -419,7 +419,8 @@ func (c *esClientV7) createIndex(args ElasticsearchArgs) error {
return fmt.Errorf("Error parsing response body: %v", err)
}
indices := v["indices"].([]interface{})
indices, ok := v["indices"].([]interface{})
if ok {
for _, index := range indices {
name := index.(map[string]interface{})["name"]
if name == args.Index {
@ -427,6 +428,7 @@ func (c *esClientV7) createIndex(args ElasticsearchArgs) error {
break
}
}
}
if !found {
resp, err := c.Indices.Create(args.Index)