fix empty cluster_uuid
This commit is contained in:
parent
43de31f656
commit
8d5e7e8a6b
|
@ -18,6 +18,7 @@ import (
|
|||
"infini.sh/framework/core/util"
|
||||
common2 "infini.sh/console/modules/agent/common"
|
||||
elastic2 "infini.sh/framework/modules/elastic"
|
||||
"infini.sh/framework/modules/elastic/adapter"
|
||||
"infini.sh/framework/modules/elastic/common"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
@ -579,8 +580,16 @@ func getClusterConfigs() map[string]*elastic.ElasticsearchConfig {
|
|||
cfgs := map[string]*elastic.ElasticsearchConfig{}
|
||||
elastic.WalkConfigs(func(key, value interface{}) bool {
|
||||
if cfg, ok := value.(*elastic.ElasticsearchConfig); ok {
|
||||
//todo handle clusterUUID is empty
|
||||
cfgs[cfg.ClusterUUID] = cfg
|
||||
clusterUUID := cfg.ClusterUUID
|
||||
if cfg.ClusterUUID == "" {
|
||||
verInfo, err := adapter.ClusterVersion(elastic.GetMetadata(cfg.ID))
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return true
|
||||
}
|
||||
clusterUUID = verInfo.ClusterUUID
|
||||
}
|
||||
cfgs[clusterUUID] = cfg
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
|
|
@ -178,6 +178,10 @@ func (module *Module) validate(w http.ResponseWriter, r *http.Request, ps httpro
|
|||
|
||||
//validate version
|
||||
verInfo, err := adapter.ClusterVersion(elastic.GetMetadata(cfg.ID))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cfg.ClusterUUID = verInfo.ClusterUUID
|
||||
if verInfo.Version.Distribution == elastic.Elasticsearch {
|
||||
if verInfo.Version.Number != "" {
|
||||
ver := &util.Version{}
|
||||
|
|
Loading…
Reference in New Issue