mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
413fdf196883eda31f16d517bc66cd2d5537e732
1732
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
397a156104 |
security: a fips.mode setting that Go checks against GODEBUG and the Rust binaries apply to TLS (#13029)
* util: refuse to start when fips.mode in security.toml disagrees with GODEBUG security.toml gains [fips] mode = "off" | "on" | "strict", also settable as WEED_FIPS_MODE: one setting that states the FIPS 140-3 mode of every process in a deployment, so the Rust binaries, which do not run on the Go runtime, can follow it. Go processes keep taking their behaviour from GODEBUG=fips140 and now check it against the setting: LoadSecurityConfiguration and `weed worker` exit when "off" runs without fips140=off, "on" without fips140=on, or "strict" without fips140=only, naming the setting and the GODEBUG value it needs. An unknown value is refused; unset or empty changes nothing. Refs #12839 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * rust: fips.mode with FIPS-mode TLS in weed-volume, weed-worker and weed-vector seaweed-common gains a fips module: FipsMode resolved from fips.mode in the security.toml a binary uses, with WEED_FIPS_MODE over it. Each binary resolves it once at startup, logs it and installs the matching rustls provider as the process default, refusing to start on an unknown value or when another provider was installed first. Under "on" and "strict" the provider is aws-lc-rs filtered to the lists Go's crypto/tls applies in FIPS mode: TLS 1.3 AES-GCM suites and TLS 1.2 ECDHE AES-GCM suites (no ChaCha20-Poly1305), X25519MLKEM768, SecP256r1MLKEM768, P-256 and P-384 (no plain X25519), Go's ten signature schemes (no ML-DSA). Configurations SeaweedFS builds require the Extended Master Secret in that mode, and the volume server refuses a non-FIPS suite in tls.cipher_suites instead of falling back. sw-client installs the same provider instead of ring. Unset or "off" keeps aws-lc-rs's default provider unchanged. This is behavioural parity only: the provider still runs on the non-validated aws-lc-rs build. Refs #12839 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: refuse a fips.mode that is not a string viper's GetString turns an array or a table into "", so mode = ["strict"] under [fips] skipped the GODEBUG check while the Rust binaries refused the same file. RequireFipsMode now reads the raw value (ViperProxy.Get, under its lock) and exits when it is not a string, naming its source; an absent or empty value still means unset, and WEED_FIPS_MODE still wins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * rust: read fips.mode with the parser that reads the JWT keys seaweed_common::fips::resolve parsed security.toml with the toml crate, while the volume server reads the rest of the file with its own lenient loader. A file with [fips] mode = "on" beside an unquoted value the loader accepts resolved to off and logged "fips.mode unset", although the JWT keys from the same file were applied. Each binary now reads fips.mode with the loader it uses for everything else and hands the value to resolve: the volume server through its line parser, the worker and vector engine through their parsed Security table, which already refuses a file that is not TOML. A security.toml the volume server finds but cannot read stops startup. A missing setting is still off, and WEED_FIPS_MODE still wins. seaweed-common no longer depends on toml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sw-client: offer only FIPS signature schemes with insecure_skip_verify With https.client.insecure_skip_verify, reqwest installs its own verifier, which advertises a fixed scheme list including SHA-1 and Ed448 whatever the process provider allows. In FIPS mode the volume transport now builds its rustls configuration itself on the process provider: the server certificate and host name are not checked, as the setting asks, but handshake signatures are verified with the provider's algorithms, only its schemes are offered, and TLS 1.2 requires the Extended Master Secret. Outside FIPS mode the reqwest path is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-common: sign only with Go 1.27's FIPS schemes, allow ML-DSA The FIPS provider kept aws-lc-rs's key provider, so a FIPS-mode listener signed handshakes with whatever scheme its key and the peer agreed on, outside the list the provider verifies with. Keys now load through a provider that limits each key to the FIPS signature schemes and refuses a key that can sign none of them, such as Ed448; the volume server and the worker's gRPC TLS name the certificate and key files in that error. The lists follow Go 1.27.4, which go.mod now requires: its defaults_fips140.go allows ML-DSA-44, -65 and -87 as signature schemes and ML-DSA certificate keys (for Go's native module only), so they are allowed here as well. Go also allows MLKEM1024 but does not enable it by default, so it stays out of the key exchange list as in Go's defaults. "off" keeps the default key provider. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: skip the truncate manifest test on freebsd like its fake filer 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> |
||
|
|
e743f99bb5 |
util: keep a request's context while its handler works quietly past the idle timeout (#13040)
* util: keep a request's context while its handler works quietly past the idle timeout A request that the server works on for longer than the listener's idle timeout, without reading or writing, lets that timeout end net/http's background read: the read the server keeps waiting while a handler runs, to see a client hang up. net/http takes the failed read for the client's connection failing and cancels the connection's context, so the request in progress, and every later request on the kept-alive connection, run with a canceled context. #10212 covered a long write-only response, whose writes now extend the read deadline; an answer that has not started yet has nothing to extend it. On the S3 gateway (-idleTimeout 120 s) such requests are the ones that answer only when their work is done, e.g. a large CopyObject into a versioned bucket, which the copy keep-alive of #12862 does not cover. After one, the next requests on that connection fail within a millisecond: a ListObjectsV2 answers 500, a GetObject and a PutObject 499 ClientDisconnected while the client is still connected. The filer's HTTP listener has a 10 s idle timeout by default. PauseIdleTimeoutWhileHandling, which newHttpServer now installs next to the ConnContext hook it already sets (S3, filer, IAM and master HTTP), takes reading out of the activity timeout from the moment a request's body has been read to its end (at once when it has none) until its handler returns: the client is waiting for the answer, so a connection that carries nothing means the server is at work. Reading a body, writing an answer and waiting for the next request stay under the timeout, and a client that closes its connection still cancels the context. Over HTTP/2 the frame reader keeps no deadline while such a handler runs and gets it back when the last one returns. Tests: weed/util/net_timeout_test.go (a quiet handler over HTTP/1.1, TLS and HTTP/2, and the next request on the same connection; the same after a 1 MiB body; a stalled body, an idle connection, an idle HTTP/2 connection and a client hang-up still end as before; concurrent requests; a waiting read held by the pause and released at its end; the context loss without the wrapper) and weed/command/server_http_test.go (newHttpServer). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: serve through newHttpServer so quiet handlers keep their context weed webdav serves a util.Listener with an idle timeout (10 s by default) but built a bare http.Server, so it had neither ConnContext nor the idle timeout pause. A COPY or MOVE of a large file answers only once it is done, and like the S3 and filer handlers it then lost its context, and so did every later request on the connection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: pause the idle timeout for HTTP/1.x requests only HTTP/2 has no background read to protect: when its connection carries nothing for the timeout, the frame reader's deadline closes the connection, and no later request runs on it. That deadline is also what ends a stream whose client stopped reading, since the answer waits for flow-control credit, not on the socket, where the write deadline would end it. With the pause on HTTP/2 requests, a download whose client stopped reading held its handler and connection until the client acted, and a stream that declared content-length 0 but never ended could hold its handler the same way. Pause only HTTP/1.x requests; HTTP/2 keeps the timeout it had. Tests: TestStalledDownloadStillTimesOut over HTTP/1.1, TLS and HTTP/2 (the HTTP/2 case was still waiting after 8 s with the pause on HTTP/2) and TestOnlyHTTP1RequestsArePaused; the HTTP/2 quiet-handler cases are gone, with them the HTTP/2 subtest that flaked under -race. TestPauseUnderConcurrentRequests gets a 1 s idle timeout, so that a request waiting for its turn on a slow run does not find its connection closed. 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> |
||
|
|
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> |
||
|
|
a00dbff13b |
sftp: apply the bucket's default Object Lock retention to uploads (#13017)
* s3_objectlock: read a bucket's default retention from its entry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: give uploads into an Object Lock bucket its default retention Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: match uploads against the cleaned buckets folder Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
dcce121d95 |
weed fix.recover: recover needles past damaged .dat regions (#13002)
* feat: weed fix -verify to resync past damaged regions in .dat Plain `weed fix` walks .dat by trusting each needle header, so a damaged region in the middle loses or misindexes everything after it, and a torn or garbage tail ends up in the index and keeps the volume read-only. -verify reads every needle, checks structure and CRC32, and on a failure searches forward at needle alignment for the next verifiable needle. Each skipped region is reported as zero-fill / garbage / garbage+zeros with its length, zero windows and the fid of the needle that was hit. The index is rebuilt from verified needles only (old one kept as .idx.bak); -truncateTail cuts trailing garbage so the load-time integrity check passes, -dryRun only reports. Works with the 5BytesOffset build. * feat: add weed fix.verify, a read-only check of .dat files Runs the same needle/CRC verification and resync scan as `weed fix -verify` but never writes: no .idx rebuild, no truncation. Takes folders and/or .dat files, filters with -collection / -volumeId, prints the damaged regions (optionally to -report) and exits 0 when clean, 3 when damage was found and 1 when a file could not be verified. The scan options are shared with `weed fix -verify`. * feat: weed fix -compact, verify and compact a damaged volume in one pass -compact implies -verify. While the .dat is scanned, every verified needle gets an index entry, and from the first damaged region in the middle of the file the needle bytes are streamed into a new .cpd as well (the intact prefix before it is copied as one block). The result is a .dat without the damaged regions and an append-ordered .idx that matches it exactly, so a full volume scrub no longer complains about the .dat size. The compaction revision is bumped like a vacuum does. A volume without damage is left untouched, and damage only at the tail is just cut off in place, so neither costs a .dat copy. The old .idx is kept as .idx.bak and the old .dat as .dat.bak (-deleteOriginal removes it). The free space needed for the new .dat is checked before anything is written, a failing swap is rolled back, and progress is printed every 30s. * refactor: reuse backend, super block and throttler code in weed fix -compact - create the .cpd with backend.CreateVolumeFile and preallocate the bound of the new .dat; the result is truncated to its real length at the end - read the super block with super_block.ReadSuperBlock (also in the verifier) and write the bumped compaction revision with SuperBlock.Bytes() - throttle the .dat writes with util.WriteThrottler (-compactionMBps) - fsync the directory before and after swapping the new files in ReadSuperBlock cannot read a super block with extra data, so such volumes are rejected with its error instead of being handled by a hand-written parser. * refactor: drop helpers that duplicate existing code in weed fix -compact / fix.verify - util.FsyncDir instead of a local fsyncDir - io.NewOffsetWriter instead of a hand-written WriterAt adapter; the throttle now sits in one small writer wrapper used for both the prefix copy (via io.CopyBuffer) and the streamed needles, replacing the manual copy loop - needle.NewVolumeId instead of strconv for volume ids parsed from file names * fix: resync in weed fix -verify must not accept payload-less look-alikes After damage, a few bytes of a needle's tail followed by the next record's header could parse as a payload-less needle and be confirmed only because the file ended right after it, so a made-up key got into the index and swallowed the real delete record behind it. A payload-less candidate is now accepted without a verifiable successor only if it is a size-0 tombstone ending exactly at the end of the file (or, with a set timestamp, leaving less than a header); a set but implausible v3 timestamp rejects it. Anything else needs the next needle to verify. * test: recovery integration tests for damaged .dat heads (#5674, #12914) - zero-filled head (aligned and cut next record): all survivors indexed, region reported as zero-fill, trailing tombstone kept - plain weed fix stops at the first bad header (#12914 item 1) while -verify recovers the needles behind it - a needle rewritten after a damaged region is indexed at its newest copy - a zeroed superblock fails with an explicit unsupported-version error and fix.verify counts it as not verifiable (exit 1) - v1/v2 needle layouts verify cleanly * fix: reject a super block extra in fix -verify A super block extra describes an erasure-coded layout; the .dat behind it was re-striped into .ecXX shards and is not a plain needle file. Scanning it as one silently produced damage reports instead of telling the operator the file is out of scope. Return an explicit error instead. * fix: guard fix -verify/-compact against pending compaction commits and -dir.idx - refuse to start while a .cpc marker exists: an interrupted vacuum commit is pending and the volume server must reconcile it first (roll forward/back); writing a rebuilt .idx or new .cpd/.cpx over that decision would race it - clear a stale .cpc after a completed swap so it can never be rolled forward later (defensive; the start guard already refuses this state) - spell out in the help and print after a rebuild that the index is written next to the .dat: with a separate -dir.idx directory the .idx must be moved there and any stale .ldb dropped - tests: refusal leaves the marker and writes no .idx; a completed swap clears a marker that slipped past the guard * refactor: narrow this change to weed fix -verify Drop weed fix.verify and weed fix -compact from this change; they follow in their own pull requests. -report, -windowMB and -zeroWindow go with them: the scan uses fixed windows and prints its report to stdout. * fix: weed fix -verify: address review findings - -maxNeedleSizeMB limits only guesses made while resynchronising; a record reached at a known boundary may be as large as the file allows - a v2/v3 record whose parsed fields do not add up to its size, or a live record without data, is damage: a zero fill over the data length used to pass as an empty file because the CRC is only checked when there is data - a stamped v3 delete record found after damage stands on its own when its time is believable, not older than the last verified record and followed by zero padding, so a delete before a damaged tail is not lost - a read error while searching for the next needle fails the run instead of ending the scan and treating the rest as a garbage tail - keys whose newest record is damaged while an older copy is indexed are reported as stale-version warnings - the rebuilt index is staged as .idx.tmp and swapped in when complete; a stale .ldb next to it is removed so the volume server rebuilds it - -ignoreError reports a volume that cannot be verified and goes on - -truncateTail does not cut a tail it could not read and removes a partial tail backup - volume ids are parsed as uint32 - the test fixture stamps every record the way the volume server does * fix: weed fix -verify: prove deletes found after damage, swap the index safely - a delete record found while resynchronising must prove itself: a v3 one needs a believable time not older than the last verified record and zero padding (every v3 writer stamps deletes); a v1/v2 one needs the following records to reach data that passes its CRC, or the exact end of the file. Stray bytes in a zero-filled region used to pass as deletes of live keys. - the rebuilt index is fsynced before the swap, the previous one is kept as a hard link, and the new one replaces it in one rename, so a live .idx exists at every moment - .sdx and .rdb caches are removed with the .ldb - -verify exits non-zero when it found damage, like plain fix and -verifyCrc - with -ignoreError a file name whose volume id does not fit uint32 is reported and the batch goes on - the help and the printed hint say that a volume server prefers an .idx next to the .dat over the one in -dir.idx * fix: reject weed fix flag combinations -verify cannot honour -verify -remoteFile skipped an explicit .dat and reported success, -dryRun and -truncateTail were silently ignored without -verify, and -dryRun -ecx still rebuilt EC indexes. Check the combinations before any file is touched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: apply -volumeId before rejecting an out-of-range volume file name With -volumeId set, an unrelated file such as 4294967296.dat aborted the run before the filter could skip it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: check the data length before reading a record body in fix -verify A damaged size field at a known record boundary made the scan allocate and read a body of that size before rejecting it. Check that the data length after the header fits the record first, as the resync probe already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: accept a v1/v2 delete chain that reaches the end of the file on its last probe Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep an implausible needle timestamp out of the fix -verify resync baseline The data CRC does not cover the v3 timestamp, so a corrupted one passed and then rejected every genuine delete record found after later damage. Report it as a warning instead of using it as the lower bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: stop fix -verify on a read error at a known record boundary An EIO while reading a record was treated like damaged bytes: the scan resynchronised past the unread record and the rebuilt index dropped it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: sync the fix -verify tail backup before truncating the .dat A crash right after the truncate could persist it before the backup's data or directory entry, losing the cut bytes from both files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: let fix -verify -truncateTail retry when a tail backup already exists After a backup succeeded and the truncate failed, the next run hit the existing backup and could not get past O_EXCL. Keep the first backup and save the tail under a new name, as the index backup does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: drop stale index caches before fix -verify swaps in the new index Removing them after the rename left a window where a crash paired the new .idx with the old .ldb, whose newer LOG skips the replay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: pin fix -verify fixtures to needle version 3 -verify reads v1 to v3 records, so its fixtures should not follow the build's current needle version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: refuse fix -verify on remote-tiered volumes A remote-tiered volume is read from its remote .dat through the existing .idx, so rebuilding that index from a local .dat would point it at the wrong bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: pick a free backup name when fix -verify retries within one second backupName fell back to path.bak.<unix time> without checking it, so a second retry in the same second reused that name and the exclusive create (or the .idx hard link) failed. Add a .<n> suffix until the name is free. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: refuse fix -verify when the volume info cannot be read An unreadable or unparsable .vif may name a remote tier, so treat it like one and keep the existing index. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor: pass weed fix -verify options explicitly * feat: move weed fix -verify into a weed fix.recover command * docs: weed fix.recover help, point weed fix at it * fix: keep the volume file helpers below runFix Leaves the region between VisitNeedle and runFix as on master. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: build fix.recover fixtures at needle version 3 fix.recover reads needle versions 1 to 3, so its tests must not follow GetCurrentVersion; writeFixTestVolume now takes the version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: whitefox <whitefox@mayflower.work> 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> |
||
|
|
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> |
||
|
|
dbc64144ca |
mount: support NFS re-export file handles after inode eviction (-nfsExport) (#12979)
* mount: update go-fuse for the export support option Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: optionally retain the paths of forgotten inodes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: answer lookups of "." and ".." for file handle decoding Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: add -nfsExport to negotiate export support and retain forgotten inodes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: test file handle lookups of "." and ".." Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: fail a file handle lookup when its path now holds another file A "." lookup resolved a forgotten inode by its remembered path, so a file created at that path since was served to the old handle. Compare the entry's inode with the handle's and answer ESTALE on a mismatch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: register a file handle's inode under the table lock A "." lookup checked the file at the remembered path and then registered it with Lookup, which hands back whatever inode holds the path by then. LookupHandle takes the reference on the handle's own inode, or enters it at the path only while no other inode holds it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep a forgotten inode's retained path across a rename A rename whose source inode the kernel had already forgotten left the retained path at the old name, so its file handle failed with ESTALE. An index from retained path to inode lets MovePath move it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: register a file handle only at its current retained path A rename between resolving a forgotten inode's path and registering it moved the retained entry, yet LookupHandle still entered the old path. It now compares the path with the retained one under the table lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: drop the target a forgotten inode is renamed over Moving a forgotten inode's retained path onto a live name left the replaced inode mapped there. Once a retained entry moves, the target is taken apart as for a live source and reported as replaced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: test that a renamed path-inode file fails its file handle closed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * go.mod: use the go-fuse v2.9.5 release Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
36aea0020e |
weed fix: add -verifyCrc to index needles with damaged data as deleted (#12972)
* fix: add -verifyCrc to leave needles with damaged data out of the index weed fix reads only record headers, so a needle whose data was damaged is indexed and fails on every read. With -verifyCrc it reads each body and checks it; a needle that fails is not indexed, an older copy of its key is not brought back, and fix exits non-zero. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: read each record to verify it, so a read error fails instead of dropping it The scan passes a body buffer even when reading it failed, so -verifyCrc took bytes it never read for damage. Read the record through a handle of its own, drop it only when its bytes are corrupt, and fail the scan on any other read error. -verifyCrc needs the local .dat. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: -verifyCrc rejects a record with a size but no data A needle with no data is written with size 0, and the CRC covers only the data, so a record whose data size was zeroed parsed cleanly and skipped the CRC check. Treat it as corrupt, as the tail repair does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: index a needle that fails -verifyCrc as deleted Leaving it out of the index let loading the volume read the bytes past the last indexed needle as an interrupted append: the older copy of the key came back and the damaged record was cut. Handle it like a delete marker, so with -includeDeleted its tombstone keeps the key deleted and the loader leaves the .dat alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d6a657cd92 |
weed compact -method data: copy past an unreadable record like -method index (#12970)
* storage: resume data compaction past an unreadable record Compacting by data follows record headers through the .dat, so one corrupt header ended the scan: the compaction failed, or, when the header's size jumped past the end, every record after it was dropped. Compacting by index copies past such a record. When the scan stops on a corrupt header or jumps past live records, resume it at each live record the index places further on. A read error still fails the compaction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * storage: do not copy a record whose header size disagrees with the index A live record whose header carries a damaged size was copied with that size, and the compacted volume indexed a needle it could not read. The index records each live record's size, so a header that disagrees is damaged: skip it, and let the scan resume at the next live record. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * storage: verify a live record's body instead of comparing its size with the index Data compaction copied a record whose body failed to parse, and the size check dropped an intact record when only its index row was wrong. Read the body only for the record the index points at, drop it on the same errors -method index drops on, fail on any other read error, and keep the size the record itself carries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * storage: resume data compaction at every live record the scan did not reach The resume started past the last header the scan parsed, so a corrupt size that landed on a later valid header lost the live records it jumped over. Track the records the scan copied or dropped, resume at each live record it did not reach in .dat order, and stop a resumed scan at a record an earlier pass already handled so nothing is copied twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * command: read the compacted volume's version from its super block in tests Compaction can write a different needle version than the source volume, so parse the .cpd with the version it records instead of the current one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * storage: do not walk a run of damaged headers again on every resume A record whose header id is damaged is not marked as handled, so each resume at one of a run of such records walked the rest of the run before reaching a copied record, which is quadratic in the run length. Remember the offsets resumed scans pass, skip resuming at them, and stop a resume when it reaches one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * storage: count the resumed scans' reads in the damaged-run test The kept keys come out the same when every resume walks the rest of the run, so bound the reads made through the volume's data backend instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * storage: drop a record whose header size runs past the end of the .dat Reading such a record sized its buffer from the corrupt header: a size near 2 GiB allocated that much on 64-bit and panicked in makeslice on 32-bit. Check the record end against the file size first and drop the record as unreadable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * needle: compute ReadBytes slice bounds in int NeedleHeaderSize+size was Size arithmetic and wrapped for a damaged size near MaxInt32, so the slice panicked instead of failing the read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * needle: fail ReadNeedleBlob for a size that does not fit in an int On 32-bit a damaged size near MaxInt32 made the buffer length negative and panicked in makeslice. Return ErrorSizeInvalid instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * needle: compare DataSize bounds in uint64 On 32-bit builds int(DataSize) is negative for a damaged DataSize of 0x80000000 or more, which passes the bounds check and panics on the slice instead of returning ErrorCorrupted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
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>
|
||
|
|
e22704d25e |
mini: bind Admin and WebDAV to -ip.bind by default (#12971)
weed mini is a single-host sandbox whose other components already listen on -ip.bind without authentication. Moving the unauthenticated Admin UI and WebDAV to loopback broke setups that open them from another machine on a private network. -admin.allowInsecureBind and -webdav.allowInsecureBind now default to true; set them to false to keep an unauthenticated Admin or WebDAV on loopback. The Admin worker gRPC control plane still defaults to loopback. Claude-Session: https://claude.ai/code/session_011UpvahFvcQGAmXWpPrXZY1 |
||
|
|
07e1299f98 |
mount: add -idmap to allow ID-mapped bind mounts (#12922)
* mount: add -idmap to allow ID-mapped bind mounts FUSE allows ID-mapped mounts only for a server that announces FUSE_ALLOW_IDMAP. Once announced, the kernel sends uid and gid 0xFFFFFFFF on most requests after checking permissions itself, so the checks that read the caller treat that value as already checked. * fuse: refuse an unsupported -o idmap before starting the child The child exits on checkIdmap, but the parent waits for its readiness signal and never returns, so weed fuse -o idmap hung on macOS and FreeBSD. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: refuse -idmap on Windows instead of ignoring it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fuse: take -o defaultPermissions as the mount flag -o defaultPermissions=false was forwarded to the kernel as an unknown option, which failed the mount, and left the flag at true, so -o idmap,defaultPermissions=false passed the idmap check. 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> |
||
|
|
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> |
||
|
|
c7cf9db27c |
fix/compact: stop at records past EOF, report -ignoreError failures, clean up failed compaction (#12915)
* fix: do not index a record that runs past the end of the .dat A truncated .dat, or a header whose size points past the file end, left weed fix indexing a needle the volume cannot serve. Stop the scan at such a record instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: exit non-zero under -ignoreError when a volume fails -ignoreError kept going but always exited 0, so an empty or partial index looked like success. Record the failure in the exit status, and keep the existing .idx when the super block could not be read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * compact: remove the partial .cpd/.cpx when compaction fails A failed weed compact exited through glog.Fatalf and left a partial .cpd next to the volume. Remove both outputs and report the failure in the exit status instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: skip the end-of-file check for a volume on a remote tier The scan reads the remote object when the .vif lists one, so a retained local .dat is the wrong length to check records against. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep a key deleted when its last record is truncated Stopping before a truncated delete record left the key's earlier live record in the index, so a deleted file came back. Drop the key instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: return the .idx open error from SaveToIdx The bare return gave back the nil named result, so a failure to open the index looked like a successful save. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: exit non-zero when a record is cut off by the end of the .dat A record past EOF ends the scan like a bad header does, so report it the same way while keeping the index of the records before it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * compact: close the volume before removing a failed compaction's output Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: remove a failed .idx only after SaveToIdx opened it An open failure no longer reaches the caller's cleanup, so an existing .idx that could not be opened is left in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(s3vectors): drop the worker and CLI flags #12906 removed (#12911) * test(s3vectors): start weed-worker with only --admin weed-worker no longer accepts --namespace, --masters or --filer-group; it takes the Lance Namespace and the filers from admin. The worker jobs passed all three, so the worker exited on its arguments before registering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(s3vectors): let weed-vector-cli find the namespace through the masters weed-vector-cli dropped --namespace and looks the Lance Namespace up among the gateways the masters list, so the index job test failed on its arguments once the worker could register. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
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> |
||
|
|
a551b7c7e6 |
weed-vector: size the caches itself, drop the tuning, config-dir and CLI namespace flags (#12906)
* 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. * weed-vector: size the caches itself, and drop the tuning and config-dir flags The engine caches a quarter of the memory it may use, its cgroup limit or the machine's, split 2:4:1 between file reads, loaded indexes and table metadata as the three flags' defaults were, so a small pod is not overcommitted and a large host is used. --read-cache-mb, --index-cache-mb, --metadata-cache-mb, --nprobes and --exact-match-limit are gone, and with them the perf test's cold mode. --config-dir is gone too: weed mini passes the security.toml it finds there. * weed-vector-cli: find the Lance Namespace through the masters A table id is looked up in the namespace of an S3 gateway the masters list, so --namespace is gone; a local path still needs no cluster. * helm: weed-vector sizes its own caches vector.readCacheMB and vector.nprobes are gone with the engine's flags; an older pinned image keeps its own defaults. * weed-vector: size the caches from the process's own memory cgroup A systemd service is limited in its own group below the cgroup root, which the root's limit file does not show. The engine now reads its group from /proc/self/cgroup and takes the smallest limit of it and its ancestors. * mini: leave an explicit WEED_VECTOR_SECURITY_TOML to the engine --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
6adc9f0a21 |
mount: read chunks with filer-issued exact-file read tokens (#12800)
* mount: read chunks with filer-issued exact-file read tokens * mount: preserve read authorization across delayed lookups and hard links * mount: retain response tokens across read cache eviction * mount: keep a shared read-token lookup alive when its first caller is cancelled Token refreshes for one entry share a singleflight lookup that ran under the first caller's context. An interrupted read cancelled that lookup, so every other read of the entry waiting on it got no token, went out unauthenticated, and failed with EIO on a volume server enforcing read JWTs. Run the lookup detached from the caller (each attempt stays bounded by the filer RPC wait) and let a cancelled caller stop waiting at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: serve a cached chunk past the cache cutoff instead of fetching it The full-chunk read path consulted the chunk cache only for chunks below the cache size cutoff. Read-auth and peer-sharing mounts cache every chunk they upload, so a read-after-write of a high-offset chunk went to the volume, where a read-auth mount has no token before the entry is published. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: re-track read tokens when this mount renames an open file Writeback mounts skip their own rename event, so only the subscriber path re-tracked an open handle's chunks. After a local rename a token refresh looked up the vacated name and the read failed. The rename response, the subscriber rename and the surviving hard link now share ReadAuth.TrackHandle. 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> |
||
|
|
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> |
||
|
|
40fe40556c |
filer.meta.backup: list large etcd directories without the 3s request deadline, skip excluded subtrees (#12870)
* filer/etcd: list a directory without the request deadline etcd counts every key left in a range even when the request is limited, so one page of a directory costs time that grows with the entries after it: about 0.3 s at the start of a 4 million entry directory on an idle local etcd, against 1.6 ms near its end. The 3 s request_timeout therefore fails listings of large directories, which a long walk such as filer.meta.backup reaches page after page, with "list <dir> : context deadline exceeded". Listings keep the caller's context like DeleteFolderChildren; keepalive still ends a call to a member that stops answering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer_pb: let a TraverseDfs callback skip a directory's subtree fn returning fs.SkipDir for a directory leaves its subtree unlisted; the directory is still reported as walked, so a resumed walk passes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.meta.backup: do not walk directories the path filter leaves out The walk listed every directory and dropped excluded entries one by one, so -excludePrefixes could not keep it out of a directory: a huge or failing excluded directory was still listed page by page. A directory that is not included and has no include prefix under it is now skipped whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.meta.backup: resume outside a directory the path filter leaves out A walk saved before the filter skipped directories, or before the filter changed, can hold a position inside a directory the walk now leaves out. Resuming there entered the directory without asking the filter and listed it. The resume position moves to the topmost such directory, which a resumed walk treats as done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.meta.backup: skip the walk when the path filter leaves out its root The root of the walk is never handed to the callback, so a -filerDir the filter leaves out was still listed. Nothing under it would be backed up, so the walk now ends before it starts. 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> |
||
|
|
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> |
||
|
|
4fefe7863c |
scaffold: list every component that needs each JWT signing key (#12838)
* scaffold: list every component that needs each JWT signing key jwt.signing.read.key is not a master and volume only key: the filer, the S3 gateway, mount, webdav, sftp, filer.sync/backup, workers, admin and weed shell all sign their own volume read tokens with it. Giving the S3 gateway only the filer keys made every GET fail with 401 wrong jwt. Drop the stale note that the filer does not support read JWTs, and name the filer and weed shell as signers of the volume write key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * scaffold: name admin and workers as filer signing key users Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
3aadc0fc46 |
s3api: bound route-by-key lookups at an unreachable owner filer (#12827)
* s3api: bound route-by-key lookups at an unreachable owner filer A route-by-key read (getObjectEntryRoutedByKey and the scoped .versions listing) asks the key's owner filer first, on context.Background(). When that owner sits behind a network partition that drops packets instead of refusing them, the lookup waits out gRPC's 20 s connect timeout before the failover walk asks the next filer. The owner is then skipped for only 2 s, so the next read of any key it owns dials it again and waits another 20 s. With the ring spread over two data centers, about half the keys stall every ~22 s for as long as the partition lasts (#12826). - The owner's attempt in the walk now gets a deadline, -s3.routedLookupTimeout (default 1s), when the owner is not the gateway's current filer. Past it the walk moves on to the next filer, as for any transport error, and flags the owner unreachable. The current filer and every later attempt stay unbounded, so a slow but reachable local filer still answers; 0 restores the unbounded lookup. The prior- owner probe during a ring rebalance gets the same bound. - The skip time of a failed owner is now -s3.unreachableOwnerTTL (default 2s, unchanged). Deployments that can see dropped-packet partitions can raise it so each owner is retried less often. - The S3 gateway's volume location lookups take -s3.volumeLookupTimeout per filer (default 5s, the FilerClient default, unchanged), so a vidMap miss need not wait 5 s per unreachable filer. The flags exist on weed s3 (without the s3. prefix), weed filer, weed server and weed mini. Tests (s3api_object_routed_read_deadline_test.go): an owner that never answers costs a read the deadline and is skipped by the next read (hangs without the change); with the deadline 0 a slow owner is still waited for; an owner that is the current filer is not timed out; a slow filer later in the walk is waited for; the scoped listing fails over at the deadline; the skip TTL honours the option and the default. * s3api: bound a routed listing only until the owner's first message The routed-lookup deadline covered the whole .versions stream at a remote owner. A reachable owner whose listing keeps streaming past it (a store scan trailing its first rows) was cut off mid-stream, and the failover walk refuses to replay a stream that already delivered entries, while listRetry does not retry DeadlineExceeded, so the listing failed outright where it used to succeed. Lift the deadline once the stream delivers its first message; an owner that never answers still fails over at it. 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> |
||
|
|
89457b1387 |
vector: indexed metadata keys, worker job, table state and shell (#12820)
* vector: derive the indexed metadata key columns An indexed metadata key is a hidden `_mk_<n>` column of List<Utf8>: the strings an S3 `$eq` on a string matches, that is the value when it is a string or the string elements of an array, and nothing for any other type or a missing key. The field metadata names the key and its state (`building` or `ready`). The module derives the column from metadata given as JSON (the write path) or as stored (jsonb or JSON text, for a backfill), and reads the indexed keys from a schema. It lives in the worker crate so the engine and the worker share it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector: fill the indexed metadata key columns on PutVectors PutVectors builds its batch against the table's current schema. Once a table has indexed metadata key columns, the three-column batch no longer matches that schema and the write fails. Fill each `_mk_*` column the schema has from the row's metadata, whatever the key's state; a column the engine does not know still fails the request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector: answer string $eq and $in on a ready indexed key from its column The gateway renders a string `$eq` or `$in` on a key as an OR of `json_extract(metadata, P) = '"v"'` (or IN) and `json_array_contains(metadata, P, '"v"')` over the same values. On the parsed filter, a top-level conjunct of that shape on a key whose column is `ready` becomes `array_has` / `array_has_any` on the column, which its LABEL_LIST index answers. The two halves must name the same key and the same strings, the scalar half in the text json_extract returns for them; anything else, including `$ne`, `$nin`, `$exists`, numbers and booleans, stays on the JSON path, and the other conjuncts still apply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector: score few indexed matches exactly, per scope With a ready indexed key in the filter, `ann` first counts the rows of its scope that the key's conjuncts match, through the scalar index. When they are at most the limit it scores them exactly over that scope, the way the short-result fallback does; above it, the vector index searches with the indexed prefilter, and the fallback still applies. The scope is the one `exact_in_scope` scores, so per-scope exact answers merge into the global exact top-k. The limit is `Query::exact_match_limit` (None takes 256; 0 never counts), set by the engine's --exact-match-limit (WEED_VECTOR_EXACT_MATCH_LIMIT). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector: count filtered queries by metadata key For each index, the engine counts its QueryVectors calls by the metadata keys of the parsed filter, with their total latency and the operand types each key was compared with, over the last hour in 5-minute buckets. At most 512 indexes and 32 keys per index are kept (an idle key makes room; otherwise the index is marked truncated), and the stats are not exported as metrics labels. The new FilterStats RPC returns an index's stats; the gateway's discovery client forwards it like the other calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector: report the metadata columns capability in gRPC health An engine whose writes fill the indexed metadata key columns reports the gRPC health service `weed.vector.capability.metadata_columns` as serving, so an operator action can refuse to index a key while an older engine could still write the table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector: expire filter stats' operand kinds and truncation with the window The operand kinds a key was compared with, and the mark that a key went uncounted, outlived the queries that set them. Keep the kinds per 5-minute bucket and the truncation as the bucket it last happened in, so both leave the hour window with the counts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector: fill indexed key columns a write left empty racing their add A PutVectors that opened the table before an indexed key's column was added, and commits after the add, is rebased by Lance onto the wider schema: it commits, and the rows it wrote hold NULL in the new column, so the column's index misses them (reproduced in the test: 100 of 150 rows). After its commit, PutVectors now looks for indexed-key columns the batch did not carry, reads those of its keys whose column is still NULL, derives the values from their stored metadata and patches just those columns with a partial-schema merge that updates only rows still NULL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector: keep filter stats' truncation mark at the later bucket record() reads the clock before it takes the lock, so a call that waited on the lock across a bucket boundary could move the truncation mark (and the index's last-used bucket) back to its earlier bucket, and the mark then left the window one bucket early. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * vector: derive a raced write's indexed key columns from current metadata A PutVectors that opened the table before an indexed key's column was added is retried by Lance against the wider schema: rows it inserts hold NULL there, and rows it updates keep the value derived from their old metadata, which the NULL-only heal never looked at. The heal now derives the columns for all of the write's keys. Its merge also ran with Lance's retry, which joins the values derived before the conflict onto the rows a later write of the same keys left. It now fails on a conflict and is redone from the latest version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * vector: check the raced write's keys keep the later write's rows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * vector worker: the indexed metadata key lifecycle on the Lance table A key's whole state lives in the table: a request is schema metadata (`weed:metadata_key_request:<key>`), the key's `_mk_<n>` column carries `building`, `ready` or `off`, and its LABEL_LIST index is named `_mk_<n>_idx`. - request / request_removal: the cheap metadata-only steps an operator action takes. Removal of a column sets it off at once. - add_column computes the column for every row with add_columns. - finish fills rows still NULL (a write that raced the add and died before filling them), builds the first segments, fills again, marks the key ready and clears the request. - index_fragments keeps the index as time-ordered segments: the first build splits the table into segments of up to `segment_rows` rows in fragment order (uncommitted builds committed in one CreateIndex); later, once unindexed rows reach a threshold, they fold into the head (num_indices_to_merge = 1) or start a new head once the head is full (num_indices_to_merge = 0). - maintain fills NULL rows, then folds; remove_column sets off, drops the index, then the column. Filling uses a partial-schema merge that only updates rows still NULL; it moves the rows it updates to a new fragment, so it serves the few rows a racing write leaves, not the backfill, which add_columns does in place. The test runs the whole lifecycle, including a write that opened the table before the add and committed after it without filling its rows, and a compaction: Lance keeps each segment's fragments apart and remaps every segment, and indexed answers match the JSON filter throughout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector: list and request indexed metadata keys through the engine MetadataKeys reports an index's keys as its Lance table records them: requested (schema metadata), building, ready or off (the column's field), with the rows, segments and bytes of each key's scalar index. UpdateMetadataKey records a request to index a key, or to stop: a request is withdrawn, a column is set off at once. Both are refused with FailedPrecondition for a key indexed or requested already, past eight keys, or not indexed. The gateway's discovery and describe clients forward both, so the shell and admin reach them like the other calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector worker: lance_metadata_index job adds, maintains and removes keys Detection reads each S3 Vectors table's keys: a requested or `building` key is to add, an `off` one to remove, and a `ready` one whose unindexed rows reached `min_unindexed_rows` (default 50,000) to maintain. A job names the table, key and action, as the admin builds it when it dispatches one for an operator, and does only what the table still asks for when it runs. `segment_rows` (default 1,000,000) caps a segment. The job runs in the Lance scheduler lane. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * s3vectors: list and request indexed metadata keys for trusted callers Server.MetadataKeys and Server.UpdateMetadataKey reach the engine's new RPCs for the shell and the admin server. Adding a key refuses a non-filterable key of the index, and refuses unless every vector engine the masters list reports the gRPC health service weed.vector.capability.metadata_columns as serving, so no older engine can write the table without filling the key's column. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * shell: s3vectors.index.metadata lists, adds and removes indexed keys s3vectors.index.metadata -bucket b -index i [-add key | -remove key] prints each indexed metadata key with its state, the share of rows its scalar index covers, its segments and size. The shell's in-process S3 Vectors server setup moves into shellVectorsServer for both commands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector worker: derive raced rows again, not only the NULL ones A write that raced a key's column add leaves NULL in the rows it inserted and, in the rows it updated, the value derived from their old metadata. Filling only NULL rows missed the second kind. rederive compares each row's column with the value its stored metadata gives and rewrites the rows that differ, starting over from the latest version when a write commits meanwhile. finish runs it over the table before the first build and over the fragments written during the build; maintain runs it over the fragments the index does not cover yet, before folding them. The lifecycle test's raced write now moves 500 rows to another author as well as inserting 500, and all are right once the key is ready. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector: count indexed matches segment by segment, newest first The planner counted a filter's indexed matches with a Lance scan of the query's scope. A fragment-scoped scan makes Lance read the column instead of answering from the index, and it counted every match. The count now opens each segment of the key's index that overlaps the scope, newest first, searches up to eight of them at once in order, keeps the rows of the scope's fragments, and stops as soon as the total passes the limit. Rows in fragments no segment covers yet are counted by a read of the column. An AND is bounded by its most selective indexed conjunct. Rows a segment still lists after a delete count too: the total is an upper bound, which can only send a query to the vector index instead of an exact scan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector worker: test jobs on a table dropped under them (fails) DeleteIndex purges the table directory, and a colocated index created again under the same name reuses it. The test runs a vector index build and the metadata key add, maintenance and remove jobs against a table dropped right after the job opened it, and at the job's first write. It expects the job to fail, no manifest in the dropped path (no file at all when dropped before the first write), and a table created there again to start empty. It fails today: the remove job's metadata-only commits succeed and write two manifests into the dropped path, after which creating the table again fails with "Dataset already exists". The next commit fixes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector worker: a job does not write into a table dropped under it Jobs open tables through dataset::open, which now wraps the store in a DropGuard: once the manifest of the version the job opened is gone, every write fails ("the table was dropped while this job wrote it"), so the job fails instead of committing a manifest of the old table into the dropped path. A drop can land between the check and a write, so a manifest write is checked again afterwards and removed if the table is gone. Data or index files written in that window stay in the path unreferenced; no manifest does. With the guard, the vector index build and the metadata key add, maintenance and remove jobs fail on a table dropped after their open or at their first write, leave no manifest (nor any file when dropped before they wrote), and a table created there again starts empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector: test an index dropped and created again on one engine (fails) DeleteIndex purges the table's directory through the catalog and an index created again under the same name reuses it. On the same running engine, after a ready indexed key, a query and its filter stats, the test drops and re-creates the index, writes new rows and queries again: no old row, indexed key or filter stat may come back. Rows and keys come back clean; the filter stats of the old table are still served for the new one. The next commit fixes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector: filter stats follow the table behind an index name An index dropped and created again under its name is another table, but its filter stats were kept by name, so the new index showed the old one's filtered queries. The engine now forgets an index's stats when it creates or drops the index, and, since DeleteIndex purges through the catalog without telling the engines, a query of an index whose table id differs from the one its stats were counted on starts them over. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * s3vectors: refuse indexed key calls when no engine is configured A Server built without a vector engine client (as the admin's tests build it) panicked on MetadataKeys instead of answering with an error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector worker: a key removed during its build stays removed Removing a key whose build had not finished set its column off but left its add request, which reappeared once the column was dropped and asked for the key again. A build that finished after the removal also set the key back to ready. Removal now withdraws the request too, both when the operator asks and when the job drops the column, and finish marks the key ready only if the latest version still has it building. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector worker: maintain a key at once when a write left NULL rows A write that raced a key's add and stopped before fixing its rows leaves NULL in the key's column, so queries through the key miss those rows. They land in fragments the index does not cover yet, which maintenance derives again, but only once the unindexed rows reached the threshold. Detection now also proposes maintenance when those fragments hold a NULL row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector worker: test a purge through the drop guard (fails) A purge removes the versions before its rebuild, including the one it opened, which the drop guard watches; recording the purge's completion then fails as if the table had been dropped. The next commit fixes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector worker: the drop guard follows the job's own commits The guard watched the manifest of the version a job opened, and a job that removes old versions itself, as a purge does, removed it and then failed its next write as if the table had been dropped. The guard now watches the newest manifest the job committed, and when the job deletes the watched manifest itself, the newest manifest left beside it. A table dropped under the job still fails its writes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector worker: a column add keeps requests and states committed meanwhile add_columns commits the schema it read, and Lance lets that Merge go in over the schema and field metadata updates committed while it ran. A key requested, withdrawn or removed while another key's column was added was silently undone: the removed key went back to ready and the request vanished. The add now sets those again, and a key whose own request was withdrawn meanwhile gets its new column off instead of being built. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * vector: keep FilterStats::record's doc on record Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * vector worker: test the guard against the job's own cleanup directly The purge test asserted the purge was served, which depends on the cleanup's retention policy rather than on the guard. It now has the job remove every version before its own commit, the opened one with them, through the guarded store, and write again; a purge after that still completes. Without the previous commit's fix the write after the cleanup fails with the DropGuard error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector: indexed-key tests compare keys, not only distances assert_same accepted a different key at a rank whenever its distance matched, so a lost row replaced by a duplicate passed. It now requires the same keys, and lets two keys trade ranks only when they tie. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector: filter stats record their table with each query A query recorded its stats and its table in two steps, so the first query of an index left the stats without a table, and a later table under the name then took them over. A query of the old table finishing after the index was created again also cleared or added to the new table's stats. record now takes the table and, under one lock, starts the stats over for a new table, keeps the tables the name held before, and drops a query of one of those. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * lance worker: asking again for a key change is done, not an error UpdateMetadataKey commits the request and then lists the keys. When the listing failed after the commit, the caller saw an error, and its retry was refused as already indexed, so the change it made could not be confirmed. A request for a key requested or indexed already, and a removal of a key not indexed or already off, now succeed without another commit. A request for a key still being removed is refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * lance worker: a resumed add sets again what its commit overwrote add_columns commits the schema it read, so add_column sets again the requests and key states committed while it ran. A job that stopped between the add's commit and that step left them overwritten, and the build that resumed the key, seeing it building, finished it: a removal asked for meanwhile was lost and the key went ready. The added column records the version its add read. A resumed build compares that version's schema with the add's and sets again what the add overwrote before going on, and stops when that leaves the key off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * vector: a key goes ready only after writes that raced its add are done A PutVectors that opened the table before a key's column add and committed after it wrote its rows' key column as of the version it read: NULL for new rows, the old value for updated ones. It derives them again itself, but when that failed, or the write was still running when the build finished, the key went ready with those rows wrong, and maintenance only filled NULLs. PutVectors now commits within WRITE_DEADLINE (120s) of opening the table or fails. finish waits until RACE_GRACE (180s) after the add, then derives again the fragments written since it first looked, comparing values, not only NULLs, before it marks the key ready. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * lance worker: drop guard tests for a table created again and flaky probes A job on a table dropped and created again under the name, a probe that fails after a manifest is written, a multipart upload completing after the drop, and a cleanup whose paths now hold the new table's files. Each fails against the guard as it is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * lance worker: drop guard tells a table created again from the one opened The guard only checked that the watched manifest path existed. A table created again under the name reuses version paths, so a job on the old table wrote into the new one. A failed HEAD after a manifest write was taken as a drop and deleted the published manifest. A multipart upload was checked only when it started, and a cleanup deleted paths it picked before the drop. The guard now records the manifest's e-tag and treats another e-tag, or the manifest gone with others beside it, as a table created again. A failed probe after a manifest write keeps the manifest. A multipart upload checks again before it completes, and a cleanup checks once before it deletes, refusing when another table is there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * lance worker: order the zero-grace control of the racing-write test The control ran the stale write 1.5s into finish, so on a slow runner it could commit before finish's last pass and be repaired, failing the assertion that it lands after ready. It now commits after finish returns. With a grace the write still overlaps the wait: it commits 1.5s after the add, and finish looks again only once the grace from the add has passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * lance worker: set again what an add overwrote once, over later changes recover_add replayed the add's historical delta on every resumed build, so a request withdrawn after it was set again came back. It wrote over values changed since the add, failed on a column dropped since, and failed on every attempt once a cleanup removed the version it read. The added column now carries a restore mark. The restoration is one UpdateConfig commit that sets the schema entries and key states the add overwrote and clears the mark, so it runs once. An entry or state changed again since the add keeps its later value, and a column gone or holding another key is skipped. The schema the add read comes from the add's own version; without the version before it, the mark is cleared and the build goes on. finish waits the whole grace from now when the add's version is gone. a_restored_add_is_not_replayed, a_resumed_add_skips_a_column_dropped_since and a_resumed_add_goes_on_after_a_cleanup failed before this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * lance worker: a removal sets again what the key's add overwrote first Recovery ran only when an add resumed. A key withdrawn after its add stopped went to the remove job, which dropped the column and its restore mark, losing for good the requests and key states the add overwrote. The remove job now recovers the add before it drops the column; the key stays off. a_removal_keeps_what_the_add_overwrote failed before this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * lance worker: drop guard aborts on a failed probe, keeps another's manifest An upload whose check before completing failed returned the error without aborting, leaving its parts behind on S3. A manifest write found dropped or replaced was deleted at its path even when a table created again had since written its own manifest there. complete now aborts on a failed probe too. The rollback deletes the manifest only while its e-tag is the one this write got. Object stores offer no conditional delete, so a table created again between that HEAD and the delete is still not covered. a_failed_probe_aborts_an_upload and a_rollback_keeps_the_manifest_of_a_table_created_again failed before this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * lance worker: test a failed rollback probe over a table created again Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * lance worker: keep a replacement's manifest when the rollback cannot tell it apart After a write's manifest, a drop guard that found the table replaced deleted the manifest whenever its HEAD failed or the PUT returned no e-tag. It now deletes a replaced table's manifest only when the e-tags match; a table merely dropped still takes its manifest back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * vector: MetadataKeys leases the version it lists Like the other reads, it pins the opened version so a purge cannot reclaim that manifest's index files while the segments are loaded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * lance worker: test a key that went ready on an empty table Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * lance worker: build the first segment of a ready key below the threshold A key that went ready on an empty table has no segment. Detection held its unindexed rows to min_unindexed_rows, so a small table stayed unindexed. A ready key without a segment is now maintained once it has rows, as index_fragments builds a first segment at any size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * lance worker: test a repair retried over a compaction of its fragments Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * lance worker: a repair retried after contention derives the moved rows too rederive started over from the latest version with the fragment ids it was given. When a compaction caused the contention, those fragments were gone and the retry repaired nothing, so maintain folded the compacted rows with their columns still NULL. A retry now also derives the fragments the newer version added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * lance worker: test withdrawals that race a key's add Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * lance worker: a withdrawal that races the key's add sets its column off A removal that read only the request cleared it, and Lance rebases that metadata update over the add's Merge, so the column it made stayed building and finish made it ready. After withdrawing the request, the removal looks again and sets a column it finds for the key off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * lance worker: a withdrawal recovers interrupted adds first An add whose commit overwrote another key's request and stopped before setting it again hides that request. A withdrawal of it then found nothing to do, and the add's later recovery brought the request back. request_removal now recovers such adds before it decides. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * lance worker: test a request committed while a column is dropped Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * lance worker: a drop sets again what it overwrote while it ran drop_columns commits a Project of the schema it read, and Lance rebases it over metadata updates, so a request or key state committed while the column was dropped was lost. remove_column now sets those again as a column add does, through the overwritten diff split out of reapply_metadata. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * lance worker: drop test counts HEADs with try_update Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * vector: test a late query of a dropped table after the next table's first one Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * vector: test PutVectors at a version from before a key's column add Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * vector: keep a dropped table retired when its index's stats are forgotten Dropping or creating an index removed its stats entry, and the retired tables with it, so a late query of the dropped table that came after the new table's first one reset the new table's stats. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * vector: refuse PutVectors at a table version Table.version pins reads. A write opened at a version from before a key's column add would commit rows without the column after the key went ready, past the write deadline and the grace pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: indexed metadata keys panel for S3 Vectors indexes (#12821) * vector: report an index's rows and vector index type with its keys MetadataKeys also answers with the table's rows and its vector index type (IVF_FLAT, or empty without one), which the admin's index panel shows next to the keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * admin: indexed metadata keys panel on the S3 Vectors bucket page Each index of a vector bucket gets a card: dimension, metric, vectors and vector index type; its indexed metadata keys with state, coverage of the table's rows, filtered queries per hour and index size, with Remove for a ready key and Cancel for a requested or building one; and the keys its queries filtered on most in the last hour that are not indexed, with their average latency. A key filtered only with numbers is marked "(numeric: phase 2)" and has no Index button. "+ Index a key" and a listed key's Index button open a dialog for the key, which refuses the index's non-filterable keys. Adding or removing goes through the engine; the admin then dispatches the lance_metadata_index job for that key when a worker can run it, and detection finds it otherwise. Filter stats are read from every registered engine and summed per hour over each engine's window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * admin: keep a metadata key's spaces when indexing it The dialog trimmed the key before sending it, but metadata key names are exact strings: a key with surrounding spaces would have indexed another field. Only an empty or all-space name is refused now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * admin: bound the index panel's key lookup An engine that accepted the panel's MetadataKeys call and stopped answering held the whole bucket page; the lookup now gives up after five seconds and the panel shows the error, as the filter-stat calls do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * admin: dispatch a metadata key job without the cluster admin lock ExecutePluginJob holds the cluster admin lock for the whole run, so a key build dispatched from the bucket page kept weed shell and the default lane locked out for up to an hour. The Lance lane runs without that lock in the scheduler; run the dispatched job the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: pass an index without non-filterable keys as an empty list An index whose record holds a metadata configuration with no key list was rendered as `null`, and the dialog's non-filterable check then threw before it could submit or show an error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * admin: ask in a modal before removing or cancelling a key's index Remove and Cancel on a metadata key asked with the browser's confirm(), unlike the rest of the page. They now open a Bootstrap modal laid out as Delete Index's, naming the key and the index, and show a failure in the modal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * admin: show when an engine's filter stats leave keys out sumFilterStats dropped each engine's truncated flag, so a panel whose engine stopped counting new keys listed its frequent keys as complete. The panel now carries the flag and says the list is partial. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
2e4be5e25e | mount: report a read-only mount root that does not exist as not found, not as the create error (#12799) | ||
|
|
f7323f2b63 |
filer: optional HTTP Basic Auth on the filer HTTP ports (#12778)
* security: add a constant-time HTTP Basic Auth check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: require HTTP Basic Auth on the HTTP ports when configured With filer.basic_auth.password set in security.toml (or WEED_FILER_BASIC_AUTH_PASSWORD), a request on the filer HTTP ports, TUS included, must carry those credentials or a valid filer JWT, and an access level with no JWT signing key is no longer open. Valid Basic credentials grant read and write. 401 responses then carry a Basic challenge so browsers prompt. The credentials reload on SIGHUP with the signing keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * scaffold: document filer.basic_auth in security.toml Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: enable reloaded Basic Auth before swapping the JWT keys Reload cleared the old signing keys before storing the new Basic credentials, so a switch from JWT to Basic Auth briefly left both off and admitted anonymous requests. Store new credentials first and clear old ones last. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: refuse Basic credentials on cross-origin browser requests Browsers resend cached Basic credentials on requests other websites trigger, such as a form POST with mv.from, and the default cors.allowed_origins "*" lets them through. Accept Basic credentials only on requests without an Origin, from the filer's own host, or from an origin explicitly listed in cors.allowed_origins. A JWT is still accepted from any origin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: recheck Basic Auth after reading an empty signing key A request that loaded Basic Auth as off, then read the signing key after a JWT-to-Basic Reload had cleared it, was let through anonymously. Open access now also needs Basic Auth to be off after the key read; with Reload enabling the new credential before disabling the old one, the two loads cannot both miss a credential that was on throughout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: compare Basic Auth credentials as MACs under a per-process key A plain SHA-256 of the password is what password-hash scanners flag; keying the digests with a random per-process HMAC key keeps the length-independent constant-time compare without holding one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: read a configuration file without merging into the shared viper LoadConfiguration merges each read into the shared viper, so a key removed from the file keeps its old value after a reload. ReadConfiguration reads the file into a fresh viper with the same search path and WEED_ environment overrides. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: turn Basic Auth off when security.toml no longer sets it The shared viper merges each SIGHUP reload into what it held, so removing [filer.basic_auth] kept the old password valid. Read the credentials from security.toml alone at startup and on reload; an unreadable file keeps the current setting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep Basic Auth when security.toml cannot be read A malformed file at startup dropped a WEED_FILER_BASIC_AUTH_PASSWORD from the environment, and viper reports an unsearchable config directory as a missing file, which turned Basic Auth off on reload. ReadConfiguration now always returns the environment overrides and reports whether the file was read; a reload that could not read it keeps the current credentials. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep reloading Basic Auth from the security.toml first read A search directory that turned unsearchable made viper fall through to a lower-priority security.toml, and a reload from a file without [filer.basic_auth] turned Basic Auth off. ReadConfiguration now takes the file to read, and the filer reads the file it first found on every reload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
f5e091cf91 |
wdclient, s3: return an embedded S3 gateway to its local filer after failover (#12772)
* wdclient: sort newly discovered filers and log every current-filer switch Discovery appended new filers in map iteration order, so after the current filer left, the fallback at index 0 was a random filer. Append them sorted. Route every change of the current filer through one helper that logs it at V(0) with its reason (failover, return_home, discovery), so an operator can see which filer a gateway uses without new metrics. * wdclient: prefer a home filer and return to it after failover with backoff A FilerClient with FilerClientOption.HomeFiler set goes back to that filer once its circuit breaker allows a re-check, instead of staying on whichever peer it failed over to. Leaving home again soon after a return doubles the wait before the next return, up to 5 minutes; a return that holds for 10 minutes resets it. Volume lookups and discovery follow the same preference. * s3: embedded gateway uses its local filer as home filer weed filer -s3, weed server -s3 and weed mini now build the gateway's filer address in the form the filer registers in the master (ip:port.grpcPort), with the gRPC port default applied, and pass it to the gateway as its home filer, so the gateway returns to its local filer after any failover. Standalone weed s3 has no home filer and behaves as before. Refs #12768, follow-up to #12771 * wdclient: switch the current filer only from the filer a request started on A volume lookup that started on a peer and finished after the client had returned home moved it back to the peer and counted that as leaving home, doubling the return backoff although home never failed. Concurrent failovers could also each count as a separate departure. Failovers now name the filer they started on and take effect only while it is still current, via compare-and-swap, so only the winning switch logs and feeds the backoff. S3's failover walk uses the same rule. * wdclient: switch the current filer and record the return backoff in one step The index moved by compare-and-swap before the switch was recorded, and both ran under the shared read lock. A request reading the current filer in that gap saw the peer with the old eligibility time and, with home's breaker still closed after one failure, switched straight back home. The eligibility check, the move and the bookkeeping now all run under homeMu. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * wdclient: discovery falls back past a home that is still backing off When discovery removed the current filer and home was not yet eligible, the client took index 0, which is home whenever it is listed first. With home's breaker still closed after a single failure, requests went back to the filer they had just left. Take the next filer instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * wdclient: start return timing on every switch back to the home filer Only a return_home switch stamped lastReturnHome. Discovery or a peer's failover could also put the client back on home, and a failure soon after such a return kept the backoff at its base value instead of doubling it. 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> |
||
|
|
05a1463855 |
wdclient: keep the embedded S3 gateway on its local filer across discovery (#12771)
* filer: keep an explicit gRPC port in the embedded gateways' filer address runFiler handed the embedded S3/WebDAV/IAM/SFTP gateways NewServerAddress(...).String(), and String() drops the .grpcPort part. With a non-default -port.grpc the gateways then dialed port+10000 and did not recognize their own filer in the master's list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * wdclient: match discovered filers by gRPC address A filer listed as host:port and the same filer discovered as host:port.grpcPort were compared as raw strings, so a refresh pruned the configured filer, added every discovered filer as new in map order, and reset the current filer to whichever came first; a pushed join added it a second time. Key filers by their gRPC address: a survivor keeps its health and current position and takes the discovered address form, and pushed joins and leaves match the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
c1c95e127f |
filer: scoped read-only tokens for metadata subscriptions (#12767)
* security: scoped read-only token for filer metadata subscriptions A token signed with jwt.filer_signing.subscribe.key names the subscribe methods and the path prefixes its holder may see. mTLS peers and admin tokens stay unrestricted. Internal subscribers attach an admin token when both keys are configured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: enforce subscription token scope on metadata streams With jwt.filer_signing.subscribe.key set, SubscribeMetadata and SubscribeLocalMetadata authorize the caller first. A scoped caller gets a stream that sends only events whose paths are all under its prefixes, filters batches, and never carries log file refs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: send an admin token on internal metadata subscriptions Peer filers, metadata followers and the lifecycle reader attach an admin token when the subscribe key is configured, so they keep the full stream without mTLS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: add fs.meta.token to mint metadata subscription tokens Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: end scoped metadata subscriptions at token expiry The scope now carries the token's exp. The scoped stream's context ends at that time and the call returns Unauthenticated, so an open stream no longer outlives its token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.sync: sign metadata subscriptions with the source cluster's key MetadataFollowOption takes a FilerJwtProvider; filer.sync passes the one loaded from -a.security or -b.security, so clusters with different admin keys both accept the subscription. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: report fs.meta.token flag errors Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: give scoped metadata subscribers their own client id A scoped caller could reuse another subscriber's ClientId with a higher epoch and replace that registration, disconnecting it. Scoped streams now register under a server-chosen id that no other subscriber holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: accept only HS256 metadata subscription tokens Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: test HS384 metadata subscription token rejection Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: never let a scoped subscriber replace another registration The server-chosen id can be taken by another subscriber between choosing and registering it. Registering scoped streams with the lowest epoch makes addClient refuse them rather than replace the other registration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: send position markers for events a scoped token withholds Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: test a scoped stream withholding a whole event batch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: filter SendMsg on scoped metadata streams The scoped wrappers only overrode Send, so a SendMsg on the embedded stream would reach the client unfiltered. Route it through the same filter and refuse any other message type. Ported from #12790. Co-authored-by: mindaeon <30555587+mindaeon@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: test a scoped subscription through the real subscribe loop Run SubscribeLocalMetadata with a scoped token over a flushed backlog, the in-memory tail and live events: only in-scope events arrive, sibling, "..", encoded and cross-boundary rename paths are dropped, and no log file references are sent although the client asks for them. Without the subscribe key every event still arrives. Ported from #12790. Co-authored-by: mindaeon <30555587+mindaeon@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: test that the HTTP API refuses metadata subscription tokens GET, HEAD, PUT, POST and DELETE all refuse a subscription token, also when the subscribe key equals the read or write key. Ported from #12790. Co-authored-by: mindaeon <30555587+mindaeon@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: mindaeon <30555587+mindaeon@users.noreply.github.com> |
||
|
|
a3b2fd722d |
mount: report opens for reading with TouchAccessTime (-accessReport) (#12721)
* mount: report opens for reading with TouchAccessTime (-accessReport) An open answered from the metadata cache never reaches the filer, so a filer that tracks access cannot see that a cached file is still being read. With -accessReport, the mount sends one TouchAccessTime per open for reading, with the open time, whether the open was answered from the cache or not. Write-only opens are not reported. Reports go out in the background and never hold up the open: a report that does not fit in the queue is dropped, and drops and failures are logged once a minute. A filer that answers Unimplemented pauses reporting for 10 minutes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: address review of the access report - Drop reports still queued when reporting pauses; the filer that answered Unimplemented would answer them the same way. - Bound each filer attempt to 2s, so a filer that accepts the connection but never answers leaves time for the next one, and keep using the filer that answered. - Fail over only when a filer cannot be reached. Any answer, Unimplemented included, ends the walk. - Report an O_CREAT open of an existing file with read access, which comes through Create instead of Open. A new file has nothing to read and is not reported. - Stop the reporter on unmount: stop ends the workers and cancels the report in flight. - Say in the flag help that it has no effect unless the filer implements TouchAccessTime. - Tests no longer wait a fixed time to see that nothing else was sent; they look at the queue of a reporter that is not started. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: fail an access report over only when the filer did not answer A status the filer sent ends the walk even when its message contains a word the transient classifier matches, so an Unimplemented answer still pauses reporting and a rejected request is not resent elsewhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep a filer selection made while an access report failed over A report that reached a later filer moves the mount there only if the selection it started from is still current, so a slower report cannot undo another call's failover. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: share an access report's time with the filers not yet tried Each attempt is capped by an equal share of the report time left, so a row of stalled filers cannot use up the report before a healthy one later in the list is tried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: report the path an open for reading came through A create that opens an existing hard link reports the name it was given rather than the inode's first known name. Open reads the inode's path from the inode table rather than the handle's saved path, which other handle operations may rewrite concurrently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: check the access report stop and failover tests without races The post-stop report is checked on a reporter without workers, so no worker can take an accepted report before the check, and the failover test asserts that the stalled filer was tried first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pb: keep the shared channel when the peer answers with its own status gRPC never raises InvalidArgument, NotFound, AlreadyExists, FailedPrecondition, OutOfRange or DataLoss itself, so such a status is the peer's answer. It fell through to the string matching, and a message naming a path like /transport closed the cached channel and cancelled every other call on it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: say which filer selection an access report keeps Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: bound the in-flight call in the rejected-report channel test The call held in flight went through touchAccessTime, whose 2 s attempt cap could expire on a slow runner and fail the test on a healthy channel. It now uses callFiler with the test deadline. The wait for it to reach the filer also ends if it returns early or the deadline passes, and the blocked handler is released on every exit path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: report each file at most once per -accessReport.interval Every read open used to send a TouchAccessTime, adding a filer metadata call per open. A path reported within the interval (default 1h) is now skipped; the last report times live in a bounded LRU. 0 keeps reporting every open. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: report an open again once the file was modified since its last report Within -accessReport.interval a read open was skipped even after a write, so the filer kept an atime older than the mtime until the interval ran out. relatime records that first read after a write; do the same by comparing the entry's mtime with the last report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep the report time apart from the mtime it saw Recording max(now, mtime) as the last report let a file dated a day ahead suppress reports for a day plus the interval. Record when the report was sent and the mtime the entry had, and treat any change of that mtime as a modification, so neither clock can stretch or shorten the interval. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
91eaabf371 |
s3: answer ClientDisconnected for a GET the client aborted before the first byte (#12707)
* s3: answer ClientDisconnected for a GET the client aborted before the first byte Fixes #12706 * s3: tell a gone client on TLS and HTTP/2 too, and not on a connection the server closed |
||
|
|
0d3f5a220c |
s3: keep serving for -preStopSeconds after SIGTERM (#12703)
* s3: keep serving for -preStopSeconds after SIGTERM On SIGTERM the gateway closed its listeners at once, so requests a load balancer or Kubernetes Service still routed to it failed until the endpoint was removed. With -preStopSeconds set, the gateway makes /status, /healthz and /readyz return 503, keeps serving for that many seconds, then runs the existing graceful shutdown. 0 (the default) keeps the old behavior. The flag is registered for weed s3 and as -s3.preStopSeconds for weed filer, weed server and weed mini. A cancelled weed mini cluster context ends the wait early. The Helm chart passes s3.preStopSeconds and filer.s3.preStopSeconds through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: assert the preStopSeconds chart render under set -e, drop timing from the probe test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: wait before weed mini cancels its clients; size grace periods in the chart weed mini's interrupt hook runs before the S3 one and cancels the S3 gateway's shutdownCtx, so the pre-stop wait never happened there. The wait is now also registered with beforeMiniClientsShutdown, which runs before that cancel, and a sync.OnceFunc keeps the interrupt hook from waiting a second time. Outside weed mini the registration is a no-op. Helm: the s3 deployment fails to render when terminationGracePeriodSeconds is below preStopSeconds + 15. The filer statefulset and the all-in-one deployment, whose grace period is fixed at 60s, add preStopSeconds to it. allInOne.s3.preStopSeconds is passed through, inheriting s3.preStopSeconds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: keep 64-bit counters aligned on 386; let allInOne.s3.preStopSeconds=0 disable the wait draining sat ahead of inFlightDataSize and inFlightUploads in S3ApiServer and shifted them off 8-byte alignment on 32-bit builds, so the atomic upload-limit counters panicked there. It now follows them. Helm: allInOne.s3.preStopSeconds inherits s3.preStopSeconds only when null; default treated an explicit 0 as unset. The s3 values and the grace period error now say a lifecycle preStop hook's time comes on top. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * grace: add OnInterruptFirst for hooks that must run before any shutdown Interrupt hooks run in reverse registration order, so a hook cannot run ahead of a service that registers later, such as a volume server that is still loading its volumes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: run the -preStopSeconds wait before every other interrupt hook Under weed server the volume server registers its hook once its volumes are loaded, often after the S3 gateway. Its hook then ran first and shut the volume server down, so the gateway spent the whole wait serving requests that could not read or write objects. 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> |
||
|
|
c4e1802e3e |
s3: route ';' queries as authorized, and report an empty s3:prefix to policies (#12702)
* s3: escape raw semicolons before the router matches a route registerRouter applied EscapeSemicolonsInQuery with router.Use, but mux runs router middleware only after it has picked the route. Queries() matchers split pairs on ';', so GET /bucket?uploads;x=1 reached the multipart listing handler while the handler and the IAM resolver read uploads%3Bx=1 and saw no uploads subresource. Wrap the S3 router with the escape so routing and authorization read the same query. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: report a listing without prefix as s3:prefix "" in policy conditions The advanced IAM path already sets s3:prefix to "" when a bucket listing names no prefix, as AWS does, but bucket policies and attached policies read conditions from ExtractConditionValuesFromRequest, which leaves the key out. The AWS home-directory policy that grants s3:prefix ["", "home/"] then denied the root listing, and a Deny keyed on the empty prefix never applied. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: test the served handler composition for the semicolon escape Move the escape and the Vectors split into s3Handler so a command test can send ';' queries through the handler the server actually serves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: keep the isVectorsRequest doc comment on its function Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
b74971b6d4 |
server: add -grpc.localSocketDir for the local gRPC sockets (#12693)
* server: add -grpc.localSocketDir for the local gRPC sockets `weed server` and `weed mini` hard-coded each local gRPC Unix socket under /tmp. systemd-tmpfiles ages /tmp after 10 days and macOS after 3, so a long-running server loses its socket, and RegisterLocalGrpcSocket keeps routing local dials to the missing path: the master can no longer reach its volume server. Add -grpc.localSocketDir to both commands, defaulting to /tmp so an existing setup is unchanged, and build every socket path from it with filepath.Join. A folder that does not exist or is not a directory is refused at startup rather than at the first local RPC. A folder whose socket paths exceed the platform's sockaddr_un limit is refused too, because every bind then fails with EINVAL while the server keeps running and each local RPC dials a socket that does not exist. Refs #12692 * server: refuse a -grpc.localSocketDir the server cannot bind in An existing folder the server's user cannot write to passed the startup check, and then every socket bind failed: ListenOnLocalSocket only logs the error while GrpcDial keeps routing local dials to a socket that was never created. After the path-length check, create and remove a probe Unix socket in the folder, and refuse startup with the bind error if that fails. * server: give the -grpc.localSocketDir probe a random name A probe named only by the process id could be precreated by another user in a shared /tmp, or left by a crashed process whose pid was reused, and the server cannot remove such a file, so startup failed although the real socket paths were free. Name the probe with 8 random bytes, retry a name that is taken, and rely on the listener's close to unlink it. * server: keep the -grpc.localSocketDir probe name within the service socket lengths The probe was 5 bytes longer than the master and volume socket names, so a folder whose service sockets fit the sockaddr_un limit could still be refused. A 23-byte probe name is shorter than any service socket name, and a process with no local sockets skips the check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * server: trim the -grpc.localSocketDir comments and drop issue references Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Brent Pease <179639673+brentDSL@users.noreply.github.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
95f46c8fff |
admin: manage filer webhook targets from the UI with live reload (#12690)
* webhook: share the default target settings Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webhook: managed webhook targets with a drainable queue Targets kept as JSON (name, endpoint, token, filters, retry and worker settings) build their own queue; Close waits for queued and in-flight deliveries before stopping it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: run webhook targets stored in /etc/seaweedfs when notification.webhook.managed is set The targets in /etc/seaweedfs/notification_webhooks.json start with the filer and are rebuilt from the store whenever the file changes on any filer, alongside notification.toml. The previous queue drains before it stops. Events for the file itself, which holds bearer tokens, are not sent to notification queues. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: manage filer webhook targets A Webhooks page under Management lists, adds, edits and deletes the targets kept in /etc/seaweedfs/notification_webhooks.json. Bearer tokens are write-only: the API reports whether one is set, and an empty token on edit keeps the stored one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep the webhook queue when the stored targets did not change Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep a replaced webhook queue open until its senders hand over Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: read chunk-backed webhook targets before editing them Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: keep the stored webhook targets out of fs.meta.notify Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webhook: reject negative managed target settings Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webhook: no signal handler on queues that reloads replace Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: swap the webhook queue without waiting behind blocked senders The read lock held across SendMessage made a reload wait for any sender blocked on a saturated target, and the waiting writer stalled every other filer write with it, which is when an operator disables that target. Close now refuses new sends and waits for the senders already inside SendMessage, and a send that hits the closing queue retries on its replacement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webhook: release blocked test handlers before the server shuts down Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: always run the webhook targets managed in the admin UI Drop the notification.webhook.managed switch: every filer loads and live reloads the stored targets. Without stored targets no queue is created. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * scaffold: place the admin-managed webhook note above enabled Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * scaffold: separate the admin-managed webhook note Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * scaffold: note that admin-managed webhooks follow the notification queue Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: retry loading webhook targets after a failed read Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: retire the admin-managed webhook queue on shutdown Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
9e5357782e |
volume: keep reads over the download limit local when readMode is local (#12679)
* volume: keep reads over the download limit local when readMode is local With -readMode=local the server never sends a read for a volume it does not hold elsewhere, but a read over -concurrentDownloadLimitMB on a replicated volume was still redirected to another replica. Skip the replica fallback in local mode, so the read waits for a download slot and answers 429 when the wait times out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): keep reads over the download limit local when readMode is local Mirror the Go volume server: with readMode local, a read over the download limit waits for a slot instead of being redirected to a replica. proxy_or_redirect_to_target no longer needs the local-mode redirect switch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: check download capacity under the wait lock waitForDownloadSlot read the in-flight size outside the cond lock and the read handler broadcast without it, so a download finishing between the check and the wait was missed and the read waited out the timeout for a 429. Check capacity with util.WaitUntil under the lock and broadcast under it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): register for the download notification before checking capacity The wait loop created its Notified future only after the capacity check, so a body dropped in between had its notify_waiters() lost and the read waited out the deadline for a 429. Create the future first, then check, as Go now checks under the cond lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
b2dd93eac8 |
admin: support [maintenance.s3_lifecycle] in admin.toml (#12661)
* admin: support [maintenance.s3_lifecycle] in admin.toml
The admin.toml overlay covers vacuum, volume_balance and erasure_coding but
not s3_lifecycle, so the bucket lifecycle job's settings can only be changed
from the web UI and are lost whenever the admin data directory does not
persist. That is the worst combination for this job type: its
meta_log_retention_days knob decides whether bucket rules ever apply to
objects written before the job was enabled, and silently reverting it to the
default makes the rules no-op without any error.
Wire the four admin-side knobs into the existing overlay:
meta_log_retention_days retention window the meta-log replay can reach
walker_interval_minutes minimum gap between full bucket walks
cluster_deletes_per_second cluster-wide delete budget
cluster_deletes_burst token-bucket burst for that budget
All four are admin config values, not worker values: the engine partition is
computed on the admin side and the delete budget is divided across
execute-capable workers at dispatch time. enabled/retry_limit/
retry_backoff_seconds come for free from the shared section handling.
Tested with TestApplyPluginConfigFromTomlS3Lifecycle, which also pins the
retention=0 case: 0 means unbounded and must survive as an explicit 0 rather
than being treated as unset.
* admin: fix meta_log_retention_days guidance in admin.toml scaffold
Both reviewers caught a real error. `0` is not "unbounded": runShard does
retentionWindow := cfg.RetentionWindow
if retentionWindow <= 0 {
retentionWindow = maxTTL
}
so zero falls back to the longest rule TTL, which keeps every replay rule in
replay and promotes nothing to the walk set. Recommending 0 to force full
scans was wrong, and so was the claim that pre-existing objects are only
reachable through the walk set -- the cold-start recovery walk covers them
regardless of the retention value.
Describe zero as "no retention info supplied" and tell operators to set the
window the filer meta-log actually retains. The code change is unaffected:
it only wires the four keys into the existing overlay.
* admin: tie s3_lifecycle walk-set scans to walker_interval_minutes in admin.toml
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: show the s3_lifecycle retry defaults in admin.toml
The s3_lifecycle descriptor sets no retry limit or backoff, so a failed
run is not retried and the scheduler's 5 s backoff applies; the scaffold
listed the vacuum values instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: shorten the s3_lifecycle toml section comment
The retention and walker knobs are read by the worker from the admin
values, not computed on the admin side.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: cover cluster_deletes_burst in the s3_lifecycle toml test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: check the s3_lifecycle retention zero is a stored int64
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>
|
||
|
|
504de9b562 |
security: refuse to start when per-target gRPC server allowlists are not applied (#12662)
* security: refuse to start when per-target server allowlists are not applied A component that dials every server with one option ignored <target>_allowed_server_* keys, so a config that only set those accepted any CA-signed server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * scaffold: say which components scope server allowlists per target Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: also catch per-target server allowlists set through WEED_ env vars Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d80e905fc7 |
security: optional dialed-host check for gRPC server certificates (#12663)
* security: optionally check the dialed host against gRPC server certificates verify_server_host under [grpc] or a [grpc.<component>] section switches the client to certificate-and-host verification. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * scaffold: document verify_server_host Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
63c99183d1 |
s3vectors: name weed-vector processes servers (#12627)
* s3vectors: call the registered weed-vector processes servers The gateway's discovery named them workers, the name of the admin plugin workers. Also drops two comments left without a function. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * test/s3vectors: build the Enterprise engine as weed-vector In an Enterprise checkout, make ./weed-vector builds the distributed engine, which also serves VectorService, instead of a separate weed-vector-worker. An open-source checkout builds weed-vector-server as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * test/s3vectors: distributed mode starts two more weed-vector engines It started weed-vector-worker, which no target builds now, and waited for a gateway log line that no longer exists. The Enterprise weed-vector's engines all join the placement controller. 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> |
||
|
|
5a54009439 |
filer/etcd: client keepalive and per-request deadlines (#12621)
* filer/etcd: client keepalive and per-request deadlines An etcd member that goes silent with its connections open (a dead or hung node, a network partition, a frozen process) keeps the store's requests balanced onto it waiting forever, because the client has no keepalive and the calls have no deadline. Writes through the filer stop although the other members keep quorum. keepalive_timeout (default 3s, "0s" turns keepalive off) enables gRPC keepalive with the ping interval fixed at gRPC's 10s minimum. gRPC also sets TCP_USER_TIMEOUT to it on Linux, so a connection whose sent data goes unacknowledged that long is closed by the kernel. request_timeout (default 3s) bounds every Get, Put and Delete unless the caller set a deadline; timeout keeps its meaning as the dial timeout. DeleteFolderChildren gets no request deadline: its DeleteRange grows with the directory, and keepalive still ends it if the member goes silent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Update weed/filer/etcd/etcd_store.go Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> * Update weed/filer/etcd/etcd_store_test.go Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> * Update weed/command/scaffold/filer.toml Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> * filer/etcd: no request deadline on entry writes A Put whose client deadline expires may still have been committed. The filer's upload handler treats the error as a failed write and deletes the uploaded chunks, which the saved entry may then point at. InsertEntry and UpdateEntry therefore keep the caller's context: etcd's own request timeout ends a Put a live member cannot commit, and keepalive ends one on a member that goes silent. Reads and deletes keep request_timeout; a timed-out store delete returns before the filer deletes any chunks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/etcd: no request deadline on KvPut The filer wrapper stores a hard-linked file's attributes and chunk list through KvPut. An HTTP append to a hard-linked file whose KvPut times out after etcd saved it returns an error, and the upload handler deletes the appended chunks the saved hard link now points at. KvPut keeps the caller's context like InsertEntry and UpdateEntry. 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> |
||
|
|
911bfe4014 |
mount: stop overwriting the mount root's filer entry (#12623)
When a mount is rooted at an existing directory, two code paths replace that directory's filer entry with one the mount builds itself: - every mount start re-creates the root with a non-exclusive mkdir, which the filer handles as an update of the whole entry; - creating or removing an entry directly in the root saves the root's entry to touch its mtime, and maybeLoadEntry synthesizes that entry from the mount options instead of reading the filer. The filer keeps only crtime and inode on such an update, so the root loses its mode, owner and extended attributes. When the root is a bucket it also loses the bucket quota, which silently drops to 0 (unlimited), and the settings S3 keeps on the bucket entry. The explicit allowEmptyFolders=false that #11370 meant to keep is replaced by true at every mount start, because the mkdir has wiped it before ensureBucketAllowEmptyFolders looks. Create the root only when a lookup says it is missing, and then exclusively. Leave the root out of the filer-side mtime touch: its attributes come from the mount options (setRootAttr), so the filer copy of its mtime was never visible through the mount anyway. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
bef1b13b3d |
replication: keep a local sink path the source recreated after a delete (#12581)
* replication: let the local sink check a delete against the live source LocalSink removed the destination path for any delete it was handed. A delete that reaches the sink after the source recreated the path (a peer filer's event delivered late, or a historical event replayed) removed the newer file, and no later event brings it back. DeleteEntryVersion receives the deleted entry. Before removing an existing destination, the local sink looks up the source path and keeps the destination when the source holds an entry of the same kind committed after the deleted version (commit_ts_ns, or mtime for unstamped entries). A live entry that is the deleted version itself or older means the source store lags the event, so the delete proceeds. A failed lookup returns the error so the event is retried instead of deleting a file that may be live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.sync, filer.replicate: hand the deleted version to the sink Pure deletes, renames without a native move and moves out of the watched directory now go through sink.DeleteEntryVersion with the old entry, so a sink that checks the live source (the local sink) can keep a path the source recreated after the deleted version. Other sinks fall back to DeleteEntry unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * replication: order the local sink check by the delete's mutation time A source filer can hold a version written concurrently with the delete: newer than the deleted entry but older than the delete itself. The source's own replay applies the delete over it, so keeping the backup copy because it outranks the deleted entry left a file the source no longer has. The sink now gets the delete's mutation time (MutationTsNs, else TsNs) and keeps the destination only when the live entry was committed after it, the order Filer.Replay keeps. That also covers a stamped replacement of an unstamped entry whose mtime did not move. filer.replicate events carry no time, so they keep the deleted entry's stamp as the bound, and mtime only when nothing is stamped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * replication: count an unstamped live entry from its mtime A source filer that predates commit stamps stores entries with no CommitTsNs, so comparing the live stamp with the delete's time never kept a replacement there. An unstamped live entry now counts from its mtime against the delete's time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * replication: keep a stamped live entry when the deleted one is unstamped and the delete has no time filer.replicate gets no delete time from the notification queue. When the deleted entry has no commit stamp either, a stamped live entry was written after it, so its mtime no longer decides. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
fcfca3fee3 |
s3, filer: bound the wait for an upload slot (#12559)
* util: add WaitUntil, a cond wait bounded by a context and a timeout The caller holds the cond lock. Cancellation and the timeout wake the waiter through a broadcast taken under the same lock, so no wakeup is lost. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: bound the wait for an upload slot A PUT that arrived while the concurrent upload limits were exhausted waited on the condition variable with no bound. The handler reads nothing from the body while it waits, so a client that gave up and reset its connection went unnoticed: the socket and goroutine stayed pinned until a slot freed, and a stalled volume server grew the gateway's fd count by one per aborted PUT. The wait now ends on InflightUploadDataTimeout with 503 SlowDown, which S3 SDKs retry, and on request cancellation. An admitted upload takes its slot under the lock, and a finished upload broadcasts, so freed bytes admit every waiter that fits instead of one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: bound the wait for an upload slot The filer's PUT/POST upload limits queued requests the same unbounded way. Reuse the bounded wait: reject with 429 after InflightUploadDataTimeout, as the volume server does, and stop on request cancellation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * command: add -inflightUploadDataTimeout for the S3 gateway and the filer weed s3 -inflightUploadDataTimeout, weed filer -inflightUploadDataTimeout and -s3.inflightUploadDataTimeout, weed server and weed mini -filer.inflightUploadDataTimeout and -s3.inflightUploadDataTimeout. The default of 60s matches the volume server's flag of the same name; 0 keeps the old unbounded wait. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: reject a queued upload without reading its body WriteErrorResponse drains the request body before answering. Behind the stats recorder the drain has no read deadline, and reading the body sends an Expect: 100-continue client the go-ahead to upload what is about to be discarded. Answer the rejection with an empty-body copy of the request so the drain is skipped; net/http closes the connection when a large unread body remains. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3, filer: release an upload slot under the cond lock A waiter checks the counters under the cond lock and then waits. A release that decremented and broadcast without the lock could land between the two, so the waiter slept with a slot free until the next release or its timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3, filer: close the HTTP/1 connection when rejecting a queued upload net/http reads up to 256 KiB of an unread request body before sending a keep-alive reply, so a client that stalls its body held back the 503 or 429 until the connection idle timeout. Connection: close skips that read. HTTP/2 is left alone: there it would shut down the whole connection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
b11af30cb1 |
mount: remove the local control socket when the mount exits (#12560)
* mount: remove the local control socket when the mount exits weed mount listened on /tmp/seaweedfs-mount-<hash>.sock and removed it only when a later mount of the same directory started, so every unmount or SIGTERM left one socket file behind. Remove it on the normal return path and in the interrupt hook, unless a later mount of the same directory has already replaced it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: remove the control socket before a failed mount exits glog.Fatalf and glog.Exitf call os.Exit, which skips the deferred removal, so a mount that failed after creating its socket (mount point not available, fusermount failure) still left it behind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: register the socket cleanup hook before mount setup A SIGTERM that arrived while the mount was still setting up, for example waiting on the filer to create the mount root, exited through grace without running the deferred cleanup. Registering the hook right after the listener is created makes it run last, after the unmount and filesystem hooks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
e9606c8ecc |
filer.meta.backup: resume an interrupted metadata copy and add -entriesPerSecond (#12549)
* filer_pb: add a depth-first traversal that can resume after a path TraverseDfs walks a tree in listing order and reports each finished path, so a caller can save one path and continue from it later. Pages are read whole before visiting, and the entries of a page are visited by up to five workers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.meta.backup: resume an interrupted metadata copy The walk saves the last finished path every few seconds, and a walk that continues an unfinished one starts after it. A fresh walk clears the saved path first, and a finished walk clears it with the walk start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.meta.backup: add -entriesPerSecond to throttle the metadata copy Each entry the full copy reads waits on a rate limiter, and pages are listed only after the previous page is copied, so the flag also bounds how fast the copy lists the source filer. 0 keeps it unlimited. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer_pb: report each file of a depth-first walk once all before it are done A throttled walk only reported progress after a whole listing page, so a slow copy could go many minutes without a resumable path. Visit entries in runs that end at a directory and report each file as soon as every entry before it is done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |