diff --git a/agent/health_endpoint.go b/agent/health_endpoint.go index 0d8e2f1e8..b2b7cb086 100644 --- a/agent/health_endpoint.go +++ b/agent/health_endpoint.go @@ -219,12 +219,13 @@ func (s *HTTPHandlers) healthServiceNodes(resp http.ResponseWriter, req *http.Re return nil, nil } - // useStreaming when a blocking query is requested, but not when the near - // 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 == "" + useStreaming := s.agent.config.UseStreamingBackend && args.MinQueryIndex > 0 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) if err != nil { return nil, err diff --git a/website/content/api-docs/health.mdx b/website/content/api-docs/health.mdx index 7038d9427..bfe9c6e9a 100644 --- a/website/content/api-docs/health.mdx +++ b/website/content/api-docs/health.mdx @@ -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 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 - 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. This parameter will be removed in a future version of Consul.