diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.go index 05c04833f8..69f9bcfa1c 100644 --- a/weed/operation/upload_content.go +++ b/weed/operation/upload_content.go @@ -291,11 +291,7 @@ func (uploader *Uploader) uploadWithRetryData(assignFn func() (fileId string, ho // The request addresses the filer, which authorizes it and mints the // volume credential itself. The AssignVolume token is not a filer // credential and gets the caller nowhere here. - if uploadOption.FilerJwt != nil { - uploadOption.Jwt = uploadOption.FilerJwt(true) - } else { - uploadOption.Jwt = security.EncodedJwt(util_http.JwtForFilerServer(true)) - } + uploadOption.Jwt = filerWriteJwt(uploadOption) } uploadResult, err = uploader.retriedUploadData(context.Background(), prepared, uploadOption) @@ -451,6 +447,12 @@ func (uploader *Uploader) retriedUploadData(ctx context.Context, prepared *prepa return nil, ctx.Err() case <-time.After(time.Millisecond * time.Duration(237*(i+1))): } + // A filer credential minted for an earlier attempt can expire while + // that attempt streams its body or a replica forward fails, so + // every same-FID replay through the filer gets a fresh one. + if util_http.IsProxyChunkUrl(option.UploadUrl) { + option.Jwt = filerWriteJwt(option) + } } uploadResult, err = uploader.doUploadData(ctx, prepared, option) if err == nil { @@ -479,17 +481,6 @@ func (uploader *Uploader) retriedUploadData(ctx context.Context, prepared *prepa if statusErr.StatusCode == http.StatusConflict || (statusErr.StatusCode == http.StatusUnauthorized && statusErr.expiredBeforeAppend && !util_http.IsProxyChunkUrl(option.UploadUrl)) { return nil, err } - if statusErr.StatusCode == http.StatusUnauthorized && statusErr.expiredBeforeAppend && util_http.IsProxyChunkUrl(option.UploadUrl) { - // The caller's filer credential was minted once and may have - // expired alongside the volume JWT (both default to 10s), so - // re-mint it before replaying the same FID; otherwise the filer - // rejects the retry with an unmarked 401 and recovery stops. - if option.FilerJwt != nil { - option.Jwt = option.FilerJwt(true) - } else { - option.Jwt = security.EncodedJwt(util_http.JwtForFilerServer(true)) - } - } if statusErr.stalled { option.stallWatchdogDisarmed = true } @@ -499,6 +490,14 @@ func (uploader *Uploader) retriedUploadData(ctx context.Context, prepared *prepa return } +// filerWriteJwt mints the filer write credential for a proxy chunk upload. +func filerWriteJwt(option *UploadOption) security.EncodedJwt { + if option.FilerJwt != nil { + return option.FilerJwt(true) + } + return security.EncodedJwt(util_http.JwtForFilerServer(true)) +} + // isGenericBinaryMimeType reports a content type that says nothing about the bytes, // such as the application/octet-stream most S3 clients send for unknown files. func isGenericBinaryMimeType(mimeType string) bool { diff --git a/weed/operation/volume_jwt_expiry_recovery_test.go b/weed/operation/volume_jwt_expiry_recovery_test.go index dbae41af6c..925799aa48 100644 --- a/weed/operation/volume_jwt_expiry_recovery_test.go +++ b/weed/operation/volume_jwt_expiry_recovery_test.go @@ -218,6 +218,41 @@ func TestUploadExpiryProxyRefreshesFilerJwtOnRetry(t *testing.T) { require.Equal(t, "Bearer fresh-filer-jwt-1", auths[1]) } +// A proxy retry after any failure, such as a 500 from a failed replica forward, +// must carry a freshly minted filer credential: the first one may have expired +// while the failed attempt streamed its body (#6220). +func TestUploadProxyRefreshesFilerJwtOnEveryRetry(t *testing.T) { + const fid = "3,01637037d6" + var mu sync.Mutex + var auths []string + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + _, _ = io.Copy(io.Discard, r.Body) + mu.Lock() + auths = append(auths, r.Header.Get("Authorization")) + n := len(auths) + mu.Unlock() + if n < 3 { + w.WriteHeader(http.StatusInternalServerError) + _, _ = io.WriteString(w, `{"error":"failed to write to replicas"}`) + return + } + _, _ = io.WriteString(w, `{"size":5}`) + })) + defer srv.Close() + proxyURL := srv.URL + "/?" + util_http.ProxyChunkIdParam + "=" + fid + minted := 0 + option := &UploadOption{UploadUrl: proxyURL, Jwt: "first-filer-jwt", FilerJwt: func(isWrite bool) security.EncodedJwt { + minted++ + return security.EncodedJwt(fmt.Sprintf("fresh-filer-jwt-%d", minted)) + }} + result, err := NewUploaderWithHttpClient(srv.Client()).UploadData(context.Background(), []byte("plain"), option) + require.NoError(t, err) + require.Equal(t, uint32(5), result.Size) + mu.Lock() + defer mu.Unlock() + require.Equal(t, []string{"Bearer first-filer-jwt", "Bearer fresh-filer-jwt-1", "Bearer fresh-filer-jwt-2"}, auths) +} + // A proxy upload driven through uploadWithRetryData must be terminal after its // bounded same-FID attempts: the outer loop must not reassign a FID the proxy // owns, nor count exhausted groups toward the expiry budget. diff --git a/weed/server/common_test.go b/weed/server/common_test.go index 89841c1fc0..719a452537 100644 --- a/weed/server/common_test.go +++ b/weed/server/common_test.go @@ -45,6 +45,19 @@ func TestParseURL(t *testing.T) { } } +func TestBaseFid(t *testing.T) { + for fid, want := range map[string]string{ + "06dfa8a684": "06dfa8a684", + "06dfa8a684_1": "06dfa8a684", + "06dfa8a684_12": "06dfa8a684", + "_1": "_1", + } { + if got := baseFid(fid); got != want { + t.Errorf("baseFid(%q) = %q, want %q", fid, got, want) + } + } +} + func TestWriteJsonNoJSONP(t *testing.T) { // callback= must be ignored; response is always application/json with nosniff. cases := []string{"", "myCb", ""} diff --git a/weed/server/volume_jwt_expiry_recovery_test.go b/weed/server/volume_jwt_expiry_recovery_test.go index 947c8f3474..a45502ffae 100644 --- a/weed/server/volume_jwt_expiry_recovery_test.go +++ b/weed/server/volume_jwt_expiry_recovery_test.go @@ -18,6 +18,7 @@ import ( jwt "github.com/golang-jwt/jwt/v5" "github.com/seaweedfs/seaweedfs/weed/operation" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" + "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" "github.com/seaweedfs/seaweedfs/weed/security" "github.com/seaweedfs/seaweedfs/weed/storage" "github.com/seaweedfs/seaweedfs/weed/storage/needle" @@ -466,3 +467,91 @@ func TestVolumeJwtExpiryFanoutRollback(t *testing.T) { require.Equal(t, plain, data) } } + +// Reading a slow body can outlast the incoming write JWT, so the replica +// forward carries a fresh one that the replica's own check accepts (#6220). +func TestReplicaForwardJwtOutlivesIncomingJwt(t *testing.T) { + key := security.SigningKey("replica-forward-key") + vs := &VolumeServer{guard: security.NewGuard(nil, string(key), 10, "", 0, "", "")} + incoming := httptest.NewRequest(http.MethodPost, "/1,01637037d6_1", nil) + incoming.Header.Set("Authorization", "Bearer "+expirySignedToken(t, key, "1,01637037d6", time.Now().Add(-time.Minute))) + require.False(t, vs.maybeCheckJwtAuthorization(incoming, "1", "01637037d6_1", true), "incoming token must be expired") + + forwarded := vs.replicaJwt(incoming, "1", "01637037d6_1", key)() + + replicaRequest := httptest.NewRequest(http.MethodPost, "/1,01637037d6_1?type=replicate", nil) + replicaRequest.Header.Set("Authorization", "Bearer "+string(forwarded)) + require.True(t, vs.maybeCheckJwtAuthorization(replicaRequest, "1", "01637037d6_1", true)) +} + +// Without a signing key the volume server mints nothing and forwards the +// incoming token unchanged. +func TestReplicaForwardJwtWithoutSigningKey(t *testing.T) { + vs := &VolumeServer{guard: security.NewGuard(nil, "", 0, "", 0, "", "")} + incoming := httptest.NewRequest(http.MethodPost, "/1,01637037d6", nil) + incoming.Header.Set("Authorization", "Bearer incoming-token") + require.Equal(t, security.EncodedJwt("incoming-token"), vs.replicaJwt(incoming, "1", "01637037d6", nil)()) +} + +type delayedBody struct { + io.Reader + until time.Time + once sync.Once +} + +func (b *delayedBody) Read(p []byte) (int, error) { + b.once.Do(func() { time.Sleep(time.Until(b.until)) }) + return b.Reader.Read(p) +} + +// PostHandler authorizes a write whose JWT then expires while the body streams +// in; the replica forward must carry a fresh, valid JWT for the base file ID. +func TestPostHandlerForwardsFreshJwtAfterSlowBody(t *testing.T) { + const vid = "849300102" + key := security.SigningKey("posthandler-replica-key") + replicaAuth := make(chan string, 1) + replica := newProxyTestHTTPServer(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + _, _ = io.Copy(io.Discard, r.Body) + replicaAuth <- r.Header.Get("Authorization") + w.WriteHeader(http.StatusCreated) + _, _ = io.WriteString(w, `{"size":1}`) + })) + vs := newProxyTestVolumeServer(t, vid, []*master_pb.Location{{Url: strings.TrimPrefix(replica.URL, "http://")}}, nil) + vs.guard = security.NewGuard(nil, string(key), 10, "", 0, "", "") + vs.fileSizeLimitBytes = 4 << 20 + + var body bytes.Buffer + mw := multipart.NewWriter(&body) + part, err := mw.CreateFormFile("file", "slow.bin") + require.NoError(t, err) + _, err = part.Write([]byte("slow chunk")) + require.NoError(t, err) + require.NoError(t, mw.Close()) + + // JWT expiry has one-second precision, so truncate to know the exact instant. + expires := time.Now().Add(2 * time.Second).Truncate(time.Second) + incoming := expirySignedToken(t, key, vid+",01637037d6", expires) + req := httptest.NewRequest(http.MethodPost, "/"+vid+",01637037d6_1", &delayedBody{Reader: &body, until: expires.Add(time.Second)}) + req.Header.Set("Content-Type", mw.FormDataContentType()) + req.Header.Set("Authorization", "Bearer "+incoming) + + rec := httptest.NewRecorder() + vs.PostHandler(rec, req) + require.Equal(t, http.StatusCreated, rec.Code, rec.Body.String()) + require.False(t, vs.maybeCheckJwtAuthorization(req, vid, "01637037d6_1", true), "incoming token must have expired while the body streamed in") + + var got string + select { + case got = <-replicaAuth: + default: + t.Fatal("replica never received the forward") + } + forwarded, ok := strings.CutPrefix(got, "Bearer ") + require.True(t, ok, got) + require.NotEqual(t, incoming, forwarded) + claims := &security.SeaweedFileIdClaims{} + parsed, err := security.DecodeJwt(key, security.EncodedJwt(forwarded), claims) + require.NoError(t, err) + require.True(t, parsed.Valid) + require.Equal(t, vid+",01637037d6", claims.Fid) +} diff --git a/weed/server/volume_server_handlers.go b/weed/server/volume_server_handlers.go index 39df9331ac..64dd99e268 100644 --- a/weed/server/volume_server_handlers.go +++ b/weed/server/volume_server_handlers.go @@ -402,6 +402,16 @@ func (vs *VolumeServer) maybeCheckJwtAuthorization(r *http.Request, vid, fid str return vs.checkJwtAuthorizationWithKey(r, vid, fid, signingKey, previousSigningKey) } +// baseFid strips the "_" suffix from the needle part of a file ID. +// Write JWTs are issued for the base file ID, so every check and mint of a +// volume write JWT compares against the stripped form. +func baseFid(fid string) string { + if sep := strings.LastIndex(fid, "_"); sep > 0 { + return fid[:sep] + } + return fid +} + // checkJwtAuthorizationWithKey authorizes against caller-snapshotted signing // keys, so a write handler can classify an expired-JWT refusal against the exact // keys it authorized under rather than re-reading ones that may have rotated @@ -429,10 +439,7 @@ func (vs *VolumeServer) checkJwtAuthorizationWithKey(r *http.Request, vid, fid s } if sc, ok := token.Claims.(*security.SeaweedFileIdClaims); ok { - if sepIndex := strings.LastIndex(fid, "_"); sepIndex > 0 { - fid = fid[:sepIndex] - } - expectedFid := vid + "," + fid + expectedFid := vid + "," + baseFid(fid) if sc.Fid != expectedFid { glog.V(1).Infof("jwt fid mismatch from %s: token has %q, request has %q", r.RemoteAddr, sc.Fid, expectedFid) return false diff --git a/weed/server/volume_server_handlers_write.go b/weed/server/volume_server_handlers_write.go index cfae5523e3..2e10ab5984 100644 --- a/weed/server/volume_server_handlers_write.go +++ b/weed/server/volume_server_handlers_write.go @@ -52,6 +52,28 @@ func (vs *VolumeServer) replicaContentCrc32c(n *needle.Needle, contentCrc32c str return needle.ContentCrc32c(n.Data) } +// replicaJwt returns the source of the write JWT a replica forward carries, +// called right before each replica request. Reading the body can outlast the +// incoming JWT, so with a signing key every forward gets a fresh JWT for the +// base file ID, which the request was already authorized for. Without a +// signing key the incoming JWT passes through unchanged. +func (vs *VolumeServer) replicaJwt(r *http.Request, vid, fid string, signingKey security.SigningKey) func() security.EncodedJwt { + if len(signingKey) == 0 { + incoming := security.GetJwt(r) + return func() security.EncodedJwt { return incoming } + } + fileId := vid + "," + baseFid(fid) + return func() security.EncodedJwt { + // Minting unconditionally, rather than forwarding a still-valid incoming + // JWT, keeps a forward from carrying one that expires in flight. The cost + // falls on key rotation: replicas verify a JWT signed with the key current + // on this server, so a new write signing key must be present as + // previous_key (verify-only) on every volume server before any volume + // server makes the new key current. + return security.GenJwtForVolumeServer(signingKey, vs.guard.ExpiresAfterSec(), fileId) + } +} + func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() if e := r.ParseForm(); e != nil { @@ -77,11 +99,7 @@ func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) { // and status precedence for other content types, which get no retry marker. contentType, _, typeErr := mime.ParseMediaType(r.Header.Get("Content-Type")) if typeErr == nil && contentType == "multipart/form-data" { - baseFid := fid - if sep := strings.LastIndex(baseFid, "_"); sep > 0 { - baseFid = baseFid[:sep] - } - if security.IsExpiredVolumeJwt(writeSigningKey, security.GetJwt(r), vid+","+baseFid, previousWriteSigningKey) { + if security.IsExpiredVolumeJwt(writeSigningKey, security.GetJwt(r), vid+","+baseFid(fid), previousWriteSigningKey) { w.Header().Set(util_http.WriteOutcomeHeader, util_http.WriteOutcomeExpiredJwtBeforeAppend) } } @@ -101,7 +119,7 @@ func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) { ret := operation.UploadResult{} // use context.WithoutCancel to avoid context cancellation when the client connection is closed - isUnchanged, writeError := topology.ReplicatedWrite(context.WithoutCancel(ctx), vs.GetMaster, vs.grpcDialOption, vs.store, volumeId, reqNeedle, r, vs.replicaContentMd5(reqNeedle, contentMd5), vs.replicaContentCrc32c(reqNeedle, r.Header.Get(needle.ContentCrc32cHeader))) + isUnchanged, writeError := topology.ReplicatedWrite(context.WithoutCancel(ctx), vs.GetMaster, vs.grpcDialOption, vs.store, volumeId, reqNeedle, r, vs.replicaJwt(r, vid, fid, writeSigningKey), vs.replicaContentMd5(reqNeedle, contentMd5), vs.replicaContentCrc32c(reqNeedle, r.Header.Get(needle.ContentCrc32cHeader))) if writeError != nil { stats.VolumeServerFileWriteFailures.Inc() status := http.StatusInternalServerError diff --git a/weed/topology/store_replicate.go b/weed/topology/store_replicate.go index e51b8b093d..41f55e47b8 100644 --- a/weed/topology/store_replicate.go +++ b/weed/topology/store_replicate.go @@ -30,14 +30,13 @@ var ErrorWriteRefused = errors.New("write refused before append") // ReplicatedWrite writes a needle to the local volume and fans it out to all // remote replica locations. When type=replicate is set, the request is itself // a forwarded replication and no further remote lookups are performed. +// replicaJwt supplies the write JWT of each replica forward and is called right +// before that forward, after the master lookup; nil sends no JWT. // contentMd5 and contentCrc32c are the checked client digests replicas verify // again; empty sends none. // Returns isUnchanged=true when the local write determined the needle content // was already present. -func ReplicatedWrite(ctx context.Context, masterFn operation.GetMasterFn, grpcDialOption grpc.DialOption, s *storage.Store, volumeId needle.VolumeId, n *needle.Needle, r *http.Request, contentMd5, contentCrc32c string) (isUnchanged bool, err error) { - - //check JWT - jwt := security.GetJwt(r) +func ReplicatedWrite(ctx context.Context, masterFn operation.GetMasterFn, grpcDialOption grpc.DialOption, s *storage.Store, volumeId needle.VolumeId, n *needle.Needle, r *http.Request, replicaJwt func() security.EncodedJwt, contentMd5, contentCrc32c string) (isUnchanged bool, err error) { // check whether this is a replicated write request var remoteLocations []operation.Location @@ -159,6 +158,11 @@ func ReplicatedWrite(ctx context.Context, masterFn operation.GetMasterFn, grpcDi bytesBuffer := buffer_pool.SyncPoolGetBuffer() defer buffer_pool.SyncPoolPutBuffer(bytesBuffer) + var jwt security.EncodedJwt + if replicaJwt != nil { + jwt = replicaJwt() + } + // volume server do not know about encryption uploadOption := &operation.UploadOption{ UploadUrl: u.String(), diff --git a/weed/topology/store_replicate_test.go b/weed/topology/store_replicate_test.go index 0f902410d8..44db3296ff 100644 --- a/weed/topology/store_replicate_test.go +++ b/weed/topology/store_replicate_test.go @@ -18,6 +18,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/operation" "github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" + "github.com/seaweedfs/seaweedfs/weed/security" "github.com/seaweedfs/seaweedfs/weed/stats" "github.com/seaweedfs/seaweedfs/weed/storage" "github.com/seaweedfs/seaweedfs/weed/storage/needle" @@ -215,7 +216,7 @@ func TestReplicatedWriteForwardsFsyncToReplicas(t *testing.T) { Data: []byte("test data"), Ttl: needle.EMPTY_TTL, } - if _, err := ReplicatedWrite(context.Background(), masterFn, dialOption, store, volumeId, n, r, "", ""); err != nil { + if _, err := ReplicatedWrite(context.Background(), masterFn, dialOption, store, volumeId, n, r, nil, "", ""); err != nil { t.Fatalf("ReplicatedWrite: %v", err) } @@ -235,6 +236,61 @@ func TestReplicatedWriteForwardsFsyncToReplicas(t *testing.T) { } } +// TestReplicatedWriteForwardsReplicaJwt verifies that each forward carries a +// JWT minted after the master lookup, right before the replica request, not +// the one on the incoming request. +func TestReplicatedWriteForwardsReplicaJwt(t *testing.T) { + replicaAuth := make(chan string, 1) + replica := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + replicaAuth <- r.Header.Get("Authorization") + w.WriteHeader(http.StatusCreated) + if _, err := w.Write([]byte(`{"size":1}`)); err != nil { + t.Errorf("replica write response: %v", err) + } + })) + defer replica.Close() + + master := &mockMasterServer{ + locations: []*master_pb.Location{{Url: strings.TrimPrefix(replica.URL, "http://")}}, + } + masterFn, dialOption := startMockMasterServer(t, master) + volumeId := needle.VolumeId(1) + operation.InvalidateVolumeIdLocationCache(volumeId.String()) + + r := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:8080/1,01637037d6", nil) + r.Header.Set("Authorization", "Bearer incoming-jwt") + if err := r.ParseForm(); err != nil { + t.Fatal(err) + } + var mints, lookupsAtMint int + replicaJwt := func() security.EncodedJwt { + master.mu.Lock() + lookupsAtMint = master.calls + master.mu.Unlock() + mints++ + return "replica-jwt" + } + n := &needle.Needle{Id: 1, Data: []byte("test data"), Ttl: needle.EMPTY_TTL} + if _, err := ReplicatedWrite(context.Background(), masterFn, dialOption, &storage.Store{}, volumeId, n, r, replicaJwt, "", ""); err != nil { + t.Fatalf("ReplicatedWrite: %v", err) + } + + select { + case got := <-replicaAuth: + if got != "Bearer replica-jwt" { + t.Errorf("replica Authorization = %q, want the replica JWT", got) + } + case <-time.After(5 * time.Second): + t.Fatal("replica never received the fan-out request") + } + if mints != 1 { + t.Errorf("replica JWT minted %d times, want once per replica", mints) + } + if lookupsAtMint == 0 { + t.Error("replica JWT minted before the master lookup") + } +} + // newReplicateTestStore builds a single-disk store in dir, draining the notify // channels so volume mounts never block on a heartbeat reader. func newReplicateTestStore(t *testing.T, dir string) *storage.Store { @@ -310,7 +366,7 @@ func TestReplicatedWriteOverlapsLocalAndReplicaWrites(t *testing.T) { done := make(chan error, 1) go func() { - _, err := ReplicatedWrite(context.Background(), masterFn, dialOption, store, volumeId, n, r, "", "") + _, err := ReplicatedWrite(context.Background(), masterFn, dialOption, store, volumeId, n, r, nil, "", "") done <- err }() @@ -399,7 +455,7 @@ func TestReplicatedWriteFailsWhenEitherLegFails(t *testing.T) { t.Fatal(err) } - _, err := ReplicatedWrite(context.Background(), masterFn, dialOption, store, tc.volumeId, n, r, "", "") + _, err := ReplicatedWrite(context.Background(), masterFn, dialOption, store, tc.volumeId, n, r, nil, "", "") if err == nil { t.Fatal("ReplicatedWrite succeeded despite a failed leg") } @@ -442,7 +498,7 @@ func TestReplicatedWriteRejectsWriteWithNoTarget(t *testing.T) { Data: []byte("test data"), Ttl: needle.EMPTY_TTL, } - _, err := ReplicatedWrite(context.Background(), masterFn, dialOption, store, volumeId, n, r, "", "") + _, err := ReplicatedWrite(context.Background(), masterFn, dialOption, store, volumeId, n, r, nil, "", "") if err == nil { t.Fatal("ReplicatedWrite acknowledged a write that no volume stored") } @@ -483,7 +539,7 @@ func TestReplicatedWriteFailsAtTheBoundWhenAReplicaNeverAnswers(t *testing.T) { timeouts := stats.VolumeServerReplicationFailures.WithLabelValues(stats.ReplicationOpWrite, stats.FailureTimeout) timeoutsBefore := testutil.ToFloat64(timeouts) start := time.Now() - _, err := ReplicatedWrite(context.Background(), masterFn, dialOption, &storage.Store{}, volumeId, n, r, "", "") + _, err := ReplicatedWrite(context.Background(), masterFn, dialOption, &storage.Store{}, volumeId, n, r, nil, "", "") elapsed := time.Since(start) select { case <-received: @@ -540,7 +596,7 @@ func TestReplicatedWriteGivesALargerBodyMoreTime(t *testing.T) { } n := &needle.Needle{Id: 1, Data: data, Ttl: needle.EMPTY_TTL} - if _, err := ReplicatedWrite(context.Background(), masterFn, dialOption, &storage.Store{}, volumeId, n, r, "", ""); err != nil { + if _, err := ReplicatedWrite(context.Background(), masterFn, dialOption, &storage.Store{}, volumeId, n, r, nil, "", ""); err != nil { t.Fatalf("a replica answering within the %v bound for a %d-byte body failed the write: %v", replicaRequestBound(len(data)), len(data), err) } select {