mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
wgengine/magicsock: deflake some tests with an ugly hack
Starting withfe68841dc7
, some e2e tests got flaky. Rather than debug them (they're gnarly), just revert to the old behavior as far as those tests are concerned. The tests were somehow using magicsock without a private key and expecting it to do ... something. My goal withfe68841dc7
was to stop log spam and unnecessary work I saw on the iOS app when when stopping the app. Instead, only stop doing that work on any transition from once-had-a-private-key to no-longer-have-a-private-key. That fixes what I wanted to fix while still making the mysterious e2e tests happy.
This commit is contained in:
parent
ec4feaf31c
commit
58b721f374
@ -175,6 +175,7 @@ type Conn struct {
|
||||
derpMap *tailcfg.DERPMap // nil (or zero regions/nodes) means DERP is disabled
|
||||
netMap *controlclient.NetworkMap
|
||||
privateKey key.Private
|
||||
everHadKey bool // whether we ever had a non-zero private key
|
||||
myDerp int // nearest DERP region ID; 0 means none/unknown
|
||||
derpStarted chan struct{} // closed on first connection to DERP; for tests & cleaner Close
|
||||
activeDerp map[int]activeDerp // DERP regionID -> connection to a node in that region
|
||||
@ -1815,6 +1816,7 @@ func (c *Conn) SetPrivateKey(privateKey wgcfg.PrivateKey) error {
|
||||
c.privateKey = newKey
|
||||
|
||||
if oldKey.IsZero() {
|
||||
c.everHadKey = true
|
||||
c.logf("magicsock: SetPrivateKey called (init)")
|
||||
go c.ReSTUN("set-private-key")
|
||||
} else if newKey.IsZero() {
|
||||
@ -2184,8 +2186,19 @@ func (c *Conn) ReSTUN(why string) {
|
||||
// raced with a shutdown.
|
||||
return
|
||||
}
|
||||
if c.privateKey.IsZero() {
|
||||
c.logf("magicsock: ReSTUN(%q) ignored; no private key", why)
|
||||
|
||||
// If the user stopped the app, stop doing work. (When the
|
||||
// user stops Tailscale via the GUI apps, ipn/local.go
|
||||
// reconfigures the engine with a zero private key.)
|
||||
//
|
||||
// This used to just check c.privateKey.IsZero, but that broke
|
||||
// some end-to-end tests tests that didn't ever set a private
|
||||
// key somehow. So for now, only stop doing work if we ever
|
||||
// had a key, which helps real users, but appeases tests for
|
||||
// now. TODO: rewrite those tests to be less brittle or more
|
||||
// realistic.
|
||||
if c.privateKey.IsZero() && c.everHadKey {
|
||||
c.logf("magicsock: ReSTUN(%q) ignored; stopped, no private key", why)
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user