From a9427e13101a26654e58d04a0474187a78f091f6 Mon Sep 17 00:00:00 2001 From: cskh Date: Wed, 26 Oct 2022 11:50:34 -0400 Subject: [PATCH] fix(peering): nil pointer in calling handleUpdateService (#15160) * fix(peering): nil pointer in calling handleUpdateService * changelog --- .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.