mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-18 20:51:45 +00:00
tailcfg, logtail: provide Debug bit to disable logtail
For people running self-hosted control planes who want a global opt-out knob instead of running their own logcatcher. Change-Id: I7f996c09f45850ff77b58bfd5a535e197971725a Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
ecea6cb994
commit
9f1dd716e8
@ -34,6 +34,7 @@ import (
|
|||||||
"tailscale.com/hostinfo"
|
"tailscale.com/hostinfo"
|
||||||
"tailscale.com/ipn/ipnstate"
|
"tailscale.com/ipn/ipnstate"
|
||||||
"tailscale.com/log/logheap"
|
"tailscale.com/log/logheap"
|
||||||
|
"tailscale.com/logtail"
|
||||||
"tailscale.com/net/dnscache"
|
"tailscale.com/net/dnscache"
|
||||||
"tailscale.com/net/dnsfallback"
|
"tailscale.com/net/dnsfallback"
|
||||||
"tailscale.com/net/interfaces"
|
"tailscale.com/net/interfaces"
|
||||||
@ -895,6 +896,9 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netm
|
|||||||
c.logf("exiting process with status %v per controlplane", *code)
|
c.logf("exiting process with status %v per controlplane", *code)
|
||||||
os.Exit(*code)
|
os.Exit(*code)
|
||||||
}
|
}
|
||||||
|
if resp.Debug.DisableLogTail {
|
||||||
|
logtail.Disable()
|
||||||
|
}
|
||||||
if resp.Debug.LogHeapPprof {
|
if resp.Debug.LogHeapPprof {
|
||||||
go logheap.LogHeap(resp.Debug.LogHeapURL)
|
go logheap.LogHeap(resp.Debug.LogHeapURL)
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
|
|
||||||
"tailscale.com/logtail/backoff"
|
"tailscale.com/logtail/backoff"
|
||||||
"tailscale.com/net/interfaces"
|
"tailscale.com/net/interfaces"
|
||||||
|
"tailscale.com/syncs"
|
||||||
tslogger "tailscale.com/types/logger"
|
tslogger "tailscale.com/types/logger"
|
||||||
"tailscale.com/wgengine/monitor"
|
"tailscale.com/wgengine/monitor"
|
||||||
)
|
)
|
||||||
@ -412,7 +413,18 @@ func (l *Logger) Flush() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// logtailDisabled is whether logtail uploads to logcatcher are disabled.
|
||||||
|
var logtailDisabled syncs.AtomicBool
|
||||||
|
|
||||||
|
// Disable disables logtail uploads for the lifetime of the process.
|
||||||
|
func Disable() {
|
||||||
|
logtailDisabled.Set(true)
|
||||||
|
}
|
||||||
|
|
||||||
func (l *Logger) send(jsonBlob []byte) (int, error) {
|
func (l *Logger) send(jsonBlob []byte) (int, error) {
|
||||||
|
if logtailDisabled.Get() {
|
||||||
|
return len(jsonBlob), nil
|
||||||
|
}
|
||||||
n, err := l.buffer.Write(jsonBlob)
|
n, err := l.buffer.Write(jsonBlob)
|
||||||
if l.drainLogs == nil {
|
if l.drainLogs == nil {
|
||||||
select {
|
select {
|
||||||
|
@ -1458,6 +1458,10 @@ type Debug struct {
|
|||||||
// new attempts at UPnP connections.
|
// new attempts at UPnP connections.
|
||||||
DisableUPnP opt.Bool `json:",omitempty"`
|
DisableUPnP opt.Bool `json:",omitempty"`
|
||||||
|
|
||||||
|
// DisableLogTail disables the logtail package. Once disabled it can't be
|
||||||
|
// re-enabled for the lifetime of the process.
|
||||||
|
DisableLogTail bool `json:",omitempty"`
|
||||||
|
|
||||||
// Exit optionally specifies that the client should os.Exit
|
// Exit optionally specifies that the client should os.Exit
|
||||||
// with this code.
|
// with this code.
|
||||||
Exit *int `json:",omitempty"`
|
Exit *int `json:",omitempty"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user