Backport of add a conditional around setting LANFilter.AllSegments to make sure it is valid into release/1.16.x (#18146)

* no-op commit due to failed cherry-picking

* add a conditional around setting LANFilter.AllSegments to make sure it is valid (#18139)

This is to correct a code problem because this assumes all segments, but
when you get to Enterprise, you can be in partition that is not the
default partition, in which case specifying all segments does not
validate and fails. This is to correct the setting of this filter with
`AllSegments` to `true` to only occur when in the the `default`
partition.

<!--

* In the case of bugs, describe how to replicate
* If any manual tests were done, document the steps and the conditions
to replicate
* Call out any important/ relevant unit tests, e2e tests or integration
tests you have added or are adding

-->

<!--

Include any links here that might be helpful for people reviewing your
PR (Tickets, GH issues, API docs, external benchmarks, tools docs, etc).
If there are none, feel free to delete this section.

Please be mindful not to leak any customer or confidential information.
HashiCorp employees may want to use our internal URL shortener to
obfuscate links.

-->

* [ ] updated test coverage
* [ ] external facing docs updated
* [ ] appropriate backport labels added
* [ ] not a security concern

---------

Co-authored-by: temp <temp@hashicorp.com>
Co-authored-by: John Murret <john.murret@hashicorp.com>
This commit is contained in:
hc-github-team-consul-core 2023-07-17 12:59:44 -05:00 committed by GitHub
parent 6a5244bf9c
commit 788225832e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -190,7 +190,11 @@ func AgentMembersMapAddrVer(s *HTTPHandlers, req *http.Request) (map[string]stri
filter := consul.LANMemberFilter{
Partition: entMeta.PartitionOrDefault(),
}
if acl.IsDefaultPartition(filter.Partition) {
filter.AllSegments = true
}
lanMembers, err := s.agent.delegate.LANMembers(filter)
if err != nil {
return nil, err