Skip to content

Commit 239ad57

Browse files
committed
tailcfg: move LogHeapPprof from Debug to c2n [capver 69]
And delete Debug.GoroutineDumpURL, which was already in c2n. Updates tailscale#8923 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
1 parent 24509f8 commit 239ad57

File tree

10 files changed

+32
-119
lines changed

10 files changed

+32
-119
lines changed

cmd/tailscaled/depaware.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
242242
tailscale.com/ipn/store/mem from tailscale.com/ipn/store+
243243
L tailscale.com/kube from tailscale.com/ipn/store/kubestore
244244
tailscale.com/log/filelogger from tailscale.com/logpolicy
245-
tailscale.com/log/logheap from tailscale.com/control/controlclient
246245
tailscale.com/log/sockstatlog from tailscale.com/ipn/ipnlocal
247246
tailscale.com/logpolicy from tailscale.com/cmd/tailscaled+
248247
tailscale.com/logtail from tailscale.com/control/controlclient+
@@ -325,7 +324,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
325324
💣 tailscale.com/util/deephash from tailscale.com/ipn/ipnlocal+
326325
L 💣 tailscale.com/util/dirwalk from tailscale.com/metrics+
327326
tailscale.com/util/dnsname from tailscale.com/hostinfo+
328-
tailscale.com/util/goroutines from tailscale.com/control/controlclient+
327+
tailscale.com/util/goroutines from tailscale.com/ipn/ipnlocal
329328
tailscale.com/util/groupmember from tailscale.com/ipn/ipnauth
330329
💣 tailscale.com/util/hashx from tailscale.com/util/deephash
331330
tailscale.com/util/httpm from tailscale.com/client/tailscale+
@@ -495,7 +494,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
495494
regexp from github.com/coreos/go-iptables/iptables+
496495
regexp/syntax from regexp
497496
runtime/debug from github.com/klauspost/compress/zstd+
498-
runtime/pprof from tailscale.com/log/logheap+
497+
runtime/pprof from net/http/pprof+
499498
runtime/trace from net/http/pprof
500499
slices from tailscale.com/wgengine/magicsock
501500
sort from compress/flate+

control/controlclient/debug.go

Lines changed: 0 additions & 40 deletions
This file was deleted.

control/controlclient/direct.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
"tailscale.com/health"
3333
"tailscale.com/hostinfo"
3434
"tailscale.com/ipn/ipnstate"
35-
"tailscale.com/log/logheap"
3635
"tailscale.com/logtail"
3736
"tailscale.com/net/dnscache"
3837
"tailscale.com/net/dnsfallback"
@@ -1096,12 +1095,6 @@ func (c *Direct) sendMapRequest(ctx context.Context, isStreaming bool, nu Netmap
10961095
logtail.Disable()
10971096
envknob.SetNoLogsNoSupport()
10981097
}
1099-
if resp.Debug.LogHeapPprof {
1100-
go logheap.LogHeap(resp.Debug.LogHeapURL)
1101-
}
1102-
if resp.Debug.GoroutineDumpURL != "" {
1103-
go dumpGoroutinesToURL(c.httpc, resp.Debug.GoroutineDumpURL)
1104-
}
11051098
if sleep := time.Duration(resp.Debug.SleepSeconds * float64(time.Second)); sleep > 0 {
11061099
if err := sleepAsRequested(ctx, c.logf, timeoutReset, sleep, c.clock); err != nil {
11071100
return err

ipn/ipnlocal/c2n.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
"tailscale.com/version/distro"
2626
)
2727

28+
var c2nLogHeap func(http.ResponseWriter, *http.Request) // non-nil on most platforms (c2n_pprof.go)
29+
2830
func (b *LocalBackend) handleC2N(w http.ResponseWriter, r *http.Request) {
2931
writeJSON := func(v any) {
3032
w.Header().Set("Content-Type", "application/json")
@@ -70,6 +72,13 @@ func (b *LocalBackend) handleC2N(w http.ResponseWriter, r *http.Request) {
7072
res.Error = err.Error()
7173
}
7274
writeJSON(res)
75+
case "/debug/logheap":
76+
if c2nLogHeap != nil {
77+
c2nLogHeap(w, r)
78+
} else {
79+
http.Error(w, "not implemented", http.StatusNotImplemented)
80+
return
81+
}
7382
case "/ssh/usernames":
7483
var req tailcfg.C2NSSHUsernamesRequest
7584
if r.Method == "POST" {

ipn/ipnlocal/c2n_pprof.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) Tailscale Inc & AUTHORS
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
4+
//go:build !js && !wasm
5+
6+
package ipnlocal
7+
8+
import (
9+
"net/http"
10+
"runtime/pprof"
11+
)
12+
13+
func init() {
14+
c2nLogHeap = func(w http.ResponseWriter, r *http.Request) {
15+
pprof.WriteHeapProfile(w)
16+
}
17+
}

log/logheap/logheap.go

Lines changed: 0 additions & 45 deletions
This file was deleted.

log/logheap/logheap_js.go

Lines changed: 0 additions & 7 deletions
This file was deleted.

tailcfg/tailcfg.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ type CapabilityVersion int
106106
// - 66: 2023-07-23: UserProfile.Groups added (available via WhoIs)
107107
// - 67: 2023-07-25: Client understands PeerCapMap
108108
// - 68: 2023-08-09: Client has dedicated updateRoutine; MapRequest.Stream true means ignore Hostinfo+Endpoints
109-
const CurrentCapabilityVersion CapabilityVersion = 68
109+
// - 69: 2023-08-16: removed Debug.LogHeap* + GoroutineDumpURL; added c2n /debug/logheap
110+
const CurrentCapabilityVersion CapabilityVersion = 69
110111

111112
type StableID string
112113

@@ -1749,15 +1750,6 @@ type ControlIPCandidate struct {
17491750
//
17501751
// TODO(bradfitz): start migrating the imperative ones to c2n requests.
17511752
type Debug struct {
1752-
// LogHeapPprof controls whether the client should log
1753-
// its heap pprof data. Each true value sent from the server
1754-
// means that client should do one more log.
1755-
LogHeapPprof bool `json:",omitempty"`
1756-
1757-
// LogHeapURL is the URL to POST its heap pprof to.
1758-
// Empty means to not log.
1759-
LogHeapURL string `json:",omitempty"`
1760-
17611753
// ForceBackgroundSTUN controls whether magicsock should
17621754
// always do its background STUN queries (see magicsock's
17631755
// periodicReSTUN), regardless of inactivity.
@@ -1787,10 +1779,6 @@ type Debug struct {
17871779
// disabled if WPAD is present on the network.
17881780
DisableSubnetsIfPAC opt.Bool `json:",omitempty"`
17891781

1790-
// GoroutineDumpURL, if non-empty, requests that the client do
1791-
// a one-time dump of its active goroutines to the given URL.
1792-
GoroutineDumpURL string `json:",omitempty"`
1793-
17941782
// SleepSeconds requests that the client sleep for the
17951783
// provided number of seconds.
17961784
// The client can (and should) limit the value (such as 5

tstest/iosdeps/iosdeps.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import (
4242
_ "tailscale.com/ipn"
4343
_ "tailscale.com/ipn/ipnlocal"
4444
_ "tailscale.com/ipn/localapi"
45-
_ "tailscale.com/log/logheap"
4645
_ "tailscale.com/logtail"
4746
_ "tailscale.com/logtail/filch"
4847
_ "tailscale.com/net/dns"

types/netmap/netmap_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ func TestNetworkMapConcise(t *testing.T) {
7171
name: "debug_values",
7272
nm: &NetworkMap{
7373
NodeKey: testNodeKey(1),
74-
Debug: &tailcfg.Debug{LogHeapPprof: true},
74+
Debug: &tailcfg.Debug{SetForceBackgroundSTUN: "true"},
7575
},
76-
want: "netmap: self: [AQEBA] auth=machine-unknown u=? debug={\"LogHeapPprof\":true} []\n",
76+
want: "netmap: self: [AQEBA] auth=machine-unknown u=? debug={\"SetForceBackgroundSTUN\":true} []\n",
7777
},
7878
} {
7979
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)