Repository navigation
Conversation
b794cb4 to
1be4ed7
Compare
If a derper is loaded for any reason, it can add spurious additional runtime to stun responses producing latency estimation errors in the clients. For some deployment scenarios simply running the stun responder as a subprocess is a simple solution to substantially reduce this problem. Fixes #8434 Closes #8435 Signed-off-by: James Tucker <[email protected]>
1be4ed7 to
c6aeb67
Compare
We going to |
| log.Fatalf("stun: failed to start subprocess: %v", err) | ||
| } | ||
| readSTUNStats(ctx, stdout) | ||
| cmd.Process.Kill() |
There was a problem hiding this comment.
Worth noting that this sends a SIGKILL; maybe worth allowing things to gracefully shut down with a SIGTERM and then waiting and killing with SIGKILL?
cmd.Process.Signal(syscall.SIGTERM)
killed := make(chan struct{})
go func() {
select {
case <-killed:
case <-time.After(2*time.Second):
cmd.Process.Kill()
}
}()
cmd.Process.Wait()
close(killed)There was a problem hiding this comment.
This kill is probably superfluous anyway - if the read has stopped it's more than likely the pipe is closed, which most commonly means the process is gone. I just didn't want to have wait hang indefinitely on some edge case.
| log.Fatalf("failed to open STUN listener: %v", err) | ||
| } | ||
| log.Printf("running STUN server on %v", pc.LocalAddr()) | ||
| // close the listener on shutdown in order to rbeak out of the read loop |
There was a problem hiding this comment.
| // close the listener on shutdown in order to rbeak out of the read loop | |
| // close the listener on shutdown in order to break out of the read loop |
| if *stunOnly { | ||
| log.SetPrefix(fmt.Sprintf("stun(%d) ", os.Getpid())) | ||
| log.Printf("Starting in stun-only mode.") | ||
| go printSTUNStats(ctx, os.Stdout, time.Second*10) |
There was a problem hiding this comment.
May I suggest to consider having the subprocess expose its own debug http server? This will improve our ability to introspect it via pprof, and will allow adding it separately to Prometheus. This will give us a bunch of built-in Go runtime metrics for free (gc metrics, goroutine count, memstats, cpu time) and help avoid bespoke metric serializaton machinery.
There was a problem hiding this comment.
That change ends up being a lot bigger once it is rationalized, because the basic take on process supervision and argument delegation taken here no longer makes so much sense. At that point we may as well split out a stund entirely, and manage it separately - but doing so then also requires new deployment machinery as well. I understand the motivations you're describing, it just may block us addressing this issue again, which has already been stuck for months due to time-cost trade-offs - e.g. see the PR that this supersedes.
There was a problem hiding this comment.
I guess it's fixit-friday so I did it anyway: #10757
I wasn't planning to, the kernel scheduler should perform fine here. |
Add a standalone server for STUN that can be hosted independently of the derper, and factor that back into the derper. Fixes #8434 Closes #8435 Closes #10745 Signed-off-by: James Tucker <[email protected]>
|
This patch is superseded by #10757 which splits this out into an entirely standalone service. |
Add a standalone server for STUN that can be hosted independently of the derper, and factor that back into the derper. Fixes #8434 Closes #8435 Closes #10745 Signed-off-by: James Tucker <[email protected]>
Add a standalone server for STUN that can be hosted independently of the derper, and factor that back into the derper. Fixes #8434 Closes #8435 Closes #10745 Signed-off-by: James Tucker <[email protected]>
Add a standalone server for STUN that can be hosted independently of the derper, and factor that back into the derper. Fixes #8434 Closes #8435 Closes #10745 Signed-off-by: James Tucker <[email protected]>
Add a standalone server for STUN that can be hosted independently of the derper, and factor that back into the derper. Fixes #8434 Closes #8435 Closes #10745 Signed-off-by: James Tucker <[email protected]>
Add a standalone server for STUN that can be hosted independently of the derper, and factor that back into the derper. Fixes #8434 Closes #8435 Closes #10745 Signed-off-by: James Tucker <[email protected]>
Add a standalone server for STUN that can be hosted independently of the derper, and factor that back into the derper. Fixes #8434 Closes #8435 Closes #10745 Signed-off-by: James Tucker <[email protected]>
Add a standalone server for STUN that can be hosted independently of the derper, and factor that back into the derper. Fixes #8434 Closes #8435 Closes #10745 Signed-off-by: James Tucker <[email protected]>
Add a standalone server for STUN that can be hosted independently of the derper, and factor that back into the derper. Fixes #8434 Closes #8435 Closes #10745 Signed-off-by: James Tucker <[email protected]>
Add a standalone server for STUN that can be hosted independently of the derper, and factor that back into the derper. Fixes #8434 Closes #8435 Closes #10745 Signed-off-by: James Tucker <[email protected]>
Add a standalone server for STUN that can be hosted independently of the derper, and factor that back into the derper. Fixes tailscale#8434 Closes tailscale#8435 Closes tailscale#10745 Signed-off-by: James Tucker <[email protected]>
Add a standalone server for STUN that can be hosted independently of the derper, and factor that back into the derper. Fixes tailscale#8434 Closes tailscale#8435 Closes tailscale#10745 Signed-off-by: James Tucker <[email protected]>
If a derper is loaded for any reason, it can add spurious additional runtime to stun responses producing latency estimation errors in the clients. For some deployment scenarios simply running the stun responder as a subprocess is a simple solution to substantially reduce this problem.