mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 11:05:45 +00:00
wgengine/monitor: log warning if state changes but stringification doesn't
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
b14ea68754
commit
602f92ec30
@ -8,6 +8,7 @@
|
||||
package monitor
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"sync"
|
||||
"time"
|
||||
@ -208,9 +209,15 @@ func (m *Mon) debounce() {
|
||||
m.logf("interfaces.State: %v", err)
|
||||
} else {
|
||||
m.mu.Lock()
|
||||
changed := !curState.Equal(m.ifState)
|
||||
oldState := m.ifState
|
||||
changed := !curState.Equal(oldState)
|
||||
if changed {
|
||||
m.ifState = curState
|
||||
|
||||
if s1, s2 := oldState.String(), curState.String(); s1 == s2 {
|
||||
m.logf("[unexpected] network state changed, but stringification didn't: %v\nold: %s\nnew: %s\n", s1,
|
||||
jsonSummary(oldState), jsonSummary(curState))
|
||||
}
|
||||
}
|
||||
for _, cb := range m.cbs {
|
||||
go cb(changed, m.ifState)
|
||||
@ -225,3 +232,11 @@ func (m *Mon) debounce() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func jsonSummary(x interface{}) interface{} {
|
||||
j, err := json.Marshal(x)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return j
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user