From 8e7e92987567f1363b3ccce88f38d6ff533088e4 Mon Sep 17 00:00:00 2001 From: hc-github-team-consul-core Date: Wed, 26 Oct 2022 11:50:55 -0400 Subject: [PATCH] Backport of fix(peering): nil pointer in calling handleUpdateService into release/1.14.x (#15162) This pull request was automerged via backport-assistant --- .changelog/15160.txt | 3 +++ agent/grpc-external/services/peerstream/replication.go | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changelog/15160.txt diff --git a/.changelog/15160.txt b/.changelog/15160.txt new file mode 100644 index 0000000000..8cfda548f5 --- /dev/null +++ b/.changelog/15160.txt @@ -0,0 +1,3 @@ +```release-note:bug +peering: fix nil pointer in calling handleUpdateService +``` \ No newline at end of file diff --git a/agent/grpc-external/services/peerstream/replication.go b/agent/grpc-external/services/peerstream/replication.go index c43262b053..908c6d2457 100644 --- a/agent/grpc-external/services/peerstream/replication.go +++ b/agent/grpc-external/services/peerstream/replication.go @@ -287,7 +287,6 @@ func (s *Server) handleUpsertExportedServiceList( if err != nil { return err } - for _, sn := range serviceList { if _, ok := exportedServices[sn]; !ok { err := s.handleUpdateService(peerName, partition, sn, nil) @@ -324,9 +323,12 @@ func (s *Server) handleUpdateService( return fmt.Errorf("failed to read imported services: %w", err) } - structsNodes, err := export.CheckServiceNodesToStruct() - if err != nil { - return fmt.Errorf("failed to convert protobuf instances to structs: %w", err) + structsNodes := []structs.CheckServiceNode{} + if export != nil { + structsNodes, err = export.CheckServiceNodesToStruct() + if err != nil { + return fmt.Errorf("failed to convert protobuf instances to structs: %w", err) + } } // Normalize the data into a convenient form for operation.