Merge pull request #9758 from hashicorp/dnephin/fix-streaming-bugs

http: error if near is used with streaming
This commit is contained in:
Daniel Nephin 2021-02-12 10:37:29 -05:00 committed by hashicorp-ci
parent bee9b55f3e
commit 8db1a08fc9
2 changed files with 8 additions and 5 deletions

View File

@ -219,12 +219,13 @@ func (s *HTTPHandlers) healthServiceNodes(resp http.ResponseWriter, req *http.Re
return nil, nil return nil, nil
} }
// useStreaming when a blocking query is requested, but not when the near useStreaming := s.agent.config.UseStreamingBackend && args.MinQueryIndex > 0
// query parameter is set, because that requires data only available to the server
// to sort the results.
useStreaming := s.agent.config.UseStreamingBackend && args.MinQueryIndex > 0 && args.Source.Node == ""
args.QueryOptions.UseCache = s.agent.config.HTTPUseCache && (args.QueryOptions.UseCache || useStreaming) args.QueryOptions.UseCache = s.agent.config.HTTPUseCache && (args.QueryOptions.UseCache || useStreaming)
if args.QueryOptions.UseCache && useStreaming && args.Source.Node != "" {
return nil, BadRequestError{Reason: "'near' query param can not be used with streaming"}
}
out, md, err := s.agent.rpcClientHealth.ServiceNodes(req.Context(), args) out, md, err := s.agent.rpcClientHealth.ServiceNodes(req.Context(), args)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -232,7 +232,9 @@ The table below shows this endpoint's support for
- `near` `(string: "")` - Specifies a node name to sort the node list in - `near` `(string: "")` - Specifies a node name to sort the node list in
ascending order based on the estimated round trip time from that node. Passing ascending order based on the estimated round trip time from that node. Passing
`?near=_agent` will use the agent's node for the sort. This is specified as `?near=_agent` will use the agent's node for the sort. This is specified as
part of the URL as a query parameter. part of the URL as a query parameter. **Note** that `near` can not be used if
[`use_streaming_backend`](/docs/agent/options#use_streaming_backend)
is enabled, because the data is not available to sort the results.
- `tag` `(string: "")` **Deprecated** - Use `filter` with the `Service.Tags` selector instead. - `tag` `(string: "")` **Deprecated** - Use `filter` with the `Service.Tags` selector instead.
This parameter will be removed in a future version of Consul. This parameter will be removed in a future version of Consul.