diff options
| author | Claus Lensbøl <claus@tailscale.com> | 2026-03-03 10:55:28 -0500 |
|---|---|---|
| committer | Claus Lensbøl <claus@tailscale.com> | 2026-03-03 10:55:28 -0500 |
| commit | 6d0d6e6cebb1beea47410990e0cb46bab2dbd811 (patch) | |
| tree | b08015ed19b8dc171e24bcec549ce9877ad9b675 | |
| parent | 2d21dd46cd9fbb2fcf020d6b5e764f3d4aaf2d2c (diff) | |
| download | tailscale-cmol/debug-write-netmap-to-disk.tar.xz tailscale-cmol/debug-write-netmap-to-disk.zip | |
DEBUG DO NOT MERGE: write netmap to diskcmol/debug-write-netmap-to-disk
| -rw-r--r-- | control/controlclient/direct.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/control/controlclient/direct.go b/control/controlclient/direct.go index 6f3393b18..6fb3fb048 100644 --- a/control/controlclient/direct.go +++ b/control/controlclient/direct.go @@ -1111,6 +1111,19 @@ func (c *Direct) sendMapRequest(ctx context.Context, isStreaming bool, nu Netmap // KeepAlive set. var gotNonKeepAliveMessage bool + // Dump netmap to disk if we are in debug mode + var netmapDebug *os.File + if path := envknob.String("DEBUG_NETMAP_TO_DISK"); path != "" { + c.logf("Logger set to %s", path) + netmapDebug, err = os.Create(path) + if err != nil { + return err + } + defer netmapDebug.Close() + } else { + c.logf("Logger not set to %s", path) + } + // If allowStream, then the server will use an HTTP long poll to // return incremental results. There is always one response right // away, followed by a delay, and eventually others. @@ -1142,6 +1155,19 @@ func (c *Direct) sendMapRequest(ctx context.Context, isStreaming bool, nu Netmap } watchdogTimer.Stop() + if netmapDebug != nil { + out, err := json.MarshalIndent(resp, "", " ") + if err != nil { + return fmt.Errorf("encoding response: %w", err) + } + out = append(out, '\n') + if _, err := netmapDebug.Write(out); err != nil { + vlogf("failed writing netmap debug file, closing file and stopping debug: %v", err) + netmapDebug.Close() + netmapDebug = nil + } + } + metricMapResponseMessages.Add(1) if isStreaming { |
