From da7d38f5fa85445ab6a7d747ad308f0e0577abee Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Wed, 11 Mar 2026 14:38:29 +0000 Subject: [PATCH] logtail: add Enable to allow re-enabling log uploads Disable() was a one-way latch that could never be reversed. Add Enable() so that when the control plane (e.g., Headscale) disabled logging via MapResponse.Debug.DisableLogTail, it can be re-enabled when switching to a different control server. This is a prerequisite for tracking DisableLogTail per-instance on LocalBackend rather than as irreversible global state. --- logtail/logtail.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/logtail/logtail.go b/logtail/logtail.go index ed3872e79..16b371865 100644 --- a/logtail/logtail.go +++ b/logtail/logtail.go @@ -589,11 +589,20 @@ func (lg *Logger) ExpVar() expvar.Var { // logtailDisabled is whether logtail uploads to logcatcher are disabled. var logtailDisabled atomic.Bool -// Disable disables logtail uploads for the lifetime of the process. +// Disable disables logtail uploads. If the disable was initiated by the +// control plane (not the user), it can be reversed by calling Enable. func Disable() { logtailDisabled.Store(true) } +// Enable re-enables logtail uploads that were previously disabled via +// Disable. This is used when the control plane (not the user) had +// disabled logging and the client is switching to a different control +// server. +func Enable() { + logtailDisabled.Store(false) +} + var debugWakesAndUploads = envknob.RegisterBool("TS_DEBUG_LOGTAIL_WAKES") // tryDrainWake tries to send to lg.drainWake, to cause an uploading wakeup.