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