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 9d36db3a2a
commit 57380ea752
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 { if err != nil {
return err return err
} }
for _, sn := range serviceList { for _, sn := range serviceList {
if _, ok := exportedServices[sn]; !ok { if _, ok := exportedServices[sn]; !ok {
err := s.handleUpdateService(peerName, partition, sn, nil) 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) return fmt.Errorf("failed to read imported services: %w", err)
} }
structsNodes, err := export.CheckServiceNodesToStruct() structsNodes := []structs.CheckServiceNode{}
if err != nil { if export != nil {
return fmt.Errorf("failed to convert protobuf instances to structs: %w", err) 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. // Normalize the data into a convenient form for operation.