From 6d0d6e6cebb1beea47410990e0cb46bab2dbd811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claus=20Lensb=C3=B8l?= Date: Tue, 3 Mar 2026 10:55:28 -0500 Subject: [PATCH] DEBUG DO NOT MERGE: write netmap to disk --- control/controlclient/direct.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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 {