fix agent dispatch task bug

This commit is contained in:
liugq 2023-07-12 23:02:22 +08:00
parent 464a2f9bea
commit 3137efd397
1 changed files with 9 additions and 7 deletions

View File

@ -236,6 +236,7 @@ func (h *APIHandler) getInstanceStats(w http.ResponseWriter, req *http.Request,
} }
q := orm.Query{} q := orm.Query{}
queryDSL := util.MapStr{ queryDSL := util.MapStr{
"size": len(instanceIDs),
"query": util.MapStr{ "query": util.MapStr{
"terms": util.MapStr{ "terms": util.MapStr{
"_id": instanceIDs, "_id": instanceIDs,
@ -797,24 +798,25 @@ func getSettingsByClusterID(clusterID string) (*model.TaskSetting, error) {
}, },
}, },
}, },
"minimum_should_match": 1,
"should": []util.MapStr{ "should": []util.MapStr{
{ {
"term": util.MapStr{ "term": util.MapStr{
"payload.task.cluster_health": util.MapStr{ "payload.task.cluster_health.enabled": util.MapStr{
"value": true, "value": true,
}, },
}, },
}, },
{ {
"term": util.MapStr{ "term": util.MapStr{
"payload.task.cluster_stats": util.MapStr{ "payload.task.cluster_stats.enabled": util.MapStr{
"value": true, "value": true,
}, },
}, },
}, },
{ {
"term": util.MapStr{ "term": util.MapStr{
"payload.task.index_stats": util.MapStr{ "payload.task.index_stats.enabled": util.MapStr{
"value": true, "value": true,
}, },
}, },
@ -841,7 +843,7 @@ func getSettingsByClusterID(clusterID string) (*model.TaskSetting, error) {
indexStats = true indexStats = true
clusterHealth = true clusterHealth = true
) )
keys := []string{"payload.task.cluster_stats", "payload.task.cluster_health", "payload.task.index_stats"} keys := []string{"payload.task.cluster_stats.enabled", "payload.task.cluster_health.enabled", "payload.task.index_stats.enabled"}
for _, row := range result.Result { for _, row := range result.Result {
if v, ok := row.(map[string]interface{}); ok { if v, ok := row.(map[string]interface{}); ok {
vm := util.MapStr(v) vm := util.MapStr(v)
@ -849,11 +851,11 @@ func getSettingsByClusterID(clusterID string) (*model.TaskSetting, error) {
tv, _ := vm.GetValue(key) tv, _ := vm.GetValue(key)
if tv == true { if tv == true {
switch key { switch key {
case "payload.task.cluster_stats": case "payload.task.cluster_stats.enabled":
clusterStats = false clusterStats = false
case "payload.task.index_stats": case "payload.task.index_stats.enabled":
indexStats = false indexStats = false
case "payload.task.cluster_health": case "payload.task.cluster_health.enabled":
clusterHealth = false clusterHealth = false
} }
} }