sort config files first
This commit is contained in:
parent
7e4f3c9e4f
commit
e70f7ed900
|
@ -7,6 +7,7 @@ package api
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
log "github.com/cihub/seelog"
|
||||||
"infini.sh/framework/core/elastic"
|
"infini.sh/framework/core/elastic"
|
||||||
"infini.sh/framework/core/global"
|
"infini.sh/framework/core/global"
|
||||||
"infini.sh/framework/core/kv"
|
"infini.sh/framework/core/kv"
|
||||||
|
@ -15,7 +16,6 @@ import (
|
||||||
"infini.sh/framework/core/util"
|
"infini.sh/framework/core/util"
|
||||||
common2 "infini.sh/framework/modules/elastic/common"
|
common2 "infini.sh/framework/modules/elastic/common"
|
||||||
"infini.sh/framework/plugins/managed/common"
|
"infini.sh/framework/plugins/managed/common"
|
||||||
log "github.com/cihub/seelog"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -97,9 +97,6 @@ func dynamicAgentConfigProvider(instance model.Instance) []*common.ConfigFile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if len(ids) > 0 {
|
if len(ids) > 0 {
|
||||||
|
|
||||||
cfg := common.ConfigFile{}
|
cfg := common.ConfigFile{}
|
||||||
|
@ -116,7 +113,7 @@ func dynamicAgentConfigProvider(instance model.Instance) []*common.ConfigFile {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
latestTimestamp = time.Now().Unix()
|
latestTimestamp = time.Now().Unix()
|
||||||
log.Error("local hash is different from remote's hash, update local's hash, update version to current timestamp")
|
log.Info("local hash is different from remote's hash, update local's hash, update version to current timestamp")
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.Size = int64(len(cfg.Content))
|
cfg.Size = int64(len(cfg.Content))
|
||||||
|
@ -126,8 +123,6 @@ func dynamicAgentConfigProvider(instance model.Instance) []*common.ConfigFile {
|
||||||
result = append(result, &cfg)
|
result = append(result, &cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,8 +130,20 @@ func getAgentIngestConfigs(items map[string]BindingItem) string {
|
||||||
|
|
||||||
buffer := bytes.NewBuffer([]byte("configs.template: "))
|
buffer := bytes.NewBuffer([]byte("configs.template: "))
|
||||||
|
|
||||||
|
//sort items
|
||||||
|
newItems := []util.KeyValue{}
|
||||||
|
|
||||||
|
for k, v := range items {
|
||||||
|
newItems = append(newItems, util.KeyValue{Key: k, Value: v.Updated,Payload: v})
|
||||||
|
}
|
||||||
|
|
||||||
|
newItems=util.SortKeyValueArray(newItems,false)
|
||||||
|
|
||||||
var latestVersion int64
|
var latestVersion int64
|
||||||
for _, v := range items {
|
for _, x := range newItems {
|
||||||
|
|
||||||
|
v,ok:=x.Payload.(BindingItem)
|
||||||
|
if !ok{continue}
|
||||||
|
|
||||||
if v.ClusterID == "" {
|
if v.ClusterID == "" {
|
||||||
panic("cluster id is empty")
|
panic("cluster id is empty")
|
||||||
|
@ -181,7 +188,6 @@ func getAgentIngestConfigs(items map[string]BindingItem) string {
|
||||||
"NODE_LOGS_PATH: \"%v\"\n\n\n", v.NodeUUID, v.ClusterID, clusterEndPoint, username, password, clusterLevelEnabled, nodeLevelEnabled, v.PathLogs)))
|
"NODE_LOGS_PATH: \"%v\"\n\n\n", v.NodeUUID, v.ClusterID, clusterEndPoint, username, password, clusterLevelEnabled, nodeLevelEnabled, v.PathLogs)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//password: $[[keystore.$[[CLUSTER_ID]]_password]]
|
//password: $[[keystore.$[[CLUSTER_ID]]_password]]
|
||||||
buffer.WriteString("\n")
|
buffer.WriteString("\n")
|
||||||
buffer.WriteString(fmt.Sprintf("#MANAGED_CONFIG_VERSION: %v\n#MANAGED: true\n", latestVersion))
|
buffer.WriteString(fmt.Sprintf("#MANAGED_CONFIG_VERSION: %v\n#MANAGED: true\n", latestVersion))
|
||||||
|
@ -190,4 +196,3 @@ func getAgentIngestConfigs(items map[string]BindingItem) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
const LastAgentHash = "last_agent_hash"
|
const LastAgentHash = "last_agent_hash"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue