Skip to content

Commit

Permalink
Fix ES schema comparison in healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
gotha committed Jun 24, 2020
1 parent 2bbac5b commit 5827f47
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/es/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,29 @@ func (s *ElasticsearchService) GetSchemaHealth() (string, error) {
return "", err
}

settings, ok := liveIndex[s.IndexName].Settings["index"].(map[string]interface{})
indices := make([]string, 0, len(liveIndex))
for indexName := range liveIndex {
indices = append(indices, indexName)
}
if len(indices) < 1 {
return fmt.Sprintf("not ok, could not find index or alias %s", s.IndexName), nil
}
// we are getting the first index name because we are fetching by index or alias but response is real name
realIndexName := indices[0]

settings, ok := liveIndex[realIndexName].Settings["index"].(map[string]interface{})
if ok {
delete(settings, "creation_date")
delete(settings, "uuid")
delete(settings, "version")
delete(settings, "created")
}

if !reflect.DeepEqual(liveIndex[s.IndexName].Settings, referenceIndex.index[s.IndexName].Settings) {
if !reflect.DeepEqual(liveIndex[realIndexName].Settings, referenceIndex.index[s.IndexName].Settings) {
return "not ok, wrong settings", nil
}

if !reflect.DeepEqual(liveIndex[s.IndexName].Mappings, referenceIndex.index[s.IndexName].Mappings) {
if !reflect.DeepEqual(liveIndex[realIndexName].Mappings, referenceIndex.index[s.IndexName].Mappings) {
return "not ok, wrong mappings", nil
}

Expand Down

0 comments on commit 5827f47

Please sign in to comment.