Skip to content

Commit

Permalink
Merge pull request #750 from ersonp/bug/hypervisor-panic
Browse files Browse the repository at this point in the history
Solve nil pointer derefrence
  • Loading branch information
jdknives authored May 5, 2021
2 parents bc08494 + 8e29830 commit d3a7d7d
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions pkg/visor/hypervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,12 @@ func (hv *Hypervisor) getVisorsExtraSummary() http.HandlerFunc {
summary, err := hv.visor.ExtraSummary()
if err != nil {
log.WithError(err).Warn("Failed to obtain summary of this visor.")
summary = &ExtraSummary{}
summary.Summary.PubKey = hv.visor.conf.PK
summary = &ExtraSummary{
Summary: &Summary{
PubKey: hv.visor.conf.PK,
},
Health: &HealthInfo{},
}
}

addr := dmsg.Addr{PK: hv.c.PK, Port: hv.c.DmsgPort}
Expand All @@ -553,9 +557,14 @@ func (hv *Hypervisor) getVisorsExtraSummary() http.HandlerFunc {
summary, err := c.API.ExtraSummary()
if err != nil {
log.WithError(err).
Warn("Failed to obtain summary via RPC.")
summary = &ExtraSummary{}
summary.Summary.PubKey = pk
Warn("Failed to obtain summary via RPC.", pk)

summary = &ExtraSummary{
Summary: &Summary{
PubKey: pk,
},
Health: &HealthInfo{},
}
} else {
log.Debug("Obtained summary via RPC.")
}
Expand All @@ -570,6 +579,8 @@ func (hv *Hypervisor) getVisorsExtraSummary() http.HandlerFunc {
for i := 0; i < len(summaries); i++ {
if stat, ok := dmsgStats[summaries[i].Summary.PubKey.String()]; ok {
summaries[i].DmsgStats = &stat
} else {
summaries[i].DmsgStats = &dmsgtracker.DmsgClientSummary{}
}
}

Expand Down

0 comments on commit d3a7d7d

Please sign in to comment.