From 6c7c0cf66df05a9f8b2b2e545a7eac4b517c2c42 Mon Sep 17 00:00:00 2001 From: hc-github-team-consul-core Date: Wed, 24 May 2023 17:55:16 -0400 Subject: [PATCH] Backport of Fix namespaced peer service updates / deletes. into release/1.15.x (#17458) * backport of commit dc995c18fd9f4b0a7277cffd8dde35f3ed01d7fd * backport of commit 169a3279b6563514dc79d21b6e28f85237cb8545 --------- Co-authored-by: Derek Menteer --- .changelog/17456.txt | 3 +++ agent/grpc-external/services/peerstream/replication.go | 6 ++++-- agent/grpc-external/services/peerstream/stream_test.go | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changelog/17456.txt diff --git a/.changelog/17456.txt b/.changelog/17456.txt new file mode 100644 index 0000000000..7b81d53543 --- /dev/null +++ b/.changelog/17456.txt @@ -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. +``` diff --git a/agent/grpc-external/services/peerstream/replication.go b/agent/grpc-external/services/peerstream/replication.go index 45f66add78..f00b0b590a 100644 --- a/agent/grpc-external/services/peerstream/replication.go +++ b/agent/grpc-external/services/peerstream/replication.go @@ -282,9 +282,11 @@ func (s *Server) handleUpsertExportedServiceList( exportedServices[snSidecarProxy] = struct{}{} 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 { return err } diff --git a/agent/grpc-external/services/peerstream/stream_test.go b/agent/grpc-external/services/peerstream/stream_test.go index 7109460c2c..887364b107 100644 --- a/agent/grpc-external/services/peerstream/stream_test.go +++ b/agent/grpc-external/services/peerstream/stream_test.go @@ -1957,7 +1957,7 @@ func processResponse_ExportedServiceUpdates( localEntMeta acl.EnterpriseMeta, peerName string, tests []PeeringProcessResponse_testCase, -) { +) *MutableStatus { // create a peering in the state store peerID := "1fabcd52-1d46-49b0-b1d8-71559aee47f5" require.NoError(t, store.PeeringWrite(31, &pbpeering.PeeringWriteRequest{ @@ -2038,6 +2038,7 @@ func processResponse_ExportedServiceUpdates( run(t, tc) }) } + return mst } func Test_processResponse_ExportedServiceUpdates(t *testing.T) {