mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-18 02:48:40 +00:00
health: fix nil DERPMap dereference panic
Looks like a DERPmap might not be available when we try to get the name associated with a region ID, and that was causing an intermittent panic in CI. Fixes #12534 Change-Id: I4ace53681bf004df46c728cff830b27339254243 Signed-off-by: Andrea Gottardo <andrea@gottardo.me>
This commit is contained in:
parent
25eeafde23
commit
d7619d273b
@ -685,6 +685,18 @@ func (t *Tracker) SetDERPMap(dm *tailcfg.DERPMap) {
|
|||||||
t.selfCheckLocked()
|
t.selfCheckLocked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// derpRegionNameLocked returns the name of the DERP region with the given ID
|
||||||
|
// or the empty string if unknown.
|
||||||
|
func (t *Tracker) derpRegionNameLocked(regID int) string {
|
||||||
|
if t.derpMap == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if r, ok := t.derpMap.Regions[regID]; ok {
|
||||||
|
return r.RegionName
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// state is an ipn.State.String() value: "Running", "Stopped", "NeedsLogin", etc.
|
// state is an ipn.State.String() value: "Running", "Stopped", "NeedsLogin", etc.
|
||||||
func (t *Tracker) SetIPNState(state string, wantRunning bool) {
|
func (t *Tracker) SetIPNState(state string, wantRunning bool) {
|
||||||
if t.nil() {
|
if t.nil() {
|
||||||
@ -928,13 +940,13 @@ func (t *Tracker) updateBuiltinWarnablesLocked() {
|
|||||||
} else if !t.derpRegionConnected[rid] {
|
} else if !t.derpRegionConnected[rid] {
|
||||||
t.setUnhealthyLocked(noDERPConnectionWarnable, Args{
|
t.setUnhealthyLocked(noDERPConnectionWarnable, Args{
|
||||||
ArgDERPRegionID: fmt.Sprint(rid),
|
ArgDERPRegionID: fmt.Sprint(rid),
|
||||||
ArgDERPRegionName: t.derpMap.Regions[rid].RegionName,
|
ArgDERPRegionName: t.derpRegionNameLocked(rid),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
} else if d := now.Sub(t.derpRegionLastFrame[rid]).Round(time.Second); d > tooIdle {
|
} else if d := now.Sub(t.derpRegionLastFrame[rid]).Round(time.Second); d > tooIdle {
|
||||||
t.setUnhealthyLocked(derpTimeoutWarnable, Args{
|
t.setUnhealthyLocked(derpTimeoutWarnable, Args{
|
||||||
ArgDERPRegionID: fmt.Sprint(rid),
|
ArgDERPRegionID: fmt.Sprint(rid),
|
||||||
ArgDERPRegionName: t.derpMap.Regions[rid].RegionName,
|
ArgDERPRegionName: t.derpRegionNameLocked(rid),
|
||||||
ArgDuration: d.String(),
|
ArgDuration: d.String(),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user