Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve nil pointer derefrence #750

Merged
merged 3 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9 h1:sYNJzB4J8toYPQTM6pAkcm
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
Expand Down
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