fix(peering): nil pointer in calling handleUpdateService (#15160)

* fix(peering): nil pointer in calling handleUpdateService

* changelog
This commit is contained in:
cskh 2022-10-26 11:50:34 -04:00 committed by GitHub
parent e5130be812
commit a9427e1310
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

3
.changelog/15160.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
peering: fix nil pointer in calling handleUpdateService
```

View File

@ -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.