volume: skip the proxy lookup error when the inbound request is gone

This commit is contained in:
user.email committed 2026-10-26 02:55:56 -07:00
1 parent 21c4de24e9
commit 29d00ae794
2 files changed
+15

No files matched your search

@@ -67,6 +67,9 @@ func (vs *VolumeServer) proxyReqToTargetServer(w http.ResponseWriter, r *http.Re
} }
lookupResult, err := operation.LookupVolumeIdWithContext(r.Context(), vs.GetMaster, vs.grpcDialOption, volumeId.String()) lookupResult, err := operation.LookupVolumeIdWithContext(r.Context(), vs.GetMaster, vs.grpcDialOption, volumeId.String())
if err != nil && vs.ReadMode == "proxy" { if err != nil && vs.ReadMode == "proxy" {
if r.Context().Err() != nil {
return
}
glog.V(0).InfofCtx(r.Context(), "lookup error: %v %s", err, r.URL.Path) glog.V(0).InfofCtx(r.Context(), "lookup error: %v %s", err, r.URL.Path)
InternalError(w, r, nil) InternalError(w, r, nil)
return return
@@ -355,6 +355,18 @@ func TestProxyReqToTargetServerCancelsUpstreamBodyReadWithInboundRequest(t *test
} }
func TestProxyReqToTargetServerDistinguishesLookupFailureFromNoLocation(t *testing.T) { func TestProxyReqToTargetServerDistinguishesLookupFailureFromNoLocation(t *testing.T) {
t.Run("cancelled request skips the lookup error response", func(t *testing.T) {
const volumeID = "849300107"
vs := newProxyTestVolumeServer(t, volumeID, nil, nil)
ctx, cancel := context.WithCancel(context.Background())
cancel()
w := httptest.NewRecorder()
vs.proxyReqToTargetServer(w, httptest.NewRequest(http.MethodGet, "/"+volumeID+",abcdef", nil).WithContext(ctx))
if w.Code != http.StatusOK {
t.Errorf("status %d, want no response written for a cancelled request", w.Code)
}
})
t.Run("master lookup failure is internal error", func(t *testing.T) { t.Run("master lookup failure is internal error", func(t *testing.T) {
const volumeID = "849300103" const volumeID = "849300103"
vs := newProxyTestVolumeServer(t, volumeID, nil, status.Error(codes.Unavailable, "master unavailable")) vs := newProxyTestVolumeServer(t, volumeID, nil, status.Error(codes.Unavailable, "master unavailable"))