diff --git a/apiserver/httpserver/utils/handler.go b/apiserver/httpserver/utils/handler.go index e8d1c91d9..f757a7d75 100644 --- a/apiserver/httpserver/utils/handler.go +++ b/apiserver/httpserver/utils/handler.go @@ -389,10 +389,13 @@ func ParseQueryParams(req *restful.Request) map[string]string { queryParams := make(map[string]string) for key, value := range req.Request.URL.Query() { if len(value) > 0 { - queryParams[key] = value[0] // 暂时默认只支持一个查询 + if key == "keys" || key == "values" { + queryParams[key] = strings.Join(value, ",") + } else { + queryParams[key] = value[0] // 暂时默认只支持一个查询 + } } } - return queryParams } diff --git a/service/instance.go b/service/instance.go index a8508d02a..693dbf468 100644 --- a/service/instance.go +++ b/service/instance.go @@ -22,6 +22,7 @@ import ( "errors" "fmt" "strconv" + "strings" "time" "github.com/gogo/protobuf/jsonpb" @@ -1237,7 +1238,17 @@ func preGetInstances(query map[string]string) (map[string]string, map[string]str apimodel.Code_InvalidQueryInsParameter, "instance metadata key and value must be both provided") } if metaKeyAvail { - metaFilter = map[string]string{metaKey: metaValue} + metaFilter = map[string]string{} + keys := strings.Split(metaKey, ",") + values := strings.Split(metaValue, ",") + if len(keys) == len(values) { + for i := range keys { + metaFilter[keys[i]] = values[i] + } + } else { + return nil, nil, api.NewBatchQueryResponseWithMsg( + apimodel.Code_InvalidQueryInsParameter, "instance metadata key and value length are different") + } } // 以healthy为准