More verbose Taildrive logging, DO NOT MERGE TO main

Signed-off-by: Percy Wegmann <percy@tailscale.com>
This commit is contained in:
Percy Wegmann 2025-06-12 14:31:09 -05:00
parent db34cdcfe7
commit 224776df6a
No known key found for this signature in database
GPG Key ID: 29D8CDEB4C13D48B

View File

@ -1015,12 +1015,14 @@ func (rbw *requestBodyWrapper) Read(b []byte) (int, error) {
} }
func (h *peerAPIHandler) handleServeDrive(w http.ResponseWriter, r *http.Request) { func (h *peerAPIHandler) handleServeDrive(w http.ResponseWriter, r *http.Request) {
h.logf("taildrive: handleServeDrive: received peerapi request %s: %q", r.Method, r.URL.Path)
if !h.ps.b.DriveSharingEnabled() { if !h.ps.b.DriveSharingEnabled() {
h.logf("taildrive: not enabled") h.logf("taildrive: not enabled")
http.Error(w, "taildrive not enabled", http.StatusNotFound) http.Error(w, "taildrive not enabled", http.StatusNotFound)
return return
} }
h.logf("taildrive: handleServeDrive: checking peer caps")
capsMap := h.PeerCaps() capsMap := h.PeerCaps()
driveCaps, ok := capsMap[tailcfg.PeerCapabilityTaildrive] driveCaps, ok := capsMap[tailcfg.PeerCapabilityTaildrive]
if !ok { if !ok {
@ -1034,6 +1036,7 @@ func (h *peerAPIHandler) handleServeDrive(w http.ResponseWriter, r *http.Request
rawPerms = append(rawPerms, []byte(cap)) rawPerms = append(rawPerms, []byte(cap))
} }
h.logf("taildrive: handleServeDrive: parsing permissions")
p, err := drive.ParsePermissions(rawPerms) p, err := drive.ParsePermissions(rawPerms)
if err != nil { if err != nil {
h.logf("taildrive: error parsing permissions: %v", err) h.logf("taildrive: error parsing permissions: %v", err)
@ -1041,6 +1044,7 @@ func (h *peerAPIHandler) handleServeDrive(w http.ResponseWriter, r *http.Request
return return
} }
h.logf("taildrive: handleServeDrive: getting DriveForRemote")
fs, ok := h.ps.b.sys.DriveForRemote.GetOK() fs, ok := h.ps.b.sys.DriveForRemote.GetOK()
if !ok { if !ok {
h.logf("taildrive: not supported on platform") h.logf("taildrive: not supported on platform")
@ -1055,6 +1059,10 @@ func (h *peerAPIHandler) handleServeDrive(w http.ResponseWriter, r *http.Request
} }
r.Body = bw r.Body = bw
defer func() {
h.logf("taildrive: after ServeHTTPWithPerms to %q, status was %d", r.URL.Path, wr.statusCode)
}()
if r.Method == httpm.PUT || r.Method == httpm.GET { if r.Method == httpm.PUT || r.Method == httpm.GET {
defer func() { defer func() {
switch wr.statusCode { switch wr.statusCode {
@ -1072,6 +1080,7 @@ func (h *peerAPIHandler) handleServeDrive(w http.ResponseWriter, r *http.Request
} }
r.URL.Path = strings.TrimPrefix(r.URL.Path, taildrivePrefix) r.URL.Path = strings.TrimPrefix(r.URL.Path, taildrivePrefix)
h.logf("taildrive: handleServeDrive: calling ServeHTTPWithPerms at: %s", r.URL.Path)
fs.ServeHTTPWithPerms(p, wr, r) fs.ServeHTTPWithPerms(p, wr, r)
} }