Fix namespaced peer service updates / deletes. (#17456)

* Fix namespaced peer service updates / deletes.

This change fixes a function so that namespaced services are
correctly queried when handling updates / deletes. Prior to this
change, some peered services would not correctly be un-exported.

* Add changelog.
This commit is contained in:
Derek Menteer 2023-05-24 16:32:45 -05:00 committed by GitHub
parent b8eb98fcac
commit e2f15cfe56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

3
.changelog/17456.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
peering: Fix issue where modifying the list of exported services did not correctly replicate changes for services that exist in a non-default namespace.
```

View File

@ -285,9 +285,11 @@ func (s *Server) handleUpsertExportedServiceList(
exportedServices[snSidecarProxy] = struct{}{} exportedServices[snSidecarProxy] = struct{}{}
serviceNames = append(serviceNames, sn) serviceNames = append(serviceNames, sn)
} }
entMeta := structs.NodeEnterpriseMetaInPartition(partition)
_, serviceList, err := s.GetStore().ServiceList(nil, entMeta, peerName) // Ensure we query services from all namespaces in this partition when we perform
// this query or else we may not propagate updates / deletes correctly.
entMeta := acl.NewEnterpriseMetaWithPartition(partition, acl.WildcardName)
_, serviceList, err := s.GetStore().ServiceList(nil, &entMeta, peerName)
if err != nil { if err != nil {
return err return err
} }

View File

@ -1960,7 +1960,7 @@ func processResponse_ExportedServiceUpdates(
localEntMeta acl.EnterpriseMeta, localEntMeta acl.EnterpriseMeta,
peerName string, peerName string,
tests []PeeringProcessResponse_testCase, tests []PeeringProcessResponse_testCase,
) { ) *MutableStatus {
// create a peering in the state store // create a peering in the state store
peerID := "1fabcd52-1d46-49b0-b1d8-71559aee47f5" peerID := "1fabcd52-1d46-49b0-b1d8-71559aee47f5"
require.NoError(t, store.PeeringWrite(31, &pbpeering.PeeringWriteRequest{ require.NoError(t, store.PeeringWrite(31, &pbpeering.PeeringWriteRequest{
@ -2041,6 +2041,7 @@ func processResponse_ExportedServiceUpdates(
run(t, tc) run(t, tc)
}) })
} }
return mst
} }
func Test_processResponse_ExportedServiceUpdates(t *testing.T) { func Test_processResponse_ExportedServiceUpdates(t *testing.T) {