mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
413fdf196883eda31f16d517bc66cd2d5537e732
2284
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f2e9e49842 |
master: stop volume growth from leaking volumes into a just-deleted collection (#13035)
* topology: stop a grow once a delete fences its collection A grow request creates its volumes one after another and resolves the collection by name for each, so once the collection was deleted the rest of the request recreated it. The request now keeps the collection it started in and holds a per-collection fence shared while it creates each volume. A delete can raise the fence exclusively, which waits out the volume in flight, and the request stops at its next volume. A collection dropped only because its last layout emptied is followed to the one published under its name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * master: fence volume growth before deleting a collection The delete listed the collection's servers, fanned out DeleteCollection, and only then dropped the collection from the topology. A grow still running created its next volumes during or after the fan-out, on servers that had already been cleaned or were not in the list, and those volumes registered a new layout for the deleted collection that nothing removed. A bucket deleted right after its first write leaked most of its initial volumes this way. The delete now raises the collection's growth fence first, so the volume in flight registers and is deleted with the rest, and the grow stops. A failed fan-out lifts the fence, since the collection stays in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * topology: refuse assigns from a collection being deleted The delete waits for the volume a grow is creating before it lists the collection's servers, and the collection's writable volumes stayed assignable meanwhile, so a write could land in a volume about to be deleted. The delete now raises the fence before it waits, and assigns check it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * topology: list only collections that hold a volume layout A grow request publishes its collection before its first volume registers, so one that created nothing left a collection with no volume in the list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * topology: queue no grow for a collection being deleted PickForWrite returned the layout's shouldGrow before it checked the fence, so an assign on an empty layout of a collection being deleted still queued a grow. That grow could run after the delete finished and recreate the collection. Check the fence right after the pick, before any early return. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * topology: keep an emptied collection published while growth holds it DeleteLayout unpublished a collection as soon as its last layout emptied, even while a grow held it or a delete had fenced it. The volume in flight then registered by name into a new collection that the delete never listed servers for, and the delete's final DeleteCollection dropped it from the topology while it stayed on disk. Unpublish an empty collection only when no grow or delete holds it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * topology: fence the collection still published under the name An emptied-layout cleanup that passed its fence check could unpublish the collection while the delete waited to fence it. The delete then fenced and listed an orphaned object, while growth published a new collection under the name that no fence held. Topology.FenceGrowth re-checks publication once the fence is up and moves to the collection published since. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * topology: run one delete of a collection at a time Two deletes of one collection both fenced it and fanned out by name. Once the first removed it, a write could recreate the collection, and the second delete removed the new one's volumes and topology entry. FenceGrowth now waits for a delete already running on the collection and finds nothing once that delete removed it; a delete that failed hands the collection to the one waiting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * topology: stop a delete another delete beat to the collection A delete that fenced the collection but had not yet checked that it was still published retried when it was not, for the collection an emptied layout drops. A delete that removed it in between also left it unpublished, so the retry fenced and returned the collection a write had recreated under the name since. finish(true) now marks the collection deleted before it unpublishes it, and the retry stops at that mark. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * master: keep the name fenced through the EC pass of a delete The normal pass unpublished the collection and let growth back in before the EC pass ran. The EC pass deletes by name on every server holding the collection's shards, and DeleteCollection on a server also drops its normal volumes, so a write recreating the bucket in between could land a volume that the EC pass then deleted. A second delete of the name, finding no collection, also ran its own EC pass by name. deleteCollection now fences the name once, before either pass, and lifts or ends the fence after both. finish(true) unpublishes the collection then. A name with EC shards only gets an empty collection to fence, so an assign under it is refused too, and a delete that finds nothing skips both passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * topology: wait for the second delete's lock instead of sleeping The overlapping-delete tests slept before acting on the first delete. A second delete scheduled late started after the collection was replaced, or after the first delete was already over, so the tests could fail or pass without the overlap they check. They now wait until the second delete is blocked on the delete lock, read from the goroutine stacks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * topology: empty the layout through UnRegisterVolumeLayout in the test The test called DeleteLayout, whose signature differs in builds that key layouts by more than replication, TTL and disk type. UnRegisterVolumeLayout reaches the same cleanup from a VolumeInfo and has one signature everywhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
1f8ad7016f |
filer: compare garbage chunks by needle identity (#12992)
* Normalize chunk identities during garbage comparison * Keep replication chunk respellings observable * filer: skip the needle identity index when nothing is subtracted Every compaction subtracted its retained chunks from an often empty covered list, parsing and re-formatting each retained file ID first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: skip the identity subtraction at the compaction call site Returning early from doMinusChunks on an empty minuend stopped MinusChunks from calling GetFileIdString on the new entry's chunks. After CreateEntry of a new file, the caller's chunks then kept the FileId that BeforeEntrySerialization cleared, so tus completion built its still-referenced set from empty IDs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: match needle spellings through DoMinusChunks instead of a new function Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: DoMinusChunks always matches chunks by needle Drop the byNeedle parameter so DoMinusChunks keeps its two-argument signature and every caller, including ones added on master since, compares equivalent file ID spellings as the same needle. The needle normalization moves from the server scope checks to filer.ChunkIdentity so both share it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filersink: match replicated source file IDs by needle compareChunks no longer reports a respelled source chunk, so the replica keeps the SourceFileId it was copied under. Removing chunks the source dropped and judging stale backup chunks now compare that ID by needle, otherwise a later removal in the other spelling would leave the replica's chunk behind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
39675b2faf |
filer: hide remote rename source paths from scoped responses (#13010)
* filer: redact remote rename source from scoped responses * Preserve scoped remote rename markers * Consolidate scoped marker replacement coverage * Refuse scoped whole-entry guards during remote rename * Keep coded create refusals for guarded scoped writes * Make scoped subscription batch coverage deterministic * filer: refuse scoped conditions that compare the remote rename source IF_EXTENDED_NOT_EQUAL clauses and ExpectedExtended on Create, Update and DeleteEntry could still compare a guess against the hidden marker, so a scoped client could confirm the source path it redacts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: refuse scoped condition gates on the remote rename source An IF_EXTENDED_TIME_ELAPSED gate applies its time check only when the gate value matches, so a gate on the marker also confirms a guess. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep a pending rename source out of remote copy errors A failed copy of a pending remote-only rename named the marker's source location, which the backend error repeats, and rename RPCs return that error to scoped callers. Log the full error and return one naming only the paths the caller supplied. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: let a scoped local overwrite end a pending remote rename Scoped replacements kept the hidden rename source marker even though a scoped entry can never stay remote-only, so the marker was stale on the local copy and every later scoped IF_ENTRY_EQUAL write was refused. Drop the preservation and let the overwrite clear the marker as other local writes do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * codespell: ignore poligon only inside URLs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
0fb1387226 |
s3: compare If-None-Match weakly, as the filer and volume servers do (#13033)
* s3: compare If-None-Match weakly, as the filer and volume servers do The S3 gateway matched conditional ETags by trimming quotes, so a weak tag such as W/"etag" in If-None-Match never matched and a revalidating GET got 200 instead of 304. Move the filer's RFC 9110 matcher to weed/util and use it in the gateway: weak comparison for If-None-Match, strong for If-Match. The routed write condition now sets AllowWeak on IF_ETAG_NOT_MATCH so the check under the object lock agrees with the gateway's pre-check. * s3: split write-condition ETag lists the way the gateway matches them etagList split on every comma and kept empty elements, so the filer's locked If-None-Match check (now a weak comparison) could match a fragment of one quoted tag, or an empty element, that the gateway's pre-check ignores. A PUT with If-None-Match: W/"<etag>,x" passed the pre-check and then got 412 under the lock. Reuse the gateway's quote-aware splitter and drop empty elements. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Mansur Akhmadi <10739460+mansur-akhmadi@users.noreply.github.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
a409877b8f |
volume, operation: refresh the write JWT for replica forwards and filer-proxy retries (#13028)
* volume, operation: refresh the write JWT for replica forwards and filer-proxy retries A write JWT is checked when a request arrives, but a slow chunk can take longer to stream in than the JWT lives. The volume server then forwarded the already expired JWT to its replicas, which rejected it with wrong jwt, and the client retried through the filer with its own filer JWT, which by then had expired too. Only a 401 marked as an expired volume JWT re-minted the filer JWT, so the 500 from the failed replica forward led to retries that could never succeed. The volume server holds the signing key and has already authorized the request for this file ID, so it signs a fresh JWT for the forward; without a signing key it forwards the incoming one as before. A filer-proxy upload re-mints its filer JWT before every retry, whatever the previous failure was. Refs #6220 * volume: mint the replica forward JWT right before each forward A JWT minted before the uncached master lookup spends part of its lifetime on that lookup, so the replica can still see it expire; minting inside the forward path gives each replica request its full lifetime. Minting stays unconditional rather than forwarding a still-valid incoming JWT, which could expire in flight and reintroduce the failure. The cost is a key rotation constraint: a new write signing key must be verify-only on every volume server before any server makes it current. The base file ID trim moves into one helper so the authorization check, the expiry classification and the mint cannot disagree on which file ID a write JWT covers. |
||
|
|
e9a5d733b1 |
weed: report host THP policy; build: declare Go 1.27.4 to match the releases (#13025)
* weed: report the host transparent huge page policy at startup Go maps the heap with MADV_HUGEPAGE, so the host THP policy applies to a SeaweedFS process whether or not the operator asked for it, and the advice in the Go GC guide depends on the heap size. Operators had no way to see which mode a node actually runs in. Log enabled/defrag/khugepaged.max_ptes_none once at startup from the long-running commands, and print the Go toolchain in `weed version` so a support bundle identifies the runtime that produced the binary. Nothing changes the policy: THP is host-wide, and GODEBUG=disablethp=1 remains the only per-process control. Refs #5437 * build: declare Go 1.27.4, the toolchain the releases already use The 4.55 release binaries report go1.27.4 (`go version -m` on the published tarball), while go.mod still said 1.26.6, the Dockerfiles pinned golang:1.26, and the release workflows left the Go version to the action default of "the latest stable at build time". A source build, a container and a downloaded tarball therefore ran different toolchains from the same tag, and the next release could silently pick up another one. Set the go directive to 1.27.4 in the root module and in the four modules that build in CI, bump the 16 Dockerfiles, and pin goversion: 1.27.4 in the 16 release and dev action steps. `go mod tidy` now emits the two require blocks Go 1.27 expects; no dependency version changed. Go 1.27's gofmt realigns 8 files. * weed mini: report the THP policy after quieting stderr The startup line ran from the dispatch point before runMini applied quietMiniLogs, so every weed mini start on Linux printed it to stderr, which mini keeps for the welcome banner, warnings and errors. Log it from runMini after quietMiniLogs so it lands in the log file only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: report whether the Go heap can use huge pages The runtime advises only GC metadata with MADV_HUGEPAGE and leaves the heap arenas to the host default, so under enabled=madvise the heap stays on small pages. The log still printed go_heap_disabled=false there, which reads as "the heap uses THP". Report go_heap_thp, true only under enabled=always without GODEBUG=disablethp, and drop the struct comment that said the heap is mapped with MADV_HUGEPAGE. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: count an inherited PR_SET_THP_DISABLE in go_heap_thp A launcher can disable THP for the process with prctl, and children inherit it, so enabled=always alone does not mean the heap gets huge pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: read GODEBUG disablethp the way the runtime does The runtime applies GODEBUG left to right, so with disablethp=1,disablethp=0 the heap keeps THP, while the helper stopped at the first disablethp=1. The helper also missed other nonzero values such as disablethp=2, which the runtime treats as disabled, and trimmed spaces around keys, which the runtime keeps. Take the last disablethp with an integer value, treat any nonzero value as disabled, and match keys exactly. The parser now takes the GODEBUG string, so it is tested without changing the environment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: honor per-size THP policies in go_heap_thp Since Linux 6.8 each anonymous huge page size has its own policy in hugepages-<size>kB/enabled, and only "inherit" follows the top-level knob. A 64kB size set to "always" gives the unadvised heap huge pages under a top-level "madvise" or "never", and a 2048kB size set to "never" takes them away under "always", but the log judged only the top-level value. Read the per-size policies and report go_heap_thp=true when any size reaches the heap. Under a top-level "never", the "disabled by the host" line is now printed only when no size reaches the heap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: report go_heap_thp=unknown when the process setting is unreadable If PR_GET_THP_DISABLE fails, for example because a seccomp profile rejects it, the process THP setting is not known, but the log treated it as allowed and could print go_heap_thp=true. Print go_heap_thp=unknown in that case. It stays false when the host or GODEBUG already rules out heap huge pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: report go_heap_thp=unknown when a per-size THP policy is unreadable An unreadable hugepages-<size>kB/enabled was skipped, so the log could say the host disabled THP while that size allowed it. Keep it as an empty mode and report unknown unless a readable size already allows huge pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: take the Go version from go.mod in tests and releases posix-compliance pinned GO_VERSION 1.26 and built go 1.27.4 modules only through the GOTOOLCHAIN auto-switch; nine workflows used go-version ^1.26 and the kafka jobs ran in golang:1.26-alpine. Read the version from go.mod with go-version-file, as the other setup-go steps already do, moving checkout ahead of setup-go where it came after so the file exists. The posix report takes the version from the setup-go output. The release and dev builds pinned goversion 1.27.4 in 16 places. The pinned go-release-action reads the go directive when goversion is go.mod, so the binaries now follow go.mod without a second copy of the version. * weed: report the THP policy from every long-running command mount, worker, iam, master.follower, the filer sync/backup/remote/replicate daemons and the mq agent and kafka gateway keep serving after startup like the commands already listed; mount is likely where heap size matters most. fuse is not listed: its first process starts a child with the same arguments and waits, so logging at dispatch would print the line twice. It logs in runFuse just before handing over to runMount, which only the child reaches. --------- Co-authored-by: Konstantin Lebedev <whitefox@mayflower.work> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
77a6787335 |
Bound upload memory: admission by size, gateway holder writes, 503/SlowDown back-pressure, body deadline (#13021)
* util: one admission rule for upload limits * operation: mark gateway fan-out holder writes as client traffic * volume: bound upload admission, limit gateway holder writes, 503 on timeout * volume: charge unknown-length uploads half the budget, document client wait cap * s3, filer: admit uploads by inFlight+size and charge unknown lengths a chunk * s3: answer a volume overload as SlowDown with Retry-After * operation: cut an upload whose body crawls below the minimum rate on any host * operation: make the slow-commit deadline test honour the request context * s3: stop chunk uploads when the client goes away * operation: treat a body deadline cut as back-pressure, not a same-holder retry A body that crawls past the body deadline returns from retriedUploadData at once, like an overload, and counts toward the single reassign the chunk loop and the filer retry gate give back-pressure. A watchdog cut keeps its retry on a fresh conn. Both still match ErrUploadStalled and stay reassignable. * operation: apply the body deadline only to uploads that opt in UploadOption.BodyDeadline and ChunkedUploadOption.BodyDeadline turn the body deadline on; S3 chunk uploads (relay and fan-out) and the filer's chunk loop set it. Mount, filer.sync, filer.copy and UploadWithRetry keep the stall watchdog only, as before the deadline existed. * s3, operation: check a chunk cancelled with its client is deleted from every holder A volume commits on a context that ignores the cancel, so a chunk whose caller went away after sending the body may still land. The chunk loop already deletes the fid from every holder after a failed attempt; pin that for the relay and fan-out paths and for an S3 PUT whose client goes away. * s3: count a request's declared bytes in the circuit breaker byte limits The per-bucket and global byte counters go back to the declared length (an unknown length counts one chunk), so a bucket bytes limit still rejects a single PUT larger than it. Only the upload budget uses the capped gateway charge. * s3: answer copy chunk overloads as SlowDown, tidy the client-gone checks CopyObject and UploadPartCopy map a volume overload or an exhausted stall to SlowDown, as PutObject does. The client-gone log check matches the mapper's context.Canceled test, the truncated-body case drops a check the first case already makes, and the Retry-After test reads the headers actually sent. * filer, volume: clamp the filer charge chunk, set the upload gauge under the lock A filer with -maxMB 0 charges its default chunk size instead of nothing. The volume server sets its in-flight upload gauge inside the critical section. The upload limit tests wait until the waiter is parked before releasing, check handleUploadRequest gives its charge back, and use CI-safe bounds. * volume: cap the Rust server's client upload-slot wait at 5s Same cap as the Go volume server's volumeClientUploadWaitCap, so a gateway's body deadline never fires before the 503. * operation: reflow the body deadline comment * volume(rs): count a gateway's src=client holder write against the upload limit Mirrors operation.IsReplicaForward: only a primary-to-replica forward skips the upload budget; a gateway's ?type=replicate&src=client fan-out waits like any client write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): admit uploads by inFlight+size, reserved atomically Mirrors the Go volume server's waitForUploadSlot: an upload is admitted by util.UploadAdmits (idle server, or inFlight + size within the limit) and reserves its bytes in the same step, so concurrent waiters cannot all pass one check. Primary-to-replica forwards and unlimited servers are counted but never refused. UploadLimitCond counts once per waiting upload, and the wake-up is armed before each check so a release in between is not missed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): charge an unknown-length upload against the upload limit Mirrors the Go volume server's uploadCharge: a chunked upload without Content-Length reserves one file's worth of budget, at most half the limit and at least 1 byte, instead of 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): a zero -inflightUploadDataTimeout waits the 5s client cap The Go volume server now reads 0 as the 5s cap (its flag help says so); the Rust server used a 2s wait. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): close a rejected large or unknown-length HTTP/1 upload Mirrors the Go volume server's uploadRejectCloseThreshold: the 503 for a body over 256 KiB, or one without a length, carries Connection: close instead of keeping the connection for a body nobody reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): drop src from a primary's replica forward A client upload carrying src=client kept it on the forward, so replicas treated the forward as gateway fan-out and could refuse it after the primary had already appended. Go's ReplicatedWrite builds a fresh query. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): keep the upload admission CAS buildable on rust 1.91.1 Atomic try_update is stable only since 1.95. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): refuse an upload the in-flight counter cannot hold A replica forward added its charge with fetch_add, so a Content-Length near i64::MAX wrapped the shared counter negative and let later client uploads past admission. The forward now reserves with a checked add and answers 503 when the size does not fit; the client CAS adds only after admission passes. With no upload limit the counter only feeds the gauge, so it keeps wrapping arithmetic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: refuse an upload the in-flight counter cannot hold A replica forward added its charge unchecked, so a Content-Length near math.MaxInt64 wrapped inFlightUploadDataSize negative and let later client uploads past admission. Under the lock the reservation now checks that the counter can hold the charge and answers 503 otherwise, matching the Rust volume server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: keep the request body on a rejected upload Replacing r.Body with http.NoBody hid the server's early close of the unread body from net/http before Go 1.27, so it skipped the FIN-then-wait close and reset the connection under a client still sending. Go 1.26.6, the version go.mod declares, then failed TestUploadLimit503ReachesGoClientForLargeBody with a write error instead of the 503. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: compare upload admission without forming inFlight+size * operation: reassign a chunk after a 429 as after a 503 * s3: do not count a chunk assignment the client cancelled as a filer failure * filer: charge an upload by its request chunk size, and an inline upload by its whole body * s3: hold an aws-chunked body to its X-Amz-Decoded-Content-Length * volume: answer a rejected small-body upload without waiting for its body * s3: fill the upload budget before testing that a release wakes every waiter --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d2276f531e |
master: apply the whitelist to management gRPC RPCs (#13022)
* master: gate operator-only management RPCs on the whitelist CollectionDelete, DisableVacuum, EnableVacuum, VolumeGrow, ResumeVolumeGrowth, LeaseAdminToken and ReleaseAdminToken now call checkGrpcAdminAuth, matching the whitelist their HTTP counterparts already enforce. VolumeGrow stays open to the in-process growth loop, and callers on the local gRPC socket of weed server/mini are local. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * master: admit unknown masters over KeepConnected only from the whitelist A KeepConnected registration as a master pulls that address into the raft quorum. Accept it from any caller only for this master and its -peers; any other master address now needs a whitelisted caller, the same check RaftAddServer applies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * master: test that every RPC is gated or listed with a reason Port the volume server's coverage test so a new master RPC cannot skip checkGrpcAdminAuth without an explicit exemption. The proto and AST helpers now take the proto file and receiver name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: admit callers on the local gRPC socket weed server and weed mini route same-host gRPC dials through a unix socket, whose peer address carries no IP. With -whiteList set the volume server refused the in-process master's AllocateVolume, so no volume could be grown. The Rust volume server serves gRPC over TCP only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * master: match a KeepConnected master against configured peers by gRPC endpoint Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pb: bind the local gRPC socket for the owner only Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: warn when a deleted bucket's collection is left on the master Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pb: bind the local gRPC socket in a private directory before moving it into place Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: report an unconfirmed bucket collection delete as such Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
25f7e8a0fd |
filer: refuse chunk appends onto inline and remote-only entries (#12993)
* filer: refuse unsafe chunk appends * filer: report append representation preconditions * filer: cover cached remote append eviction safety * filer: cover lazy remote append refusal * filer: refuse HTTP appends and offset writes onto remote-only entries An HTTP append or offset write onto a remote-only entry stored the new chunk with nothing below it, so reads returned zeros where the remote bytes were and the entry stopped being remote-only. Small appends failed with a retryable "inline file changed" error instead. Refuse both with a client error, matching AppendToEntry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: AppendToEntry appends after a sparse tail AppendToEntry placed new chunks at the end of the existing chunks, so a file extended past them by a truncate got the appended bytes inside its logical length instead of after it, and its size did not grow. Use the entry size, as the HTTP append path does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
f079b68f2b |
filer: grpc_require_token with authenticated filer-to-filer peer calls (#13011)
* filer: require bearer tokens for configured gRPC calls * filer: authenticate owned peer RPCs with per-call admin tokens * filer: retain scoped forwarding refusals with required authentication * filer: preserve tokenless HTTP forwarding outside require mode * filer: honor clock tolerance for gRPC admin fallback * filer: preserve caller token on lock owner forwards * filer: forward caller auth on target ping * filer: authenticate startup peer digest checks * filer: verify required subscription bearers independently of mTLS * filer: assert exact caller bearer on forwarded ping * filer: sign peer tokens with the gRPC verification key peerContext signed filer-owned RPCs with jwt.filer_signing.key only. With grpc_key as the only key and require-mode on, peer calls went out tokenless and were refused. With both keys set, peers that verify with grpc_key and lack the shared-key admin fallback refused the shared-key token even with require-mode off. Sign with the key filesystem gRPC verifies, and keep the shared key for metadata subscriptions, whose verifier accepts admin tokens signed only with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep a subscription token's scope over mTLS in require-mode Require-mode admitted a dedicated subscription bearer without the mTLS shortcut, but the handler re-checked it with the certificate, which granted the full stream past the token's prefixes and expiry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: delete uploaded chunks when the write owner refuses authentication A forwarded HTTP append or offset write that the owner refused as Unauthenticated kept its new chunks as if the outcome were unknown, orphaning them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: hand the admitted subscription scope to the handler The handler re-verified a dedicated subscription token after reading the request. If the token expired in between, an mTLS peer fell back to the certificate and got an unrestricted stream. The interceptor now passes the scope it admitted, and the handler refuses it once expired. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: accept grpc_key admin tokens on metadata subscriptions A filer with only grpc_key signs peer subscriptions with it, but the subscription verifier checked admin tokens against the shared key only, so with a subscribe key set the aggregator's peer streams were refused. An unscoped grpc_key token already has full filer gRPC access. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: delete the generated manifest when the write owner refuses authentication A forwarded HTTP append that crossed the manifest threshold left the manifest blob it had uploaded orphaned when the owner refused the call as Unauthenticated. The blob alone is deleted, since the manifest also lists committed chunks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
a1764358cf |
filer, mount: keep a hard-linked file to one link id and count its names on the filer (#13006)
* filer, mount: keep a hard-linked file to one link id and count its names on the filer A hard link's bookkeeping was done by the client. To link a file a mount reads its entry and sends two writes, an update of the source and a create of the new name, both with a link id and a count of the file's names. Two clients that link one file at the same moment each worked from the entry as it was before the other's writes: - With no link id on the entry yet, each made one up. The second update moved the source to its id, the store took the name off the first, and the first client's new name was left alone on it: one file's chunks under two link ids. - With a link id there, both read the same count and sent it plus one. The record counted one name fewer than the file had. Any write through a name carried the client's copy of the count and replaced the record the same way. Either way the delete of the last counted name deleted the record and the chunks while another name still read them. The filer's own store now counts the names of a hard-linked file itself (countLink): one more when the name written did not hold the link before, the same when it did or when a rename moves it there (WithMovedLink), one for a record that starts. The count sent is not used, and the entry gets the count stored, so the response and the event carry it. The lookup of the name, the count, the record and the name are stored as one change of the record (changeLinkRecord), which DeleteHardLink goes through as well: under a lock per link id, and in a transaction where the store refuses a commit over a change made since it began, run again when it does. A wrapper around a copy of some entries, such as a mount's metadata cache, sees only some of the names and stores the count it is given. UpdateEntry refuses to give a name that holds a hard link another link id that no file has yet (refuseSecondHardLink). The mount sends a file's first link's update as a unary RPC, which keeps that refusal apart from an I/O failure, reads the entry again and links under the id the file has by now. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * filer: take a replicated update's link id without refusing it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: look a path-specific name up outside the record's transaction Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: check the leveldb open and close it in the hard link test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: send a refused first link again from the entry as stored Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep a first link's refusal over the next filer's error Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: count a hard link's names next to the clients' count instead of in its place The filer's count replaced the one clients send, which lost two things that count did by being worked out ahead: - A link's first write, the update of the source, carries the count with the new name in it already. While the second write is on its way that kept a delete of the source from being taken for the delete of the file's last name (lastLinkDropped goes by the count it read), and the chunks from being deleted under the name about to come. Counted only when it arrived, the new name was stored with chunks that were gone: 104 of 300 rounds of a mount linking a file while another deletes it. - A write of a name the store refused had counted the name already, and sent again counted it once more. The filer now keeps its count of the names in a key of its own next to the record (linkNames), written once the name is stored, and the record gets whichever is higher: the count the client sent or the names counted. It is never lower than what the client alone would have left, and never lower than the names the file has. A record from before has its count recorded as the names when it is first written again. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * mount: send a refused first link again with the file's inline content The second attempt builds the new name's create from the entry as the filer has it by now: attributes, chunks and extended attributes. A file the filer keeps inside its entry has its bytes in Content, and the create is what the filer writes the link's shared record from, so without them the record lost the file's content. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * filer: store a path-specific name before the record's lock is let go A second create of the same new name on this filer took the lock between the first one's count and its name write, missed the name, and counted it again: the file's record and chunks then outlived its last name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep a link's names key out of the keys of a directory's entries The key began with the link's random id. One that began as the root's entry keys do in a store keyed by path put the names' 4 bytes in the root's listing, and it failed to decode: listing / and the etcd scan under fsck failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: record a hard link's name before it is stored, and take it off if it is not The names counted for a hard link were recorded once the name was stored. On a store without transactions a failure of that write left the name stored and not counted, and the write sent again found the name there and did not count it either: the names recorded stayed one below the names stored, the side a file is deleted under a name from. They are recorded first now, inside the change of the record that counted them, and a name the store then does not take is counted off again (storeCountedName). A failure halfway leaves them one above the names stored, and the file leaked. A name in a path-specific store is recorded with the record as well, and counted off in a change of its own. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * filer: keep a hard link's name counted when a failed write stored it A write whose deadline passes after the store took the name returns an error, and counting the name off then left the names one below the names stored. A later write with the count from before the link lowered the record to them, and the file was deleted under a name it still had. Read the name back first, and keep it counted where that cannot be told. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: carry the stored RemoteEntry into the name a retried first link adds The retry rebuilds the new name from the entry the file has once another client linked it, but kept the RemoteEntry of the entry first read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
fb0a734dc4 |
feat(remote_storage): add Yandex Disk as a remote storage backend (#13012)
* feat(remote_storage): add a Yandex Disk backend Yandex Disk joins s3/gcs/azure as a remote storage type, so it can back remote mounts and sink replication (filer.remote.sync, filer.remote.gateway) without a separate sink. The Disk API has no buckets and no place for a file's mtime: a top-level folder under yandex_root plays the bucket, and the entry's modification time and content encoding travel as custom resource properties (seaweedfs_modified, seaweedfs_content_encoding; rclone_modified is read too). The client also handles the API's asynchronous operations (202 + operation polling), the short-lived, single-use download links (a fresh link per read and per retry), single-PUT uploads, mkdir -p of an S3-style key's parents, server-side copy for a remote-only rename, and a ranged read that refuses a short body. A caller-supplied endpoint goes through the guarded client like the s3 and azure endpoints. * feat(shell): configure and issue Yandex Disk tokens remote.configure gains the yandex flags (token, client_id, client_secret, root, trash, app_folder, endpoint). A refreshable token is issued in two steps without a browser on the server: -yandex.oauth_url prints the authorization url and keeps the app credentials, -yandex.code exchanges the copied code for a token and stores it. The token and the client secret are masked in the configuration listing. docs/remote-storage-yandex.md walks through the OAuth app, both token flows, the mount and replication commands, and the platform's limits. * fix(remote_storage): handle missing Yandex folders on stat, copy and upload A missing object is confirmed against the bucket folder rather than its immediate parent, as the gcs client does: a key whose subfolder does not exist yet (a rename destination) is a missing object, not a vanished mount, and the sync only proceeds on ErrRemoteObjectNotFound. CopyFile creates the destination's parent folders, so a remote-only rename into a folder the remote does not have yet succeeds. The Disk API answers a missing parent with 409 DiskPathDoesntExistsError; upload and copy treat it like a 404, and the fake answers the way the API does. An operation poll refreshes the token once on 401 and then fails, instead of polling without a pause until the operation deadline. * fix(remote_storage): retry a locked Yandex resource A folder that is still being deleted asynchronously answers a write with 423 DiskResourceLockedError for a moment. The client now retries it with the same backoff as 429/5xx/509, and the error stays transient for the sync's upload retry when the client's retries run out. * fix(remote_storage): harden the Yandex backend after review Traverse reports objects only, like the s3, gcs and azure clients: its callers (remote.cache, remote.copy.local) read the stamp of every entry, and a folder came with none. Deletes no longer reach what they were not meant for. A Disk API delete is recursive, so DeleteFile keeps a folder that took a file's place on the remote, and DeleteBucket removes an empty bucket folder only, the rule S3 and GCS apply to a bucket. CopyFile keeps the destination until its replacement exists: it copies with overwrite and removes the old object (to the trash when configured) only when the service kept it anyway. It refuses to replace a folder, treats a copy onto itself as done, and carries the source's resolved modification time, including rclone_modified and the service's own time. Every metadata request and operation poll has a deadline that covers reading the answer, and a token refresh or code exchange has its own, so a stalled endpoint cannot block the client. Redirects are checked like the transfer links, an endpoint that would send the token over plain http is refused unless it is on a loopback host, a 202 without an operation link is an error, and a read with an offset and no size starts at the offset. * chore(seaweed-volume): keep only the Yandex fields in the remote.proto copy * yandex: retry a failed operation poll One throttled, failed or timed-out status poll ended a wait of up to 30 minutes while the operation kept running on the service, so a large delete or copy was reported failed and redone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * yandex: refresh a token once for concurrent 401s Every request rejected with the same access token replaced the token source, so N concurrent 401s refreshed, and rotated the refresh token, N times. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * yandex: retry an operation poll whose answer was cut short A status poll that got its 200 headers but lost the connection before the JSON body ended failed with io.ErrUnexpectedEOF, which the poll retry did not treat as transient, so the wait ended while the operation kept running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Konstantin Lebedev <whitefox@mayflower.work> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
37c0b2f162 |
webdav: store a real md5 for each uploaded chunk (#12988)
* webdav: store a real md5 for each uploaded chunk Chunks written through the shared gateway uploader had no md5, so the file ETag was built from empty digests: every overwrite of a multi-chunk file kept the same ETag (If-None-Match answered 304 for new content) and single-chunk files had no ETag at all. Ask the uploader for Content-MD5, as mount and filer.copy already do. * webdav: quote the ETag it serves DAV:getetag and the ETag header must be entity-tags. A bare digest never matches a client's quoted If-None-Match or If-Match in http.ServeContent, and single-chunk files now carry a digest instead of webdav's quoted fallback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: serve no filer ETag built from chunks without digests Files written before chunks carried an md5 all hash to the md5 of empty digests plus their chunk count, so unrelated files with as many chunks share one tag and a conditional GET can answer 304 for changed content. Leave the tag to webdav's modtime and size fallback for those. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: answer a PUT with the ETag of the content it committed webdav.Handler stats the file before Close uploads the last chunk and updates the entry, so every PUT answered the empty created entry's tag and an If-Match with it failed against the stored file. Close now records the committed entry's tag on the PUT outcome and the response writer sends it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: serve no filer ETag for inline content without an md5 filer.ETag hashes only the chunk list, so every inline entry without Attributes.Md5 gets the empty-list tag. Fall back to webdav's own tag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: upload the PUT test's chunk during Close Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: tag inline content without an md5 by its bytes The modtime+size ETag webdav derives matches two equal-size contents stored in one second, so a replace could answer 304. util.Md5 follows the cluster's digest, which fips140=only keeps off MD5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: tag chunks stored without digests by their file ids The modtime+size ETag webdav derives matches two equal-size files stored in one second. A rewrite stores new chunks, so their file ids and placement tell contents apart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
a5e52b68f1 |
server, filer, s3: log downloads the client hung up on below error level (#12991)
* server: log a response the client hung up on below error level A client that closes a download early (a video player seeking, a browser cancel) fails the next response write with a broken pipe, a connection reset, or an HTTP/2 stream close, and ProcessRangeRequest logged each one as an ERROR. net/http cancels the request context once a write to the client fails, so a canceled context now logs at V(3); a failure under a live request still logs as an error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: log a stream the client hung up on below error level The filer logged "failed to stream content" as an ERROR for every download a client closed early, next to ProcessRangeRequest's own line. It now goes through the same check, so only a failure under a live request reaches the error log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: log a GET the client hung up on below error level A client closing a download early made GetObject log two ERROR lines, from streamFromVolumeServers and from GetObjectHandler, and the SSE copy paths logged a third. The write fails with a broken pipe or connection reset rather than context.Canceled, so the canceled-stream check missed it. net/http cancels the request context once a write to the client fails, so streamCanceled also treats a canceled request as the client leaving. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: log a canceled chunk read below error level A ranged S3 GET reads through ChunkReadAt with the request context, so a client hanging up cancels the chunk fetch and the reader logged "fetching chunk ...: context canceled" (and, when the lookup was the step canceled, "operation LookupFileId ... failed") as an ERROR. A read whose caller canceled it now logs at V(3). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
7638cf2f66 |
mount: keep the data past a sparse file's first hole when merging chunks (#12978)
* mount: merge each run of a sparse file's data, not just the run before its first hole The chunk stream reader ends at a hole, so the merge stopped there and replaced every chunk with ones covering only the data before the first hole. Read and save each contiguous run of visible data on its own, and leave the holes between runs unwritten. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: skip the small-chunk merge for a sparse file The merge reads the chunks through the stream reader to its end, which stops at a hole, and keeps only the chunks before its start offset, so an append to a sparse file lost the data past the first hole after it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
1815f140b6 |
fips140=only: refuse JWT signing keys and S3 secrets too short for HMAC (#12912)
* fips140=only: refuse HMAC keys too short for FIPS mode where they are configured Under GODEBUG=fips140=only, hmac.New panics on keys shorter than 112 bits (14 bytes). A short JWT signing key starts fine and then kills weed server on the first write (the master's Assign mints a volume JWT in an unrecovered gRPC handler), and an S3 secret of 8 or 9 characters (the SigV4 signing key is HMAC keyed with "AWS4"+secret) makes every request from that identity panic in its handler. Only under crypto/fips140.Enforced(): - security.toml: LoadSecurityConfiguration exits with an error naming the setting when a jwt.signing / jwt.filer_signing key, read key or previous key is under 14 bytes. LoadFilerJwtFromFile (filer.sync -a.security/-b.security) returns the same error, and Guard.UpdateSigningKeys keeps the keys in effect on a reload that brings in a short key. - S3: SigV4 (header, presigned, streaming seed and POST policy) answers InvalidAccessKeyId, as for an inactive key, when the credential's secret is under 10 characters, and logs the access key. Loading such a credential logs a warning; it stays loaded and stored. - IAM CreateAccessKey (IAM API, embedded IAM, admin UI) requires a caller-supplied SecretAccessKey of at least 10 characters. Refs #12839 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fips140=only: check jwt.filer_signing.subscribe.key and the imgproxy key too The filer verifies metadata subscription tokens with jwt.filer_signing.subscribe.key and `weed shell fs.meta.token` signs them with it, so under GODEBUG=fips140=only a short value panics on first use; LoadSecurityConfiguration now refuses it with the other JWT keys. `weed image` signs imgproxy URLs with HMAC keyed with IMGPROXY_KEY; gateway.New refuses a key under 14 bytes in that mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: warn about JWT keys too short for fips140=only outside that mode Outside GODEBUG=fips140=only a JWT signing key under 14 bytes works, so LoadSecurityConfiguration (every weed command but fuse) and LoadFilerJwtFromFile now log a warning naming the setting instead of saying nothing: such a key is refused under fips140=only, and a future release may refuse it in every mode, so the warning asks for a rotation to a longer key with previous_key while it still works. A short previous_key holds the old key during that rotation, so its warning only asks to clear it afterwards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: refuse a short secret under fips140=only with AccessDenied, not InvalidAccessKeyId InvalidAccessKeyId says the access key does not exist, so a client refused for a secret too short for fips140=only went looking for a missing key. The new ErrFips140SecretTooShort answers AccessDenied (403) with "This access key cannot be used while the server runs in FIPS 140 mode. Ask the administrator for a new secret." The message leaves out the length rule: the refusal comes before the request's signature is checked, so any caller that knows the access key ID would learn the secret is short. The embedded IAM API maps it to AccessDenied as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: log an S3 secret too short for fips140=only at error level Under GODEBUG=fips140=only every request signed with such a key is refused, so the identity is unusable; the load-time message is an error, not a warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util, security: name every JWT key too short for fips140=only in one error CheckFips140SigningKeys stopped at the first short key, so a cluster with two short keys failed at startup, was fixed, and failed again on the next one. CheckFips140HmacKeys checks every setting and names each short key ("jwt.signing.key is 10 bytes, jwt.filer_signing.key is 8 bytes; ..."); with one short key the message is unchanged. Guard reloads use it as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fips140=only: say what happened, to what and what to do in the short-key messages The messages about S3 secrets and JWT keys too short for FIPS 140 now start from the process's mode, name the key, its owner or file, the limit, and the fix: - loading S3 identities: "this process runs with GODEBUG=fips140=only, and refuses all S3 requests signed with access key ... (identity ...) because its secret is shorter than the 10 characters FIPS 140 needs for SigV4 secrets; give that access key a new secret of at least 10 characters"; - a refused request logs its request ID, which the client gets back, its client IP (as the audit log records it, s3err.RemoteIP) and the identity; - the startup refusal names security.toml's path and every short key, and links the wiki section on replacing them with or without downtime; - the startup warning outside fips140=only says the server would not start in that mode, and links the same section. A short previous_key no longer gets a warning outside fips140=only: it holds the old key while switching to a longer one, and under fips140=only the startup refusal names it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: a reload under fips140=only drops short previous keys, not the new keys UpdateSigningKeys refused the whole key set when a previous key was too short, so a volume server kept its old keys while the filer's volume signer, which gets no previous keys, took the new ones; proxied chunk reads then failed with 401. Short current keys still keep the keys in effect. A short previous key is dropped with an error log instead: nothing under fips140=only can sign with it, so no token is lost, and every server ends up with the same current keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: check only the filer keys filer.sync uses in its security files LoadFilerJwtFromFile checked every JWT setting in a -a.security/-b.security file, so under fips140=only filer.sync refused to start over a short volume or previous key it never uses. It now checks jwt.filer_signing.key and its read key, after the fallback to the process-wide configuration, which startup checks already. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: answer a short secret under fips140=only with SignatureDoesNotMatch A distinct answer before the signature is checked told anyone who knows an access key ID that its secret is short. The refusal now runs where the signature would be checked, after the permission, expiry and signed-header checks, and answers the SignatureDoesNotMatch a wrong signature gets. The server log keeps the cause, the request ID and the client. This drops ErrFips140SecretTooShort and its IAM mapping. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security, filer: keep Basic Auth on a reload whose JWT keys are refused When a reload under fips140=only refused the new filer JWT keys, the filer still removed Basic Auth, so a configuration that switches from Basic Auth to short JWT keys left the filer with neither. UpdateSigningKeys and ReloadSigningKeys now report whether the new keys are in effect, and the filer drops Basic Auth only when they are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util/http: do not install a volume read key too short for fips140=only A reload installed jwt.signing.read.key into the read-signing cache without a length check, so under fips140=only a short key made later chunk reads panic signing with it. loadJwtConfig now leaves the key in effect when the new one is too short. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util/http: keep the volume read key when the volume guard would refuse the reload Under GODEBUG=fips140=only a volume server's reload keeps its keys when jwt.signing.key or jwt.signing.read.key is too short. The read-key cache checked only the read key, so it could sign reads with a key the volume servers had not taken. It now checks the same two keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: build the short-key list in one append in CheckFips140HmacKeys Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: keep the blank line before the permission check in verifyV4Signature Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: skip TestFIPS140OnlyShortSecret under real fips140=only enforcement Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
5b300ea909 |
filer: scope metadata subscriptions to a token's prefixes (#12931)
* filer: scope metadata subscriptions to a token's prefixes * filer: check scoped updates before preparing chunks * filer: recheck scoped WORM policy after chunk preparation * filer: preserve scoped event parents and recheck update authority |
||
|
|
7c33a8449f |
volume: check a CRC32C of each chunk upload, in every digest mode (#12999)
* volume: check a CRC32C of each chunk upload, in every digest mode In sha256 digest mode the uploader sends no Content-MD5, so the volume server and its replicas store a chunk without checking that its bytes arrived as sent. The uploader now sends X-Seaweed-Content-Crc32c, the std-base64 of the big-endian CRC32C of the bytes Content-MD5 is checked against (the file data after undoing Content-Encoding: gzip; the ciphertext for ciphered chunks), in both digest modes. Uploads that forward a stored needle (IsReplication) carry only a value the primary volume server checked. The Go and Rust volume servers refuse a mismatch or a malformed value with 400, as they refuse a wrong Content-MD5, and forward the checked value to replicas, which check it again. A gzipped upload without Content-MD5 is checksummed while its size is counted, without holding the uncompressed bytes. Servers that predate the header ignore it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): keep the first part's headers when no part has a filename Go's parseUpload falls back to the first multipart part with its Content-Type, Content-MD5 and Content-Encoding. The Rust fallback dropped them, so a gzipped part without a filename was stored as plain bytes and its X-Seaweed-Content-Crc32c was checked against the compressed body. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): read the RFC 2231 filename* of a multipart part Go's uploader names a part with mime.FormatMediaType, which writes filename*=utf-8''... for a non-ASCII name, and Go's Part.FileName() decodes it. multer reads only filename, so the Rust volume server missed the file part and lost its name, gzip encoding and Content-MD5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: send replicas the CRC32C of a rewritten JPEG Once the orientation fix rewrites a JPEG, the client's CRC32C no longer covers the bytes the primary forwards, so the replica got no checksum. Send the CRC32C of the stored bytes instead, in Go and Rust. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): read filename* only outside quoted parameter values A quoted name such as "note; filename*=utf-8''decoy" split at its semicolon and was taken for the part's filename. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): refuse a decoded filename* with control characters A percent-encoded CR/LF in the name would end the header block of the part the primary forwards to its replicas. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: read the forwarded CRC32C with the replica response in the test A failing assertion left the CRC32C in the one-slot channel, so the next subtest's replica blocked instead of the test reporting the failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): use naïve for the non-ASCII filename test data codespell reads the ASCII part of café as a misspelling of calf. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
c0f3182046 |
filer: run scoped UpdateEntry checks before chunk preparation (#12965)
* filer: check scoped updates before preparing chunks (cherry picked from commit |
||
|
|
9ffb5fe185 |
filer, s3, filer.sync: one digest per cluster, set by the filer's -digest and followed by its clients (#12913)
* util, filer: choose the digest at filer startup with -digest
NewMd5 and NewSha1 returned SHA-256 cut to size whenever the process ran
under GODEBUG=fips140=only, so the kind of digest a cluster stores followed
each process's own environment. They now follow a digest mode set once at
startup: util.SetDigest("md5"|"sha256"), or "" to keep following
fips140.Enforced(). The default is unchanged.
weed filer -digest, weed server -filer.digest and weed mini -filer.digest
set it; fips140=only refuses md5 at startup. The leveldb2/leveldb3
directory-key marker follows the mode, as do the places that compare a
NewMd5 digest with Content-MD5 or pass it on as one: S3 PutObject, filer
HTTP uploads, the Content-MD5 the filer returns, and the uploader's
Content-MD5 to volume servers. Places that verify Content-MD5 with a real
MD5 (volume servers, S3 request bodies and archive uploads) keep keying on
fips140.Enforced(), since they can check it whenever MD5 is available.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer, command: report the filer's digest and make its clients use it
GetFilerConfigurationResponse carries the filer's digest mode in a new
field 16, digest. weed s3, mount, webdav, sftp, iam and filer.copy adopt
it before they serve or write, so a gateway started with a different
GODEBUG writes the same kind of ETag and chunk digest as the rest of the
cluster. A process under fips140=only refuses a filer that reports md5. A
filer that reports no digest predates the field; the client then keeps
its own mode and logs a warning.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.sync, s3 sink: keep digests within one kind
filer.sync copies entry digests and ETags as they are, so syncing a filer
with digest sha256 into one with md5 left SHA-256 ETags in the md5
cluster. It now reads both filers' digests and refuses to start when they
differ, with a warning when either filer does not report one.
The S3 sink sent the entry digest as Content-MD5 unless its own process
ran under fips140=only. From a sha256 source into a target that checks
Content-MD5 every single-part upload failed with BadDigest and the backup
retried it forever. It now asks the source filer for its digest once and
forwards the entry digest only when that is md5.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.meta.backup, filer.backup, filer.replicate: keep digests within one kind
filer.meta.backup opened its backup store in its own digest mode, so a copy
of a sha256 filer made by a process outside fips140=only got MD5 directory
keys and could not be opened as that filer's store. It now adopts the source
filer's digest before the store opens.
filer.backup and filer.replicate with a filer sink copied entry digests into
the target filer without comparing digests, as filer.sync did before. Both
now refuse, and exit, when the source and target filers report different
digests. replication.CheckDigestsMatch is the shared check; filer.sync uses
it too.
weed server and weed mini apply -filer.digest before they start the master
and volume server, so every part of the process hashes with one digest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer, filer.sync: refuse a peer filer with another digest; exit on mismatch
Filers peering through the meta aggregator now compare digests. A peer with
a store of its own would replay entries holding the other kind of digest
into this filer's store, so its changes are refused and the reason logged
on every reconnect. A fresh filer bootstrapping from such a peer refuses the
copy, so a new filer whose digest differs from the existing filers' exits at
startup. A peer on the same store writes into it directly, and refusing its
stream would only starve this filer's subscribers, so that mismatch is
logged as an error and the stream kept.
filer.sync exits with status 1 when the two filers use different digests,
as filer.backup and filer.replicate do: it is a configuration error a
restart cannot fix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: -digest help says a store keeps the digest it was created with
The help text said existing data keeps the digest it was written with,
which reads as if the flag could be changed on a store with data. Stores
that hash keys stop finding existing entries under another digest, so the
text now says to set it when the store is created, and that switching means
copying the metadata into a new store with fs.meta.save and fs.meta.load.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer, s3, replication, admin, iceberg: address review of the digest checks
- A filer checks its peers' digests on every start, not only at the fresh-store
bootstrap: the store signature is written when the store opens, so a fresh
filer refused at bootstrap restarted as an initialized store and served
without its peers' files.
- Under digest sha256 with MD5 available (not fips140=only), a client's
Content-MD5 is checked against a separate real MD5 of the body, in S3 object,
part and directory-marker uploads and in filer HTTP uploads. It goes
unchecked only when no MD5 can be computed.
- filer.backup and filer.replicate exit only on a DigestMismatchError; a filer
that cannot be reached is retried, so a backup started before its target is
up resumes once the target answers.
- The admin file browser and Iceberg compaction write chunks into a filer they
do not follow at process level. They read that filer's digest and pass it to
the chunk upload (ChunkedUploadOption.Digest), so their content and chunk
digests match the filer's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer, s3 sink: retire digest-refused peers; no Content-MD5 for an unknown digest
- A peer refused for its digest counts as unreachable: the check now runs
before notePeerReachable and its error wraps errPeerUnreachable, so the
subscribe loop retires the peer from the low watermarks after the usual
grace instead of keeping its zero watermark, which held every aggregated
subscriber at the settled horizon.
- When the source filer's digest cannot be read, the S3 sink no longer sends
the entry digest as Content-MD5: it may be a SHA-256 digest the target
would reject.
- TestCheckPeerDigest skips the cases that need MD5 locally under
GODEBUG=fips140=only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg, util: tests for the per-filer digest
The Iceberg tests' fake filer serves GetFilerConfiguration, which uploads now
call to read the target filer's digest; it reports none, as a filer that
predates the setting does. TestNewContentMd5 computes a real MD5, so it skips
under GODEBUG=fips140=only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: bound each startup peer digest read with a timeout
CheckPeerDigests read each peer's configuration with the caller's context,
which at startup has no deadline, so a peer that accepted the connection but
never answered held the filer's startup. Each read now has its own
peerDigestReadTimeout (10s, inside the one-minute announce cap), after which
the peer is logged and skipped like an unreachable one.
setDigestForTest restores the previous digest setting instead of the default.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util, s3, filer: one-shot digests for data held in memory
Md5For hashes with md5.Sum or sha256.Sum256 instead of writing into a
hash.Hash, and the Content-MD5 checks of S3 directory markers and of filer
uploads saved inside the filer use BodyMd5Of on the bytes they already hold.
Streaming uploads keep their io.TeeReader.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: hash Content-MD5 on the upload's digest hash, not on its body
teeContentMd5 wrapped the request body in a TeeReader before
uploadRequestToChunks. CodeQL's go/reflected-xss query follows the body
from r.Body through the chunk upload to upload_content.go's
w.Write(prepared.data), which it resolves to the response-writer
wrappers in s3vectors, s3tables, webdav and server/common.go. Those
flows exist on master from other sources (extract, tagging, the
multipart POST); the wrapped body put them through lines this PR
changed, so CodeQL reported six of them as new.
newUploadHash now builds the digest hash that uploadReaderToChunks and
the inline-append paths already tee the body into, and adds the
separate MD5 there; uploadBodyMd5 reads it back for the check. The body
reaches uploadRequestToChunks as on master. Behaviour is unchanged:
under digest sha256 with MD5 available, Content-MD5 is checked against
the body's MD5, including empty and inline appends.
Checked with CodeQL 2.27.6 (go-queries 1.6.16, ReflectedXss.ql) on this
tree: no flow of the nine reflected-XSS results passes a changed line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* replication: keep the ReadFilerSignature name and return the digest with it
Renaming it to ReadFilerSignatureAndDigest left its other callers with an
undefined function. Keep the name and add the digest to what it returns.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: keep HashToInt32 off the digest mode
HashToInt32 names things that processes derive on their own, such as a
mount's local socket path and MQ partition key hashes. weed mount adopts
a -digest=sha256 filer's digest before it names its socket, while
weed shell mount.configure keeps md5 and dialed a different socket.
Follow GODEBUG only, as before the digest setting.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.meta.backup: wait for the source filer's digest instead of exiting
A backup with a saved offset used to start its stream loop and retry
until the source filer answered. Reading the digest first made it exit
when started before the filer. Retry the read; exit only when the
digest is refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
|
||
|
|
1ddc01d93f |
filer: match the read-only rule on the entry path a write lands on (#12969)
* filer: check the read-only rule on the path a POST or PUT writes A write to an existing directory without a trailing slash stores the entry under it (the multipart file name, or the base name on PUT), but the read-only rule was only matched on the request path, so a rule on the directory's slash-terminated prefix did not apply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: check the read-only rule on the copy destination entry Copying into an existing directory stores the entry under it, so match the read-only rule on that final path rather than only the request path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: check the read-only rule on the path saveMetaData persists saveMetaData resolves the target path with its own directory lookup, so a directory created after the early check could still route the entry under a read-only prefix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
79ddcb49e6 |
filer: send a delete that misses locally to the write owner (#12967)
* filer: record which peers share this filer's store Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: send a delete that misses locally to the write owner Exclusive and conditional creates are stored on the path's write owner. With separate filer stores, a delete sent to another filer before it has replayed the create found nothing, reported success, and left the entry on the owner, from where it replicated back. Such a delete now goes to the owner, unless the owner runs on this filer's store. A forwarded delete is applied only by the filer its own ring names as the owner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: delete a directory marker on its write owner The marker is read on the key's write owner, but the delete went through the connected filer. When the marker still has children, the filer refuses the delete and the marker is demoted by a lookup and an update on that same client. A connected filer that has not caught up with the owner misses the marker there and reports success, so the owner keeps listing the key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: also delete a directory marker on its prior owner While a ring change is in its cooling-off window, the routed read can find the marker on the key's prior owner before it reaches the new one. The delete went only to the new owner, so a nonempty marker was demoted on a filer that did not have it, and the prior owner kept listing the key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: check a directory marker on the prior owner before deleting it there The prior owner's delete ran unchecked and through the failover walk. When the new owner held an empty marker and the prior owner already held the object without the slash, the delete removed that object's data. And when the prior owner could not be reached, another filer reported the delete done while the marker stayed on the prior owner. The prior owner's entry is now read on that filer and judged like the routed one before anything is deleted, and its delete runs on that filer only. A prior owner that cannot be read fails the delete for the client to retry, which lasts at most the ring's cooling-off window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: probe a marker's prior owner when its write owner misses A miss on the write owner returned success before the prior owner was checked, so an unreachable prior owner that still held the marker left it in place behind a reported delete. The miss now falls through to the prior-owner probe, which fails the delete when that filer cannot be read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: check the entry a marker delete removes on the filer it runs on The read that decides the delete can be answered by another filer than the delete: the owner write walk fails over when the owner's channel does not come up. Each delete now reads its filer's own entry first and leaves an entry holding uploaded data alone, as the routed read already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: send no marker delete to a filer that misses the marker A filer that misses passes the delete on to the key's write owner, which applies it without the marker checks and may hold uploaded data under the key. The delete now runs only where the entry was checked; a miss on an entry the read found fails the delete for the client to retry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: leave the object without the slash alone when deleting its marker A marker delete removed the entry unless it carried chunks or remote data, so the object "dir" stored inline, or empty and known only by its promotion mark, went with a delete of "dir/". A plain file or a prefix object holds the key without the slash, as reads already treat it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
800d80ed51 |
remote/s3: WEED_REMOTE_S3_CREDENTIALS=workload, the workload's identity only (#12939)
* remote/s3: WEED_REMOTE_S3_CREDENTIALS=workload, the workload's identity only A remote of type s3 with no access key and no secret takes its credentials from the SDK default chain, which looks at AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY first. A SeaweedFS process often holds keys of its own there: `weed mini` and `weed server -s3` read their initial S3 identity from those variables. On EC2, a remote mounted on an Amazon S3 bucket with the instance's role (no keys) therefore signs with the server's local identity, and every call answers InvalidAccessKeyId, while a filer.remote.sync of the same remote, started without those variables, works with the role. WEED_REMOTE_S3_CREDENTIALS=workload makes such a remote take the AWS workload's identity alone: web identity when AWS_WEB_IDENTITY_TOKEN_FILE and AWS_ROLE_ARN name one (EKS IRSA), then the ECS/EKS container credentials endpoint or the EC2 instance metadata service, on an unguarded HTTP client as the default-chain path already does. Environment keys and shared credentials files are never read. Unset, nothing changes. Keys in the configuration win; half a key pair and an unknown value are refused; other S3-compatible types are not affected. The volume server's client cache key includes the variables that choose the source. * remote/s3: a configured web identity has no instance-role fallback With AWS_WEB_IDENTITY_TOKEN_FILE and AWS_ROLE_ARN both set, a failed token read or role exchange fell through the chain to the container endpoint or IMDS, so requests were signed with the node's role. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * remote/s3: the workload credential session reads no shared files SharedConfigDisable still loads the shared credentials file, so a selected AWS_PROFILE whose role_arn lives there failed every workload client build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * remote/s3: exchange the web identity in the workload's region The credential session took the bucket's region, so with regional STS a pod whose only reachable STS endpoint is its own region could not sign for a bucket in another one. AWS_REGION/AWS_DEFAULT_REGION win; the bucket's region remains the fallback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: a container authorization token change rebuilds the guarded client The container credential provider captures AWS_CONTAINER_AUTHORIZATION_TOKEN and its _FILE path when it is built. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * remote/s3: the workload's web identity uses the regional STS endpoint SDK v1 still defaults to the legacy global endpoint for most regions, so a pod that reaches only its regional STS endpoint got no credentials. An explicit AWS_STS_REGIONAL_ENDPOINTS keeps its say. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: a workload region or STS endpoint mode change rebuilds the guarded client Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * remote/s3: a workload-mode storage session reads no shared files either A selected profile the SDK rejects still failed the storage session even though it carries the workload's credentials. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: hash AWS_ROLE_SESSION_NAME into the guarded credentials version Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: an IMDS endpoint or mode change rebuilds the guarded client Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: a keyed s3 remote's guarded version follows the credentials mode too Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: hash every AWS_* variable into a default-chain remote's guarded version Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
dbbf2907a6 |
webdav: refuse to delete, move or overwrite entries under Object Lock or WORM (#12959)
* webdav: refuse to delete entries under Object Lock or WORM DELETE removed versions under legal hold or retention and WORM files that the S3 API and the filer HTTP API refuse to delete. Check the entry, and for a collection everything below it, then pin the delete to the Object Lock state that was checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: refuse to move entries under Object Lock or WORM MOVE could rename a locked version or WORM file away, move a directory holding them, or replace a protected target. Check the source, a source directory's contents and the target before the rename. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: refuse to overwrite entries under Object Lock or WORM PUT and COPY replaced a locked or WORM file with a fresh entry, dropping its content and its lock. Check an existing file before creating over it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: pin an upload's final update to the Object Lock state it read An upload writes the whole entry back when it closes. A hold or retention set on the new object while the upload was buffering would be dropped, so the filer now refuses the update if that state changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: recheck an upload's target when it commits instead of pinning it The precondition on the final update sent it to the path's write owner, while the placeholder create stayed on the connected filer. With separate filer stores the owner could miss the placeholder and refuse the update, leaving an empty file. The upload now rechecks the target right before the update, as the SFTP upload does, and the update stays local. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: share the WORM retention and subtree checks FilerConf.WormEnforced and IntersectsWorm replace the copies in the filer server and mount; ReadFilerConfFromClient reads filer.conf over a filer client. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp, webdav: use the shared Object Lock and WORM helpers Both servers now call FilerConf.WormEnforced, IntersectsWorm, ReadFilerConfFromClient and s3_objectlock.ObjectLockState instead of keeping their own copies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
1f1d6d057b |
webdav: optional Basic Auth; mini keeps unauthenticated WebDAV on loopback (#12956)
* webdav: optional HTTP Basic Auth from [webdav.basic_auth] WebDAV reaches the filer over gRPC, so neither the filer JWT nor the filer's Basic Auth covers it, and it had no authentication of its own. With a password set in [webdav.basic_auth], every request needs it. Without one, startup warns when the gateway listens beyond loopback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mini: bind WebDAV to loopback unless Basic Auth is set weed mini starts WebDAV by default on -ip.bind, which is 0.0.0.0, so anyone on the network could read, write and delete all bucket data even with S3 IAM on. Without [webdav.basic_auth], bind it to 127.0.0.1, as is done for the unauthenticated Admin UI. -webdav.allowInsecureBind keeps the network bind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * command: treat a bracketed IPv6 loopback as loopback -ip.bind='[::1]' failed net.ParseIP, so mini moved an unauthenticated WebDAV or Admin listener off it to 127.0.0.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security.toml: note TLS for WebDAV Basic Auth Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
0f3a9b315c |
filer: assignment tokens and chunk proofs for scoped writes (#12923)
* filer: assignment tokens and chunk proofs for scoped writes * filer: tighten scoped chunk identities and write boundaries * filer: apply gRPC key removal on config reload * filer: prevent scoped chunk alias and remote append data loss * filer: guard scoped writes across stored data representations * filer: preserve lazy scoped admission lookups * filer: avoid summing chunk counts for map capacity * filer: keep a scoped assign in its path's collection A scoped token could name another bucket's collection in AssignVolume and upload chunks there, charging that bucket's quota and losing them when that collection is deleted. A scoped caller now gets the collection its path resolves to; naming a different one is refused before the master call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: rotate gRPC keys and bind chunk proofs to collections --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
9fc8a6aec2 |
mount: read SSE-S3 objects through the S3 gateway (#12909)
* mount: read SSE-S3 objects through an authenticated S3 gateway * mount: check each comma-joined mount option against -sseS3ReadEndpoint Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: read a mounted version file by its object key and version id Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: read a current null-version object without s3:GetObjectVersion Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: declare -sseS3ReadEndpoint with the other mount options so weed fuse accepts it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: require the canonical bucket path as the root of an SSE-S3 read mount Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: fall back to the null version when the current object is another version Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * master: list the S3 endpoint each S3 gateway advertises Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: advertise the gateway's S3 endpoint to the master Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: find the S3 gateway through the masters instead of -sseS3ReadEndpoint -sseS3Read turns gateway reads on. The reader lists the S3 endpoints the filer's masters have registered, prefers HTTPS, and picks another gateway when the current one cannot be reached. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: retry an unreachable S3 gateway read on a different gateway Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: warn when -sseS3Read falls back to a plain-HTTP gateway Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: do not retry an unreachable HTTPS gateway over plain HTTP Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: tell HTTPS gateways apart by the parsed URL scheme An S3 gateway advertised as HTTPS://host lost the HTTPS preference and the plain-HTTP fallback guard, since the check matched the raw string. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
89d5192831 |
filer: guard entry updates against rename/delete races (TiKV, FoundationDB) (#12918)
* filer: run an entry update again when a rename or delete of it commits meanwhile
UpdateEntry reads the entry, checks its preconditions against it, then
writes. The path lock keeps the two together only against writers of that
path on that filer. A rename or a delete sent to another filer does not
take it, and on any filer a rename or recursive delete of a directory above
the entry moves and removes what is below it unlocked. One that committed
between the read and the write had the write store the entry again at the
path it had left, and the update returned success: the entry back under a
directory that is gone, two names sharing chunks, or a file back after its
unlink returned.
Where the store refuses a conflicting commit, the read, the checks and the
write now run in one store transaction. The rename or delete wrote the
entry's key after it began, so the commit is refused with
ErrTransactionConflict and the update runs again, up to five times with
the rename's back-off, and answers from what is there now.
- filer.ConflictRefusingStore is how a store says so. TiKV does. Other
stores, and entries in a path-specific store, run once without a
transaction, as before.
- A refused run gives up its commit stamp and deletes the manifest chunks
it folded the request's chunks into.
- Chunk deletion and the metadata event come after the commit, in the
order they had.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* filer: commit what an update's lookup removed, give up a failed run's manifests
From the review of
|
||
|
|
430ca2b585 |
filer: path- and method-scoped gRPC tokens (scope enforcement, fail closed) (#12904)
* filer: path- and method-scoped tokens on the filesystem gRPC service * filer: close scoped admission and compatibility gaps * filer: test subscription key ambiguity and retained write success * filer: assert verified peer chains survive subscription fallback * filer: keep a hard link's count and chunks together under a scoped token A scoped write may keep a hard link the target already has, but the link count it sends was stored as is, and its chunks could stay on the name with the link dropped. Either let a scoped token delete its own name and take the chunks of a name outside its grants with it: the forged count reaches zero, or the detached name owns the shared chunks. The handler recheck now refuses a scoped write that changes a stored link's count or keeps its chunks without the link. Dropping the link together with the data, and appending to a linked file, are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: leave subscriptions with a non-scope bearer to the existing verifier The stream interceptor refused a SubscribeMetadata or SubscribeLocalMetadata call whose bearer does not verify under the filer key unless the bearer was a subscription token, and it checked that token with the peer stripped. With no subscription key, or on an mTLS peer, the existing verifier admits such a call, so filer.sync sending another cluster's admin token stopped. When the bearer is no filer scope, the subscription verifier now decides on the original context, as before scoped tokens. A scoped token still reaches the refusal for scoped subscriptions, and malformed metadata is still refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: refuse scoped writes that would make ancestors outside the grant A scoped create, append or rename checked only its target. The filer then creates the target's missing ancestors up to the first one it finds, and turns that one into a directory if it is a file, dropping its ttl. A token granted /data/proj/ws could so promote the file /data/proj, or create /q and /q/r for a grant /q/r/ws. The scope now walks the same ancestors before admitting the write and refuses one outside the write grants that is missing or not a directory. A create with skip_check_parent_directory makes no ancestors and is not walked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: require write grants for scoped lock mutations * filer: document scoped signatures and read-only token upgrades * filer: enforce WORM retention for scoped mutations * filer: refuse scoped writes through shared hard links * filer: drop series notes from scope comments Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: refuse scoped subtree mutations across WORM rules --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
548d8f1b42 |
weed-worker: take the cluster from admin, need only --admin (#12905)
* master, s3: an S3 gateway advertises its Lance Namespace port The gateway registers with the master already; it now says which port its Lance Namespace listens on, and ListClusterNodes returns it, so admin can tell workers where the catalog is instead of each deployment configuring it. * admin: tell workers where the Lance Namespace is Each S3 gateway that serves a Lance Namespace is now in the cluster context admin sends with every request, and a preview request carries the context too, so a worker can be pointed at admin alone. * seaweed-worker: take the filers and the Lance Namespace from admin Admin names both with every request, as it does for the Go worker, so weed-worker needs only --admin. --namespace is used when admin names no namespace, as an admin or gateways from before they could do so name none. --masters and --filer-group are accepted and ignored; the filer group is the one the filers report. * helm: weed-worker needs only the admin address The Lance container no longer derives a namespace URL or passes the masters and filer group; worker.namespaceUrl, when set, is the worker's fallback. * s3: advertise the Lance port only once its listener has bound A gateway whose Lance port was taken kept advertising it, so workers that picked that gateway sent every Lance request to a port nobody served. The listener now binds before the master registration, and the port reaches the master only when the bind succeeded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: stop waiting for the cluster context at the caller's deadline The admin provider builds the context with context.Background(), so a master outage held a preview, which now loads the context before it is sent, past its own deadline. Loading the context now returns when the caller's context ends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * helm: keep giving the Lance worker its masters, group and namespace A worker image pinned to 4.55 or older needs the masters and the namespace and exits without them, and a 4.56 worker under an older admin needs the namespace. The chart now passes all three through the environment, which a 4.56 worker reads only when admin names nothing, and the namespace again defaults to the S3 service's Lance port. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * helm: give admin the filer group Admin lists filers and S3 gateways from its own group, and the Lance worker now takes its filers from admin, so with filer.filerGroup set the worker had no filers. Admin now gets the group; an -filerGroup in admin.extraArgs still wins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-worker: drop --namespace, --masters and --filer-group Admin names the namespace and the filers with every request, so the worker takes them from there alone. Handlers and the preview hold the admin-fed cluster, which also carries the signing key. The live tests get the filer through WEED_FILER and feed it to the worker as admin would. * helm: drop worker.namespaceUrl A worker from 4.56 takes the namespace from admin and has no option for it, so the value could only reach a pinned older image; the environment still gives one the S3 service's namespace, masters and filer group. * seaweed-worker: keep the last known namespaces while admin lists none When a master call fails, admin still sends its cached filers but no S3 gateways. With no --namespace fallback left, that emptied the worker's namespaces and failed every Lance job until the master answered again, though the gateways serve the namespace without it. The namespaces are now kept like the filers are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * helm: run the Lance container for the filer's S3 gateway and an external admin The container was left out whenever the chart's own S3 gateway served no Lance namespace. A filer's embedded gateway serves one too, and an external admin names its cluster's, so both now get it; the namespace variable for a pinned older worker is set only when the chart's gateway serves one. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
64a64ca75b |
volume, seaweed-volume: an EC shard copy can require a disk type (#12901)
* volume_server.proto: let an EC shard copy name the target disk type Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: an EC shard copy that names a disk type lands only on that medium With disk_id 0 the copy auto-selects a disk, and the disk that already holds the volume or its index wins regardless of medium. A move onto an empty disk of another medium therefore landed beside the existing copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: EC shard moves pass the target disk type to the copy ec.balance and the ec_balance worker plan a move onto disks of one type, but the copy only named a disk id, and the master reports 0 (auto-select) for a disk that holds nothing yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-volume: an EC shard copy that names a disk type lands only on that medium Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: an EC blob delete records on every local copy of the volume A volume mounted on several disks of one server has one runtime per disk, each with its own deletion set, and a shard read checks the runtime of the disk holding the shard. The delete stopped at the first runtime, so a read of a shard on another disk still returned the deleted needle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-volume: an EC blob delete records on every local copy of the volume Mirrors the Go handler: each disk's runtime of the volume keeps its own deletion set, so the delete is journaled on every runtime, not the first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: a typed EC shard copy yields to the shard's file on another medium The mount walks disks in order and loads the first file of the shard it finds, so a copy placed on the requested medium while another disk still holds an unmounted file of that shard could leave the old file mounted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-volume: a typed EC shard copy yields to the shard's file on another medium Mirrors the Go selector. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: a typed shard move refused by its pinned disk lets the server pick Balancers pin the destination disk from the medium its mounted shards report, which can differ from the disk's own medium after encoding spilled onto another one. The server refuses such a disk before copying anything, so the move now retries once with the server picking a disk of the type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-volume: name the requested disk type in a pinned-disk refusal Same wording as the Go server, which movers match to retry with a server-picked disk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: an EC blob delete records on the first local copy last A retry on this server resolves the volume through its first copy, so a delete that fails on another copy left the first one tombstoned and the retry stopped there. Locate the needle on every copy first, then journal the others before the first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-volume: an EC blob delete records on the first local copy last Mirrors the Go handler: a retry on this server resolves the volume through its first runtime, so that runtime journals after the others and a failure on any other leaves it live for the retry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-volume: a local EC delete records on every local copy When this server holds the shard, the distributed delete journals locally instead of calling VolumeEcBlobDelete on itself, and that path journaled only the first runtime. Record on every runtime, the first last, as the handler does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
a2df801e6d |
filer: rename a file over a file in place on a store without transactions (#12894)
* filer: run a file rename again when the store refuses its commit TiKV refuses an optimistic transaction's commit when another writer committed one of its keys after it began. A rename's transaction moves the source key, so a concurrent write of the file, through another filer for instance, failed the rename with "move commit error: write conflict". Standalone writes run again after such a conflict since #12798, but a rename's transaction belongs to the rename, and it gave up. StreamRenameEntry also sent the rename's responses before the commit, so the client had already moved the file locally when the store refused it. - The TiKV store reports such a refusal as filer.ErrTransactionConflict. - A file rename runs its transaction again after it, up to five times; the new run reads what the other writer stored and moves that. A rename that copied or deleted a remote object on the way is not run again. - On a store whose transactions keep their writes to themselves (filer.IsolatingTransaction: SQL, TiKV), a file rename holds its stream responses until the commit: a refused rename sends none, and one that runs again sends them once. A directory rename still streams its children's responses as it moves them, which keeps the client of a long rename from timing out, and is not run again. - Every failed run releases its commit stamps and rolls back, the "is not empty" refusal included. Tests: filer_grpc_server_rename_conflict_test.go, with a store that keeps a transaction's writes until its commit and can refuse it, and tikv_store_commit_test.go (-tags tikv). On master the retry, refused-commit and remote-file tests fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: run a rename again only when its transaction covers every write With path-specific stores configured, the writes under their prefixes do not go through the default store's transaction: a parent directory a rename creates at its destination there stays when the commit is refused, and a rename run again finds it and announces only the file's move, so peers replaying the events never learn of the parent. IsolatingTransaction now holds only when no path-specific store is configured, and AtomicRenameEntry checks it too before running a rename again, as StreamRenameEntry does through its held responses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: finish a committed rename before its held responses go out StreamRenameEntry sent its held responses before the work the commit leaves (metadata events, chunk deletions, remote copies). A client that stops reading without closing the stream blocks Send on flow control, and that work then never ran. It now runs first; the responses still follow the commit. A file with a remote object no longer holds its responses: its remote copy after the commit is part of that work, and the client should not wait for it. It streams as it moves, as before, and is not run again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: rename a file over a file in place on a store without transactions A rename over an existing file deleted the target, then created the renamed entry. On a store without transactions (the Redis stores, Cassandra, MongoDB, etcd and the like) the delete shows at once, and the rename's path locks fence only the filer running the rename, so a lookup or listing through another filer could find neither name and return ENOENT; POSIX rename keeps the new path resolvable throughout. A target deleted through another filer between the rename's lookup and its delete failed the rename outright ("no entry is found in filer store"). On such a store, a plain file renamed over a plain file is now written over the target in one store write (Filer.ReplaceFileForRename, an InsertEntry, which also lists the entry on Redis and drops the target's hard link after the write). The target's chunks are still deleted after the rename, unless the target's other hard links still use them, and subscribers get the same delete-then-rename events. Stores with transactions keep delete-then-create: no other reader sees the gap, and a target that went meanwhile fails the transaction cleanly. So do setups with path-specific stores, whose stores may take an insert over an existing entry differently (a SQL store inside a transaction aborts it), and directories and entries with a remote object. filer.WithoutTransactions tells the case apart; BeginTransaction marks it next to IsolatingTransaction. Tests: filer_grpc_server_rename_inplace_test.go. On master the target goes missing after the delete, and a target deleted meanwhile fails the rename; the transaction, path-specific store, directory and hard link tests guard what stays as it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: let the store say that its transactions isolate a rename Whether a rename's responses wait for the commit, and whether it may run again, was inferred from the context BeginTransaction returned and from whether any path-specific store was configured. Neither holds up: - A store may hand back a transaction context that its writes do not use: YDB begins a table-service transaction, and its statements run through the query service outside it. A store now says so itself, through IsolatingTransactionStore, which the TiKV store implements. Any other store keeps sending a rename's responses as the entries move and does not run it again, as before this PR. - A path-specific store only matters for the paths it holds. Filer.TransactionCovers asks whether the rename's source and destination live in the default store: a rename that stays there holds its responses and may run again, and one that writes into a path-specific store does neither. A rename that may not run again still must not announce changes before its commit, so a file with a remote object holds its responses too. So that its remote copy after the commit does not delay them, the held responses go out while the rename finishes, and the call returns once both are done. A held response checks the stream's context, so a rename whose client went away before its first response is rolled back, as when the responses go out at once, instead of committed unseen. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * filer: read the target again and keep its parents when a rename writes in place The in-place write skipped what delete-then-create did on its way: - Another filer can turn the target into a directory after the rename looked it up, by storing a child under it. The delete refused a non-empty directory, while the in-place write stored the file over it and stranded the child. The target is now read again right before the write, and a directory is refused. A store without transactions has no conditional write, so this leaves the window the delete-first path has between its own read of the target and its delete. - Another filer can delete the target's directory after the lookup. CreateEntry creates missing parents after its insert, and the rename announces them before the move; the in-place write now does the same. - The in-place write also applies CreateEntry's checks of the name (length, dot segments). Tests: a target that became a directory, and a target whose directory went, both right after the rename's lookup. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * filer: the SQL stores isolate their transactions too AbstractSqlStore takes the sql.Tx its context carries for every entry call (getTxOrDB) and every KV call (kvDB, also when KV has a pool of its own), so the SQL stores built on it meet what IsolatingTransactionStore asks. A file rename on them holds its responses until the commit again, as it did before the declaration became explicit; it is never run again, since no SQL store reports ErrTransactionConflict. Bucket tables are created and dropped outside the transaction, which a file rename does not do. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * filer: write a rename in place only on a store that says its insert replaces an entry The in-place write took "the store keeps no transaction" to mean that an insert over an existing entry replaces it. That does not follow: the Tarantool store's insert is an upsert that assigns only the entry's data, so the row keeps the replaced entry's expire_at, and a file renamed over an expiring one would expire with it. A store now says so itself, through OverwritingStore: it keeps no transaction, and its InsertEntry replaces the stored entry at once and whole, with its expiry and its listing. The three Redis stores declare it: their SET replaces value and expiry, and the insert lists the name whether or not it was listed. Every other store keeps delete-then-create, as before this PR. That includes the embedded default store, where each filer has a store of its own and the rename's path locks already hide the gap. This replaces the comparison of the context BeginTransaction returns; BeginTransaction is back to what it was. Tests: for each Redis store, an InsertEntry over an expiring entry leaves the second entry, no expiry and one listing (RUN_REDIS_TESTS=1). A store that does not declare it keeps delete-then-create, with and without transactions. The in-place write over one of two hard links, and over the last one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * abstract_sql: check that a transaction's writes take its own handle sqlmock serves a pool and its transactions from one mock, so the write expectations also pass for entry writes made through store.DB. Assert that getTxOrDB and kvDB return the *sql.Tx the context carries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
2037af1a37 |
erasure_coding: report and check the encode run when verifying a shard set (#12893)
* volume: report the encode run in VolumeEcShardsInfo Go and Rust volume servers now fill EcShardConfig.encode_ts_ns from the mounted EC volume's .vif, next to the block layout they already report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * erasure_coding: keep the source when holders serve different encode runs VerifyShardsAcrossServers records each holder's encode run, and RequireAgreedEncodeRun fails when holders that report one disagree. The encoder checks it before deleting the source volume, so a shard set that only looks complete by shard ids does not replace the source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * erasure_coding: refuse a holder that reports more than one encode run A holder whose disks serve shards of different encode runs reports MixedEncodeRuns, and RequireAgreedEncodeRun fails on it even when no other holder answers or every other holder agrees on one run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: report mixed encode runs across local disks in VolumeEcShardsInfo The reply listed shards from every disk under the first disk's encode run. When the shard-bearing disks of a volume hold different nonzero runs, Go and Rust volume servers now report MixedEncodeRuns instead, so the source-deletion check sees the conflict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: refuse an EC shard copy of another encode run than the mounted one VolumeEcShardsCopy committed the copied .vif and reopened replaced shards without updating the mounted volume's encode run, so the holder kept reporting the old run while serving the new bytes. Go and Rust volume servers now stage the .vif before anything is committed and fail with FailedPrecondition when it names a nonzero run different from a run this server mounts for the volume. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: list only mounted shards of every disk in Rust VolumeEcShardsInfo The Rust reply listed every shard slot of the first disk's runtime, with unmounted slots as size-0 entries, and skipped shards mounted on other disks. Callers build each holder's shard bits from this list, so a Rust holder counted as holding shards it did not have. The reply now lists the mounted shards of every local disk, each id once, as Go does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: check the source encode run of an EC shard copy without a .vif A copy that leaves out the .vif could still replace a mounted shard with another encode run's bytes. Fetch the source .vif for the run check in every copy, and install it only when asked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: refuse to serve EC files of a volume held from two encode runs CopyFile looks each requested file up on its own, so a server that holds a volume's shards on one disk from one encode run and its .vif on another disk from a different run would hand a copier mismatched files. Refuse the copy when the .vif files of this server disagree on a nonzero run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: refuse a rebuild whose holders serve different encode runs The rebuild groups holders by volume id and collection only. When they serve two encode runs, the copied shards land beside the first run's .vif and .ecx and the rebuild regenerates from the mixed set. Before copying, ask every holder for its run and refuse unless they agree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: bound each holder query in the rebuild's encode-run check A holder that accepts the connection but never answers VolumeEcShardsInfo kept the rebuild waiting forever. Give each holder its own deadline; one that times out is skipped like an unreachable holder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: check only the rebuilder and copy sources for the encode run The rebuild copies each shard from its first listed holder. Extra copies are never read, so asking them for their run only adds servers that can stall the check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: do not copy from a source whose encode run went unchecked A copy source whose VolumeEcShardsInfo query fails or times out has an unknown run. The copy fence on the rebuilder compares a source's run with the run the rebuilder mounts, so on a rebuilder that holds none of the volume's shards nothing checks it, and its shards could join a rebuild of another run. The rebuild now skips such a source like a failed copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ec: leave holders of shards the rebuilder has out of the run check The rebuild uses a shard the rebuilder already holds and never reads its other listed holders, but the run check still asked the first of them. A stale replica listed first for such a shard refused a rebuild that would not touch it. Pick the holders to check the way prepareDataToRecover picks its copy sources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
7cc8a8a445 |
filer: run a file rename again when the store refuses its commit (#12892)
* filer: run a file rename again when the store refuses its commit TiKV refuses an optimistic transaction's commit when another writer committed one of its keys after it began. A rename's transaction moves the source key, so a concurrent write of the file, through another filer for instance, failed the rename with "move commit error: write conflict". Standalone writes run again after such a conflict since #12798, but a rename's transaction belongs to the rename, and it gave up. StreamRenameEntry also sent the rename's responses before the commit, so the client had already moved the file locally when the store refused it. - The TiKV store reports such a refusal as filer.ErrTransactionConflict. - A file rename runs its transaction again after it, up to five times; the new run reads what the other writer stored and moves that. A rename that copied or deleted a remote object on the way is not run again. - On a store whose transactions keep their writes to themselves (filer.IsolatingTransaction: SQL, TiKV), a file rename holds its stream responses until the commit: a refused rename sends none, and one that runs again sends them once. A directory rename still streams its children's responses as it moves them, which keeps the client of a long rename from timing out, and is not run again. - Every failed run releases its commit stamps and rolls back, the "is not empty" refusal included. Tests: filer_grpc_server_rename_conflict_test.go, with a store that keeps a transaction's writes until its commit and can refuse it, and tikv_store_commit_test.go (-tags tikv). On master the retry, refused-commit and remote-file tests fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: run a rename again only when its transaction covers every write With path-specific stores configured, the writes under their prefixes do not go through the default store's transaction: a parent directory a rename creates at its destination there stays when the commit is refused, and a rename run again finds it and announces only the file's move, so peers replaying the events never learn of the parent. IsolatingTransaction now holds only when no path-specific store is configured, and AtomicRenameEntry checks it too before running a rename again, as StreamRenameEntry does through its held responses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: finish a committed rename before its held responses go out StreamRenameEntry sent its held responses before the work the commit leaves (metadata events, chunk deletions, remote copies). A client that stops reading without closing the stream blocks Send on flow control, and that work then never ran. It now runs first; the responses still follow the commit. A file with a remote object no longer holds its responses: its remote copy after the commit is part of that work, and the client should not wait for it. It streams as it moves, as before, and is not run again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: let the store say that its transactions isolate a rename Whether a rename's responses wait for the commit, and whether it may run again, was inferred from the context BeginTransaction returned and from whether any path-specific store was configured. Neither holds up: - A store may hand back a transaction context that its writes do not use: YDB begins a table-service transaction, and its statements run through the query service outside it. A store now says so itself, through IsolatingTransactionStore, which the TiKV store implements. Any other store keeps sending a rename's responses as the entries move and does not run it again, as before this PR. - A path-specific store only matters for the paths it holds. Filer.TransactionCovers asks whether the rename's source and destination live in the default store: a rename that stays there holds its responses and may run again, and one that writes into a path-specific store does neither. A rename that may not run again still must not announce changes before its commit, so a file with a remote object holds its responses too. So that its remote copy after the commit does not delay them, the held responses go out while the rename finishes, and the call returns once both are done. A held response checks the stream's context, so a rename whose client went away before its first response is rolled back, as when the responses go out at once, instead of committed unseen. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * filer: the SQL stores isolate their transactions too AbstractSqlStore takes the sql.Tx its context carries for every entry call (getTxOrDB) and every KV call (kvDB, also when KV has a pool of its own), so the SQL stores built on it meet what IsolatingTransactionStore asks. A file rename on them holds its responses until the commit again, as it did before the declaration became explicit; it is never run again, since no SQL store reports ErrTransactionConflict. Bucket tables are created and dropped outside the transaction, which a file rename does not do. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * abstract_sql: check that a transaction's writes take its own handle sqlmock serves a pool and its transactions from one mock, so the write expectations also pass for entry writes made through store.DB. Assert that getTxOrDB and kvDB return the *sql.Tx the context carries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
040ff9049c |
filer: roll back a stream rename refused for a non-empty target (#12886)
* filer: roll back a stream rename refused for a non-empty target StreamRenameEntry refuses to move a directory onto a non-empty one, but returned without ending the transaction it had begun. On a SQL store (MySQL, Postgres and the stores built on them) that transaction keeps its pooled connection: it was begun under context.Background(), so database/sql never rolls it back by itself. Every such refusal holds one more connection for the life of the filer, and once connection_max_open (50 in the scaffold) are held, store calls wait for a connection that never comes back. Roll the transaction back before returning, as the function's other refusals already do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: check a stream rename's target directory inside its transaction The not-empty check listed the target under context.Background(), outside the transaction the rename had already begun. The SQLite store's main pool has a single connection, which the transaction holds, so every directory rename onto an existing directory waited for that connection forever and the filer's store stopped answering. On a bounded SQL pool, concurrent renames that each hold a transaction can wedge the same way. List through the transaction's context, as the child move already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
dda0a57584 |
filer: announce the directories a rename creates at its destination (#12880)
* filer: let a suppressing caller collect the parents it creates
Under suppressed metadata events, ensureParentDirectoryEntry creates
missing parent directories without announcing them and releases their
stamps, since the caller's own event covers only its entry.
WithCreatedParents keeps the suppression and also collects those
directories, with their stamps, so the caller can announce them once its
change commits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: announce the directories a rename creates at its destination
A rename into a path whose parents do not exist yet created them without
metadata events. A peer filer with its own store replays events into that
store and never got the new directories: it found the moved entry by path,
but listing its new parent's parent showed nothing. The rename now
publishes a create event for each new parent ahead of its own event, after
the commit, and releases their stamps if it fails.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: announce a parent a rename promotes from a file to a directory
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: announce a promoted parent as replacing the file
A parent promoted from a file to a directory was announced as a create,
so a peer whose store does not upsert refused the insert over the file
row it already held and could not move past the event. Announce the
promotion with the file as the old entry, both from a plain create and
from a rename's collected parents, so a peer replays it as a replacement.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: keep announcing a promoted parent as a create
filer.sync applies a same-path update through FilerSink.UpdateEntry, and
the destination filer refuses to turn its file into a directory, so an
event carrying the file as OldEntry stalls the sync. Ordinary writes have
always published a promotion as a create; the rename publishes the same.
This reverts commit
|
||
|
|
95a4113c1e |
volume(rs): append an EC delete outside the store lock (#12874)
* volume(rs): give the EC deletion journal its own lock The .ecj append handle and its size move behind a per-volume mutex, Go's ecjFileAccessLock, shared through an EcJournalAppender that outlives the store lock that found the volume. Closing or dropping the volume closes the journal under that lock, and the decode takes it for its catch-up passes, so an append in flight is either fully read or not at all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): append an EC delete outside the store lock VolumeEcBlobDelete and the local EC delete of the HTTP path held the store write lock through the journal append and its fsync, on a runtime worker. On a slow disk a stream of deletes kept the store write-locked, and readers queued behind the waiting writer, heartbeat collection included, until the master dropped the server. They now resolve the volume and its needle under the store read lock, then append and fsync on a blocking thread under the volume's journal lock. The decode tail is checked under that lock, which the decode takes after claiming the tail, so a delete still cannot commit behind the rebuilt index. A volume closed in between is resolved again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): share a .ecj append lock across disks holding the file Disks can mount runtimes of one volume that journal into the same .ecj, each with its own handle and journal lock. With deletes appending outside the store lock, a delete through one disk could land while another disk's rebuild folded and replaced the file, or while a new mount loaded it, and be lost or cached before its rollback. The ecj registry now hands every holder of a path one append lock. Appends take it before the disk's journal lock, a mount holds it through its tail repair and load, and a rebuild holds it through the fold and every sibling's adoption. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): roll a failed .ecj append back to the file's real length The rollback point was the handle's cached size, which misses records another disk holding the same journal appended since, so a failed sync on one disk could truncate a sibling's committed delete. Take the length from the file itself, under the path's append lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): an EC sync does not wait for a journal append in flight CopyFile syncs the EC volume under the store read lock, and the .ecj sync now took the journal lock, so it waited out a delete's fsync with the store guard held. Every committed append already syncs its own record, so skip the journal while one holds its lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): repoint sibling .ecj handles when the fold fails after the unlink A rebuild fold that removed the journal and then failed to reopen it returned before the sibling disks sharing the .ecj adopted the new file, and one sibling's failed adoption skipped the rest. A delete parked on the path lock could then append to the removed inode and be acknowledged, then lost at restart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: reopen sibling .ecj handles even when the folded mount's reopen fails RebuildEcxFile unlinks the shared journal; the sibling reopen loop ran only when the folded mount's own reopen succeeded and stopped at the first sibling error, leaving the remaining handles on the detached inode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): order the EC delete tail test on the path lock, not sleeps The delete holds the .ecj path lock exactly while it waits on the journal lock the test holds, so the store probe and the tail claim wait for it to be busy, and the commit check waits for it to be free again. A tail check taken before the journal lock now fails the test every run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: track the fold outcome without rewriting the rebuild call Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): find a folded journal's siblings by the registry's path key The sibling check compared raw .ecj paths, so a runtime reaching the same journal through a differently spelled index directory shared its append lock but was not repointed after the fold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
14631d530b |
filer: refuse a forwarded conditional write on a filer that is not its owner (#12857)
* filer: refuse a forwarded conditional write on a non-owner A filer applied any routed write a ring peer forwarded, even when its own ring named another filer as the write owner. While two filers' rings disagree (a cooling-off window closing at different times, or a filer that installed the ring without the prior snapshot), each could apply a conditional write of the same entry under its own path lock, and both callers saw success. The receiver now refuses such a forward with Unavailable carrying a NOT_WRITE_OWNER reason, so the sender can tell nothing was applied. Refusing rather than re-forwarding keeps the one-hop bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: re-route a forward the owner refused as not its own A refused forward applied nothing, and the two rings converge once a ring update reaches the lagging filer or a cooling-off window closes. The sender now routes the write again by its own ring, with backoff, until shortly after its latest window ends, and surfaces the refusal only after that. A write whose owner turns out to be this filer is applied locally. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: test forwarded conditional updates between two filers Two filers on one store, each serving gRPC with its own ring: while the receiver's ring names the sender as the owner, the forward is refused and the entry is untouched; once the receiver's cooling-off window closes, the sender's retried forward applies once and a second update with the same expectation fails its condition. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep retrying a refused forward through a new ring change The retry deadline was taken from the cooling-off window seen at the first refusal. A ring change arriving during the retries opens a new window, in which the two rings can still disagree, so the deadline is now recomputed after every refusal, capped at 15 s from the first one so a ring that keeps changing cannot hold a request indefinitely. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: surface a refused forward rather than apply it locally A caller can check the entry before routing: an HTTP append verifies its snapshot under its locks and then commits locally without a condition. Once a forward is refused, the retries wait, and if this filer's ring then names itself, a local apply would act on that stale check and could overwrite an entry replaced meanwhile. The refusal now surfaces in that case, and the caller retries the whole request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
ebd90c3a45 |
fips140=only: SHA-256 in place of MD5 and SHA-1 so the server starts and serves S3 (#12855)
* util: SHA-256 stands in for MD5 and SHA-1 under fips140=only GODEBUG=fips140=only panics on MD5 and SHA-1. NewMd5 and NewSha1 return those hashes as before, and under fips140=only SHA-256 cut to the same size, so digests keep their length. Md5, HashStringToLong and HashToInt32 use NewMd5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer stores: hash directory keys with NewMd5 and NewSha1 leveldb2, leveldb3, rocksdb and arangodb hash directory keys with MD5, tikv with SHA-1, which GODEBUG=fips140=only refuses, so the filer panicked at startup. They now use util.NewMd5 and util.NewSha1. Keys made under fips140=only differ from MD5 keys, so leveldb2 and leveldb3 mark an empty database opened under fips140=only and refuse a database whose keys are of the other kind instead of showing it empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * operation, volume: no Content-MD5 checks under fips140=only Under GODEBUG=fips140=only the uploader's digest is not an MD5, so it is no longer sent as Content-MD5, which volume servers outside that mode would reject; the digest still becomes the chunk ETag. A Go volume server in that mode keeps a client's Content-MD5 unchecked instead of panicking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api, filer: ETags and content digests with util.NewMd5 ETags, entry Md5 attributes and chunk digests now use util.Md5 and util.NewMd5, so under GODEBUG=fips140=only they are SHA-256 cut to 16 bytes instead of panicking. That digest cannot check a client's Content-MD5, so in that mode Content-MD5 is accepted unchecked, and the filer stops returning Content-MD5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api, iam, master: SHA-1 names with util.NewSha1 Multipart upload ids, IAM policy ids, the OIDC provider, audit and session revocation file names, and the master's read-only copy dir hash names with SHA-1. They now use util.NewSha1, which GODEBUG=fips140=only turns into truncated SHA-256. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * postgres, oidc, update: refuse MD5 and SHA-1 checks under fips140=only PostgreSQL md5 authentication, OIDC TLS thumbprints (SHA-1 by definition) and weed update's MD5 check of the download cannot run under GODEBUG=fips140=only. They now fail with an error saying so instead of panicking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: no empty-body MD5 when Content-MD5 is not checked Under fips140=only a bodyless signed request still reached md5.Sum(nil) before the nil check and panicked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: empty copy part ETag from the digest it stores Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: skip the native MD5 test under fips140=only Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3sink: no Content-MD5 under fips140=only The entry's Md5 attribute is truncated SHA-256 there, which an S3 destination checking Content-MD5 would reject. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iam: move OIDC provider and revocation records to this mode's name The record names hash the ARN or JTI with util.NewSha1, which differs under GODEBUG=fips140=only. On the first use of a filer, each store renames records whose name does not match the one derived from their content, so lookups, revocation checks and deletes find records written in the other mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iam: test the rename with the names each fips140 mode derives Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iam: rename a record only if it is unchanged, under its new name's lock Two processes renaming after a mode switch could both list a record; if one renamed it and the provider was then deleted, the other wrote it back. The rename is now one filer transaction locked on the new name, like the stores' conditional writes, that requires the old entry to be unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
949952f2b6 |
filer: take a hard link off only after the store dropped the name (#12853)
* filer: take a hard link off only after the store dropped the name Deleting one name of a hard-linked file took the name off the file's link count (DeleteHardLink: the shared record read, its count less one written back, in writes of their own) before the store deleted the name. When the store then refused the delete (a TiKV write conflict, a database timeout), or the filer stopped in between, the name stayed with the count already one short. Each time the delete was sent again it took one more off: a client retrying, or rm run again after the error. At zero the record went, and that delete, having read a count of one, deleted the chunks. The file's other names were left with no record and with their chunks deleted. Without a retry, the next delete of another name of the file did the same. A name now comes off the count once the store no longer holds it (FilerStoreWrapper.dropLink). A refused delete leaves the name and the count as they were, and the delete sent again takes it off once. - DeleteEntry and DeleteOneEntry delete the name, then drop its link. - InsertEntry and UpdateEntry over a name of another hard-linked file write the new entry, then drop the replaced name's link (handleUpdateToHardLinks now returns it instead of dropping it). - A recursive delete drops its hard-linked children's links after DeleteFolderChildren deleted them, not while listing them. - A link that cannot be dropped after the delete or the write is logged and fails neither (a write failed before): the count stays one too high, and the record and the chunks outlive the file's last name instead of going before it. Inside a store transaction (a rename) the order changes nothing. Tests: filer_hardlink_delete_test.go, and through the DeleteEntry handler filer_grpc_server_hardlink_delete_test.go. With the old order the refused delete, write and recursive delete each take a link off, and the delete sent again queues chunk 3,0c03 for deletion while /dir/other.txt reads it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: delete a hard-linked name's chunks only once its file's record is gone DeleteEntryMetaAndData deleted the chunks of a hard-linked name when the link count it read before the delete was one or less. Another filer can link the file under a new name in between: the count misses that name, the record, which counts it, outlives the delete, and the chunks went while the new name read them. Now the count read before must leave no other name and the file's record must be gone after the delete (lastLinkDropped); a recursive delete already asks for the record. The count stays in: one name deleted at once through two filers is taken off twice, and the record goes while another name still holds the file. When both deletes read the count before either took a link off, the count still shows that name and the chunks stay. Where the two disagree the chunks leak rather than go. Tests: TestDeleteEntryKeepsChunksOfLinkAddedMeanwhile fails with the count alone, TestDeleteEntryTwiceAtOnceKeepsChunks with the record alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: delete a recursive delete's hard-linked names one by one, as a single delete does A recursive delete listed a folder's hard-linked names, had DeleteFolderChildren delete them with the other children, and then took their links off and asked whether each record was gone. Found in review: - A store that deletes a folder's children in batches (TiKV) can fail after some of them. The names it deleted are gone, their links were never taken off, and the delete run again no longer lists them, so their counts stay high and the file's chunks are never freed. - Two filers deleting the same folder at once both take the link of each hard-linked name off. The second finds the record gone and deletes the chunks while a name outside the folder still reads them (as on master). - The listed entries, chunk lists included, were kept until the folder's children were deleted. A hard-linked child now goes as it is listed, the way a single delete takes a name (deleteLinkedName): its entry read again for the current count, the name deleted by the store, then its link taken off (dropLink), and its chunks queued only when it was the last link (lastLinkDropped: the count read left no other name and the record is gone). DeleteFolderChildren takes the other children. Names of one file in two folders of the tree still free the chunks once, with the last of them. The link of a hard-linked child now comes off whether or not the delete removes data, as it already did for a single delete. OnHardLinkIdsFunc and maybeDeleteHardLinks, which took links off only with the data, are gone. Tests: TestRecursiveDeleteFailingAfterItsLinkedChildTookItsLinkOff and TestRecursiveDeletesAtOnceKeepChunksOfANameOutside fail with the previous commit; the latter also fails when deleteLinkedName asks for the record alone. TestRecursiveDeleteOfEveryNameDeletesChunksOnce covers the names of one file in two folders of the tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: delete a recursive delete's last-link chunks as the link goes deleteLinkedName queued the chunks of a file whose last link it took off with the folder's other chunks, which are deleted only once the whole folder delete has succeeded. When a later child, a listing or DeleteFolderChildren failed, the delete returned first and those chunks stayed for good: their name and record were gone, so no retry could find them. Found in review. They are now deleted when the link goes, through DeleteChunks with the child's path, as a single delete deletes them. Test: TestRecursiveDeleteFailingAfterALastLinkWentDeletesItsChunks fails with the previous commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: free a swept hard-linked child's chunks only when its last link went The replay sweep freed a hard-linked child's chunks once the shared record was gone. One name deleted at the same time through another filer takes the link off twice, so the record goes while another name still reads the file. Use lastLinkDropped with the count read under the child's lock, as the single and recursive deletes do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: test store hands out a copy of an entry, as a real store does Returning the stored entry let a later lookup overwrite the link count an earlier lookup handed to its caller. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: look a hard-linked name up again before taking its link off A delete read the name, and another filer deleted the same name and took its link off before this delete read the count. The count then already lacked the name, the second delete took the link off again, the record went with another name left, and the chunks were deleted. A hard-linked name is now deleted through DeleteEntry, which looks the name up after the count was read and skips the link when the name is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: report a failed lookup from a store delete instead of success DeleteEntry took any lookup error for a name already gone, so the delete reported success, the name stayed, and the caller sent a delete event. Only a missing name is a no-op now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
3bc6161401 |
helm: opt-in HTTPS for the volume servers' data port (#12843)
* helm: render volume server HTTPS in security.toml global.seaweedfs.volumeHttps.enabled sets [https.volume] to the volume certificate and turns on [https.client] with the client certificate and the chart CA, so the volume data port is no longer plaintext under enableSecurity. The option fails without enableSecurity. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * helm: add the volume service names to the volume certificate for HTTPS Volume servers register as <pod>.<volume service>.<namespace>, and HTTPS clients verify that name, which none of the certificate's wildcards cover. With volume HTTPS on, the certificate also lists every volume group's service. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * helm: probe volume servers over HTTPS when they serve it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * helm: reject volume HTTPS for the all-in-one deployment Its volume server registers by pod IP, so HTTPS clients could not verify the volume certificate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * helm CI: check the volume server HTTPS rendering and its guards Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * helm: document volume server HTTPS Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: copy chunks for cp.from through the shared HTTP client The copy built a bare client and plain http:// chunk URLs, so with [https.client] on it could not read from or write to HTTPS volume servers ("source returned status 400"). Use the global client's transport and redirect policy, and normalize the source and destination URLs to its scheme. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * helm: restart every security.toml reader when volume HTTPS is toggled security.toml is mounted with subPath and read once at startup, so on an upgrade that turns volume HTTPS on, the volume servers restarted with TLS while filer, S3 and the other clients kept speaking plain HTTP. A checksum/volume-https pod annotation, rendered only while the option is on, rolls them all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * helm CI: check the volume HTTPS rollout annotation Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * master: forward to the leader with the masters' own HTTP scheme A follower took the scheme from [https.client], so with HTTPS clients toward volume servers and plain-HTTP masters every forwarded request (/dir/assign, /dir/status, the UI) failed with 502 "first record does not look like a TLS handshake". Masters share one [https.master] setting, so use HTTPS exactly when this master serves it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * helm: update the volume HTTPS caveats now that masters forward correctly Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: send a read token on the cp.from source chunk GET With jwt.signing.read set, volume servers refuse unsigned reads, so cp.from of a chunked file failed with "source returned status 401". Mint a read token for the chunk on each source attempt, the same way the filer's own reads do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume (rust): look up volume locations over the master's gRPC port The lookup used the master's HTTP /dir/lookup with the [https.client] scheme, so with HTTPS volume servers and plain-HTTP masters every replicated write, proxied read, remote chunk read and batch delete failed. Go asks the master's LookupVolume over gRPC; do the same, over one reused channel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume (rust): bound the whole master dial in lookup_volume connect_channel's connect timeout covers only the TCP connect, so a master that accepted the connection and stalled in the TLS handshake held every replicated write, proxied read and remote chunk read that needed a lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
865a7bd988 |
filer: commit an HTTP append on a non-owner through the entry's owner (#12849)
* filer: commit an HTTP append on a non-owner through the entry's owner An HTTP append or offset write re-read the entry under its path lock and cluster lock and then committed with an unconditional upsert. The path lock is per process and the cluster lock is a lease, so with several filers on one store a write landing between the re-read and the upsert was overwritten although both requests were acknowledged. A filer that is not the entry's write owner now sends the commit to the owner as a CreateEntry conditioned on the entry it read (IF_ENTRY_EQUAL, absent when there was none), evaluated under the owner's path lock. The owner keeps committing locally under that same lock. A failed condition refuses the append as a changed entry; any other routed error keeps the uploaded chunks the stored entry references. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: test an HTTP append racing another filer's append Two filers on one store share a two-member ring. An append on the non-owner gets another filer's append injected at the store after each of its reads of the entry in turn; it must either keep both appends or be refused. Without the routed conditional commit, injections after the re-read are overwritten. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep the chunks of a forwarded append whose outcome is unknown The owner may have committed before its reply was lost, and with separate per-filer stores the local lookup may not see that commit yet, so deleting the chunks it does not find can strip a committed append. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep fsync appends on the local commit A per-request fsync is a local context mark that a forwarded CreateEntry cannot carry, so the owner would store the append without flushing. Storage-rule fsync is still applied on the owner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: normalize the stored entry too when matching IF_ENTRY_EQUAL A store that keeps the entry as given (the JSON-backed ones) returns FileSize zero beside chunks, while the expected entry was normalized to the chunk extent, so an unchanged entry failed the match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: carry a create's fsync request in CreateEntryRequest The per-request fsync is a context mark on the receiving filer, so a create forwarded to another filer lost it. CreateEntry now applies the request's fsync flag to its store write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: route fsync appends to the owner with the fsync flag A fsync append on a non-owner committed locally without a condition, so it could still overwrite a write the owner committed after its re-read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: test an offset write on a store that keeps FileSize as given Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: start an append at the entry's full size A store that keeps the entry as given can return FileSize zero beside chunks, so the append chunks were placed at offset zero over the existing bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: test an append on a store that keeps FileSize as given Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
22df63ad22 |
security: accept a previous JWT signing key during rotation (#12844)
* security: verify JWTs against an optional previous signing key DecodeJwt, the admin token checks and the volume expiry classifier take previous keys to try after the current one, and Guard keeps a previous write and read key next to the current ones. Signing still uses only the current key. Callers pass no previous key yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume, filer, s3, admin: accept tokens signed with jwt.*.previous_key jwt.signing.previous_key, jwt.signing.read.previous_key, jwt.filer_signing.previous_key and jwt.filer_signing.read.previous_key (WEED_JWT_*_PREVIOUS_KEY from the environment) name a key the verifiers still accept next to the current one, and SIGHUP reloads them. Keys can then rotate without an error window: add the new key as previous everywhere, swap current and previous, then remove previous. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * scaffold: document jwt previous_key for key rotation Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): accept tokens signed with jwt.signing previous_key Mirrors the Go volume server: [jwt.signing] and [jwt.signing.read] take previous_key (WEED_JWT_SIGNING_PREVIOUS_KEY, WEED_JWT_SIGNING_READ_PREVIOUS_KEY), the guard verifies against it after the current key, and SIGHUP reloads it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume, filer, s3: drop a removed previous_key on SIGHUP LoadConfiguration merges, so a previous_key line deleted from security.toml kept verifying until a restart. Read the previous keys without the merge on reload, as the Rust volume server already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume, filer, s3: keep previous keys when a reload cannot read the file A SIGHUP that found security.toml unreadable or malformed cleared the previous keys while the merged current keys stayed. Fall back to the merged configuration then, so the keys in effect stay in effect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: IAM and metadata subscription admin checks follow the filer guard The IAM gRPC service checked the jwt.filer_signing keys read at startup, and the metadata subscription read them from the merged configuration, so adding or removing previous_key with SIGHUP did not reach them. Both now read the filer guard that Reload updates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: reload jwt keys in one place, keeping the guard's previous keys When security.toml could not be read, the reloads fell back to the merged configuration, which still holds a previous_key an earlier reload removed. Guard.ReloadSigningKeys keeps the previous keys the guard already has instead, and the volume, filer and S3 reloads share it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: take reloaded current keys from the same read as previous keys The current keys came from the merged configuration and the previous keys from a second read of the file, so a file swapped between the two reads could publish the same key as both. Take every key the fresh read sets from it; a current key the file no longer sets keeps its merged value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: worker streams read the filer admin keys as security.toml sets them Both worker stream handlers read jwt.filer_signing keys from the merged configuration. Under weed mini a reload merges the file, which keeps a previous_key the operator removed, so new streams still accepted it; a standalone admin never picked up a rotation at all. Read the keys the file sets now, falling back to the merged values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * scaffold: wait for old-key tokens to expire before clearing previous_key Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): keep the keys in effect when SIGHUP cannot read security.toml parse_security_config falls back to defaults when the file is missing or unreadable, so a SIGHUP then cleared every key and turned JWT checks off. Skip the key and whitelist update in that case, as the Go reload keeps its merged configuration and the guard's previous keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: keep every key in effect when a reload cannot read security.toml A failed read took the current keys from the merged configuration while keeping the active previous keys, so after a swapped pair the guard could publish the old key twice and reject tokens signed with the new one. The reload now leaves the keys untouched, as the Rust volume server does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: filer admin keys fall back to the last pair read, not merged values When security.toml stopped being readable, FilerAdminKeys returned the merged configuration, which still holds a previous_key the file had already dropped, so tokens signed with the retired key verified again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: STS store gates check the admin token against one key snapshot The OIDC provider and role RPCs read the reloadable admin key twice, in checkAdminAuth and in the store gate. A reload that set the key between the two reads let a call without a token pass both. The gate now takes one snapshot for the empty-key refusal and the token check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: read and cache filer admin keys under one lock Concurrent callers could store their reads out of order, so an older pair that still had previous_key could overwrite a newer one and come back when a later read of security.toml failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: unlock the filer admin key mutex on every exit of its test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
f28d101a82 |
filer, mount: fail writes to a read-only path at once, as EDQUOT (#12823)
* filer: report a read-only create in the response, not as a gRPC error CreateEntry returned a storage rule's read-only verdict (a bucket over quota) as a status-less error, which reaches clients as codes.Unknown. Clients retry Unknown like a filer outage. A mount retried the create of every new file four times (1/2/4 s) before returning EIO, so each close() on an over-quota bucket hung 7 s, git on its index.lock included. Report it the way AssignVolume already does: a successful RPC whose response carries the text and FilerError_READ_ONLY. CreateEntryWithResponse and the mount's stream path already map that code to filer_pb.ErrReadOnly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: fail a write to a read-only path at once, as EDQUOT On a read-only path (a bucket over quota), close() of a new file retried its create for 7 s and then returned EIO, and a failed chunk upload returned EIO as well. The verdict holds until the bucket is back under quota, so a retry gains nothing, and EIO names no cause. - isRetryableFilerError does not retry filer_pb.ErrReadOnly. - grpcErrorToFuseStatus, writeErrorToFuseStatus, and mkdir, symlink and link return EDQUOT for it. ENOSPC still means the cluster is out of space. - ShouldReassignUpload never reassigns on it, even when the path in the message contains "transport". - CreateEntryWithResponse and the stream path recognize the text an older filer sends ("read only: <prefix> ...", as codes.Unknown or as a bare message). The mount stops retrying even before its filer is upgraded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin, iam, shell: check a create's response, not only the RPC error A filer reports a refused create in CreateEntryResponse with a nil RPC error: an existing directory, a parent that is a file, a store error, and now a read-only path. Ten callers sent CreateEntry directly and looked only at the RPC error, so they took every refusal for success. An admin upload into a bucket that went read-only mid-upload reported success and skipped its chunk cleanup, and a session revocation that the filer refused left the session usable. They now go through filer_pb.CreateEntry, which returns the response's error as the call's error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pb, mount, operation: read a filer verdict as an answer, not a failure A filer verdict, such as a read-only path, names the path in its message. Classifiers that fall back to matching that text for words like "transport" still read a refusal of /buckets/b/transport/f as a broken network: - shouldInvalidateConnection closed the shared filer channel, failing every other RPC in flight on it. - The mount's withFilerClient retried the call for about 13 s. filer_pb.IsFilerVerdict reports whether an error carries a sentinel that a filer response code maps to. shouldInvalidateConnection keeps the channel for such an error, and also for an older filer's read-only refusal that arrives as codes.Unknown. withFilerClient no longer retries it, and an upload with RetryForever no longer loops on a read-only assignment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep the first filer's verdict when another filer is down withFilerClient walks the filer addresses and keeps the last error. When the first filer refuses a write to a read-only path and the next one is unreachable, the walk returned the Unavailable from the second, so the call was retried for 13 s and then failed without the verdict. Stop the walk at a verdict and keep that filer as the one to try first: it answered, and every filer gives the same verdict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * java client: fail a metadata write the filer refuses in its response The filer now reports a create on a read-only path in CreateEntryResponse instead of as a gRPC error. writeMeta ignored the response, so closing a zero-byte file under a read-only rule reported success without creating it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
1d7125abf2 |
filer: keep AppendToEntry's cluster lock for the whole append (#12819)
* filer: renew AppendToEntry's cluster lock while the append runs AppendToEntry took a 5 s short-lived lock and never renewed it, so an append slower than that (slow store, slow volume, GC pause) lost the lock while still running, and another filer could take it and append to the same entry concurrently, dropping one append's chunks. Use the auto-renewing lock the HTTP append path already uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: refuse an AppendToEntry commit once its cluster lock was lost A renewal can still fail, or the lock can be lost and granted again under a new generation, while the append runs; another filer may have appended in between. Check the lock and its generation right before the entry is written, fail the append so the caller retries, and drop the manifest chunks this attempt created. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * cluster: IsLocked reports a lock whose lease ran out as not held isLocked only flipped when a renewal came back rejected, a second after the reply, so a holder whose renewal stalled past the lease (a long GC pause) still read as locked while the server could hand the key to someone else. Track the lease from each grant's send time and require it in IsLocked, which the filer append paths check before committing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: hold the slow-append test past the renewing lock's first lease The renewing lock grants a 7 s lease, so a 6 s hold passed even with renewal off; wait past LiveLockTTL so only a renewal keeps the lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: say the AppendToEntry lock check is best effort Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
817338c911 |
volume.merge, volume tail receiver: apply size-0 records for existing keys as deletes (#12816)
* volume: apply a tailed size-0 record as a delete when the key exists A delete and an empty write both reach the tail receiver as a size-0 .dat record. Writing every one as a live needle turned each delete caught by volume.move's tail into a 200-empty object. Treat the record as a delete when the key already has a record on the receiver, and as an empty write otherwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * rust volume: apply a tailed size-0 record as a delete when the key exists Mirrors the Go tail receiver: a size-0 record for a key that already has a record here is a delete, otherwise an empty write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: volume.merge applies a size-0 record as a delete when the key exists The tail stream carries deletes as size-0 records, and volume.merge wrote each one to the merged copy as a live empty needle, so every delete in the volume came back as a 200-empty object on all replicas. A size-0 record for a key already written in the merged stream is now a delete on the target; for a new key it stays an empty write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: volume.merge reads a size-0 record as a delete only after its own replica's record Replicas append the same write at their own times, so a fresh empty write can reach the merge twice when the copies are further apart than the dedup window. Tracking keys across all replicas made the second copy a delete. Track, per source replica, the keys it has returned (duplicates the merge skips included): a size-0 record is a delete only when its own replica wrote the key before, which is the only way a replica appends a delete. A delete for a key the merged copy already deleted sends nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: volume.merge verification counts the deletes the merge applied Applying deletes lets a correct merge hold fewer live needles than a replica that missed a delete, and the live-count check then refused it and kept the divergent replicas. Every key live on a replica is either live or deleted in the merged copy, so compare that replica's live count with the merged live count plus the keys the merge deleted. An empty merged copy is still refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: tail receiver looks a size-0 record's key up in the needle map The receiver read the needle to decide whether a size-0 record deletes an existing key. A read reports a needle past its TTL as not found, so a delete for it was written as a live empty needle, which reads ignore TTL for. Look the key up in the needle map instead (Volume.LookupNeedle). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * rust volume: tail receiver looks a size-0 record's key up in the needle map Mirror Go: write_tailed_needle read the needle to decide whether a size-0 record deletes an existing key, and a read reports a needle past its TTL as not found, so the delete became a live empty needle. Look the key up in the needle map instead (Volume::lookup_needle). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: volume.merge keeps a merged delete when a late empty copy follows A replica that missed a delete can hold its copy of the empty write stamped after the other replica's delete. As that replica's first record for the key it was written, reviving the deleted key. A size-0 record now never revives a key the merged copy already deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: volume.merge refuses more replicas than its key history has bits Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
2382f07788 |
filer: keep a hard-linked file's chunks when one of its names is replaced (#12812)
* filer: keep a hard-linked file's chunks when one of its names is replaced Replacing one name of a hard-linked file deleted the file's chunks while its other names still pointed at them. Reads through those names then return EIO once the volumes are vacuumed; until then they only work through readDeleted. Two everyday ways to get there through a mount: - conda links an environment's files to its package cache with hard links. Python saves a __pycache__/*.pyc by writing a temporary file and renaming it over the old name, so the cache's copy loses its data. - A training script saves model.pt, hard-links it into an epoch directory and saves the next epoch by renaming a new file over model.pt. Each archived epoch loses its data. Three write paths deleted the chunks of the entry they replaced without asking whether that entry was one of several hard links: - a rename over a file: moveSelfEntry drops the target's link, then queues all of the target's chunks for deletion; - CreateEntry over an existing path (an S3 PUT, for one): the update drops the old entry's link, then deleteChunksIfNotNew deletes its chunks, and the CreateEntry handler deletes chunks its own list covers; - UpdateEntry with an entry that no longer carries the old one's link. A plain delete already keeps the chunks while HardLinkCounter > 1, and a folder delete asks hardLinkIsOrphaned. The three paths now go through Filer.KeepHardLinkedChunks, which asks after the write, once the replaced name's link is gone: the chunks stay unless the file's shared record went with it, that is, unless the replaced name was the last link. Writing the file through one of its names (an entry with the same hard link id) still deletes the chunks the write replaced, since every name reads the new content. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep hard-linked chunks from the shared record, not the replaced row A lookup that cannot read the hard link record returns the name's own row, which can lag the file. Read the record when filtering the garbage, and keep everything when it cannot be read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: test the manifest reads behind KeepHardLinkedChunks The manifest resolution moves into withoutChunksOf, which takes the lookup function, so tests can serve manifests. Chunks behind nested manifests and the manifests themselves stay, unrelated garbage is still deleted, and an unreadable manifest returns an error, on which KeepHardLinkedChunks deletes nothing. Behavior is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
2ac8db5cb4 |
filer: lock the path for plain HTTP overwrites so replaced chunks get deleted (#12801)
* filer: lock the path for plain HTTP overwrites CreateEntry looks up the entry it replaces and queues that entry's chunks for deletion. Two plain PUT/POST writes of one path could both read the same old entry, so the chunks of whichever write lost were never queued. Take the exclusive path lock around CreateEntry, as the gRPC CreateEntry already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: test concurrent HTTP overwrites queue every replaced chunk Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
8df716b728 |
volume: make a delete retry after a failed replica fan-out reach the replicas (#12797)
* http: report the status of a failed delete that has no body A replica that answers a DELETE with a bare 500 left the forwarding server reporting "[<replica>]: " with an empty reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: forward a delete retry that finds nothing here to the replicas A delete is applied locally before it is sent to the other replicas, so when the fan-out fails the client is told to retry while this replica already dropped the needle. The retry then read nothing here and answered 404 without asking the replicas, so the replica that missed the delete kept the needle for good. On a replicated volume, a plain delete that finds the needle missing or deleted now cancels a write still queued for it, as a replica delete does, and sends the delete on to the other replicas. A failed fan-out is reported as before, so the client retries until every replica agrees. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): take a replica's 404 to a forwarded delete as done A replica that no longer holds the needle answers a forwarded delete with 404. The Go server folds that into success, but the Rust server reported it as a replication failure, so a delete that only had to catch up one replica failed on the replica that was already in step. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): forward a delete retry that finds nothing here to the replicas Mirrors the Go server: on a replicated volume, a plain delete that finds the needle missing or deleted cancels a write still queued for it and sends the delete on to the other replicas, so a retry after a failed fan-out reaches the replica that kept the needle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: answer a delete whose needle read fails with 500, not 404 A replica's 404 to a forwarded delete is taken as the needle being gone there. DeleteHandler answered 404 for any failed pre-read, so a replica whose disk could not read the needle let the primary acknowledge a delete that replica never applied. Only a missing or deleted needle (or a volume this server does not hold) answers 404 now; other read errors are a 500, so the client retries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): answer a delete whose needle read fails with 500, not 404 Mirrors the Go server: a replica's 404 to a forwarded delete is taken as the needle being gone there, so only a missing or deleted needle answers 404; other read errors are a 500 and the client retries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): corrupt the needle with portable file writes in the delete read test FileExt::write_all_at is Unix-only, so the test did not build on Windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
f2acfb7be4 |
volume: serve decoded bytes for a range over a compressed needle (Go and Rust) (#12805)
* volume: serve decoded bytes for a range over a compressed needle A Range with Accept-Encoding: gzip got Content-Encoding: gzip and a slice of the compressed bytes, which a decoding client cannot read. The range is over the stored file's decoded bytes, so pass gzip through only for a whole read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * seaweed-volume: serve decoded bytes for a range over a compressed needle Mirrors the Go volume server: a Range with Accept-Encoding: gzip got Content-Encoding: gzip and a slice of the compressed bytes. Pass gzip through only for a whole read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * seaweed-volume: HEAD of a compressed needle reports the served length HEAD answered a compressed needle from its meta: the stored gzip length with no Content-Encoding, whatever the request accepted. Go reads the payload and reports what the GET would send: the decoded length, or the gzip length with Content-Encoding: gzip for a whole read that accepts gzip. Read a compressed needle in full on HEAD too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * test/volume_server: range and HEAD over a compressed needle Both volume servers serve a gzip-accepted range decoded, and HEAD reports the length the matching GET would send. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * seaweed-volume: decode every gzip member of a compressed needle Go's gzip reader reads concatenated members; GzDecoder stopped after the first, so a range over such a needle saw a shorter body and length. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |