mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
a16ca18ae083d50bf03c8865262ca20f2ce2e8ff
7
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a963c1309c |
worker: purge the filer metadata log from a lifecycle job that keeps it past every TTL (#13101)
* worker: share the one-filer-per-store selection with other filer jobs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: add a meta_log_purge job that keeps the log past every TTL The job deletes whole metadata log days once per filer store, keeping every day that the longest filer.conf TTL, the longest S3 lifecycle rule, a registered retention floor or a running replay job's cursor still needs. A floor input that cannot be read stops the run before anything is deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: register meta_log_purge in the lifecycle lane Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * maintenance: stop purging the metadata log from the default scripts The meta_log_purge job now deletes old log days, keeping what TTLs, lifecycle rules and replay jobs still need. fs.log.purge stays for manual use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: let an idle filer_ttl rule's read position release the log filer_ttl no longer needs events up to read_ns, and an idle rule keeps an old ts_ns while read_ns advances, so the floor follows the later of the two. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: cap min_retention_days so a huge value cannot overflow Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: show the min_retention_days limit in the admin form Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: give a registered retention floor the store's filer client A floor that only gets a context cannot tell which cluster or store it answers for, so it cannot ask that cluster's master or read the store's own settings. Pass the filer client the job already holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: keep the log an unfinished lifecycle walk will replay A cold-start or recovery walk that resumes across runs rewinds its shard cursor to the walk's start minus the longest lifecycle TTL once it completes. Until then only its walk checkpoint records that start, so a walk running for more than a day let the purge delete the creation events the rewound replay reads. A checkpoint with buckets done or partly walked now holds the floor at started_ns minus that TTL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: hold the walk start until the checkpoint goes stale A walk clears its checkpoint in finish() before each of its shards saves the rewound cursor, so a purge scan that read the old shard cursor and then the cleared checkpoint saw neither. A cleared checkpoint keeps started_ns, so every live checkpoint now holds the floor at its start minus the longest lifecycle TTL. A finished one stops holding once it has not been saved for cursorStaleAfter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: read walk checkpoints before the shard cursors they rewind A purge scan that read a shard cursor, then a checkpoint that a later walk had already replaced, saw neither the earlier walk's hold nor the rewind its shards saved. A walk replaces its checkpoint only after the previous walk's rewind is on disk, so reading the checkpoints first always sees one of the two. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * lifecycle: save a fresh walk's checkpoint at its first progress A walk that progressed during its first save interval and then stalled for more than a day had no checkpoint on disk, so the metadata log purge saw nothing holding the days its completion replays. A fresh walk now saves on its first finished entry or bucket; a resumed walk already has its record on disk and keeps the interval. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * lifecycle: rewrite an unchanged shard cursor so its mtime stays fresh A shard stuck on RETRY_LATER saved identical bytes each pass, and SaveInsideFiler skips identical content, so the file's mtime aged past the meta log purge's staleness cutoff while the shard still needed it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: keep the log day a reader from the cursor lists first Log files are named for their flush start, so a file from just before midnight holds events after a cursor just past it. The reader backs off one flush interval before choosing its first day; the purge now does too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: stop the meta log purge on an unreadable lifecycle policy LoadCompileInputs reports a bucket whose lifecycle XML does not parse separately from its error, so the purge used the shorter floors and deleted days that bucket's rules may need once the policy is fixed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: read shard cursors with the replay's loader in the meta log purge A shard cursor the replay refuses, such as an empty object, decoded as a zero position and released the purge; it now stops the run instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: saturate the meta log purge's TTL plus a day A lifecycle TTL near the largest duration wrapped negative once a day was added, so the purge fell back to the shorter floors; the walk hold at started_ns minus that TTL likewise dropped below zero and was lost. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: leave disabled lifecycle rules out of the meta log purge floor AllActivePriorStates activates every compiled rule, so a disabled rule still held the log for its TTL, and disabling it could not release it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker: compute the meta log purge floor in SafeKeepFrom Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: fs.log.purge keeps the logs the meta log purge floor needs unless -force Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: run the fs.log.purge floor test without a master client Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
a9fda6b50f |
filer clients: authenticate filer gRPC calls with per-call admin tokens (#13039)
* Add per-call filer authentication sources and pooled client wrappers * Authenticate gateway filer calls with per-call admin tokens * Authenticate shell admin and synchronization filer calls * Authenticate workers MQ and remaining filer client paths * Cache filer client signing keys and sign subscriptions with the shared key Re-reading security.toml on every filer RPC cost about 125us against 8us for signing. Keep the keys for up to a second, re-reading at once when a WEED_ override or the configuration directory changes. When the file exists but cannot be read, keep the last keys read, else the startup keys, as FilerAdminKeys does, so a process without a key stays tokenless. Metadata subscriptions prefer the shared key, as filer peers do, because older filers verify subscription admin tokens only with it. * Authenticate admin-script, maintenance and filer.conf shell paths Plugin worker admin scripts and master maintenance scripts build their own shell options and carried no filer token source; fs.configure and s3.bucket.quota.check read filer.conf without it. * filer.cat: report a failed read; isolate key overrides in the admin-script test filer.cat ignored the error from its filer call and exited successfully, leaving a truncated -output file. Report the error and exit with failure. The admin-script token test now clears the WEED_ signing-key overrides, which take precedence over security.toml. * security: refuse gRPC keys too short to sign; query engine uses client TLS Under GODEBUG=fips140=only, hmac.New panics on keys under 14 bytes. The startup check now covers jwt.filer_signing.grpc_key and grpc_previous_key, and filer client token sources check the keys they read, so a reloaded or per-endpoint security file with a short key is refused instead of panicking when the next RPC signs. The query engine's broker client dialed every master, filer and broker in plaintext, so the admin token it now sends could cross the network in the clear. It dials with the grpc.client TLS settings instead, and weed-sql loads security.toml as weed-db does. * security: per-endpoint admin tokens ignore WEED_ key overrides FilerAdminTokenFromFile honored WEED_JWT_FILER_SIGNING_GRPC_KEY and WEED_JWT_FILER_SIGNING_KEY. Those are process-wide, so filer.sync with -a.security and -b.security signed both clusters' admin tokens with the one key, handing each cluster a token valid on the other. A per-endpoint file now supplies its own keys only. * weed-sql, weed-db: refuse to start on an unreadable security.toml Both only warned when security.toml was present but could not be read or parsed. They then dialed without the grpc.client TLS settings while the filer token source could still sign admin tokens from WEED_ environment keys, so the tokens could travel in plaintext. They now exit with an error that does not quote the file; a missing file is still fine. * pb: take the filer token source in WithGrpcFilerClient and WithOneOfGrpcFilerClients Fold WithGrpcFilerClientAuth and WithOneOfGrpcFilerClientsAuth into the existing helpers instead of keeping two names for each. Callers without a token source pass nil. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: return the read error from ReadConfiguration Fold ReadConfigurationWithError into ReadConfiguration. The error is returned and not logged, since parser errors can quote values; the existing reload callers already warn when no file was read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: keep the test-only filerAdminToken helper in the test It had no production caller. The test helper now resolves keys through filerClientKeysFrom, as the token sources do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: read security.toml once in LoadSecurityConfigurationOrError It validated the file, then merged it with a second read whose failure was ignored and whose parser error was logged. It now merges with one read and logs nothing from the parser. Viper's search also treats a directory the process cannot search as holding no file; a candidate that cannot be checked for lack of permission is now refused too. * security: verify admin subscription tokens with the gRPC clock leeway CheckGrpcMetadataSubscription checked admin tokens strictly, while unary filer calls allow jwt.filer_signing.clock_leeway_seconds. With ten-second client admin tokens, a subscriber whose clock trailed the filer's by more than ten seconds was refused with a matching key. It now takes the leeway, and the filer passes its configured one. The leeway check moves from the server package to security.IsFilerAdminTokenWithLeeway so both use it. * util: start without security.toml only when every candidate is confirmed absent A candidate whose check fails for any reason other than not existing, such as a symlink loop, is refused like one the process cannot search. --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
4ed9595a58 |
admin: explain detection cooldowns and skipped scans (#12185)
* plugin: describe detection cooldowns and report skipped scans * admin: expose cooldown eligibility and preserve skipped detection outcomes * admin: show cooldown eligibility alongside maintenance lock waits * plugin: retain cooldown activity for older admin servers * admin: keep manual detection skips out of scheduler run state * plugin: refresh descriptors on reconnect without downgrading saved schemas * plugin: allow valid schema refreshes to repair corrupt descriptors * admin: store eligible_after activity detail as RFC3339 * worker: report admin_script interval skips as skipped detection * worker: report admin_script interval skips after the last completed job * admin: show the selected job's cooldown while scheduling is disabled * admin: report an unsigned interval skip instead of a completed scan * worker: populate new DetectionComplete fields in Rust senders Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> |
||
|
|
87fdea5330 |
fix(admin): carry filer addresses as ServerAddress in plugin cluster context (#9600)
The plugin cluster context forwarded filers as gRPC-only addresses (host:grpcPort). The admin-script worker stored that in ShellOptions.FilerAddress, whose shell commands re-derive the gRPC port via ToGrpcAddress() and re-add the +10000 offset, dialing a non-existent host:28888. Carry filers in pb.ServerAddress form (host:httpPort.grpcPort) and let each consumer convert when it dials: the admin shell uses it verbatim, while the s3_lifecycle and iceberg workers collapse it to a gRPC address. Rename the proto field filer_grpc_addresses -> filer_addresses so the name matches the content. |
||
|
|
5d43f84df7 |
refactor(plugin): rename detection_interval_seconds → detection_interval_minutes (#9366)
Minutes is the natural granularity for detection cadence — every production handler already set the seconds field to a 60-multiple (17*60, 30*60, 3600, 24*60*60). Switching to minutes drops the *60 arithmetic and matches the unit conventions used elsewhere in the plugin worker forms. - Proto: AdminRuntimeDefaults + AdminRuntimeConfig.detection_interval_* field renamed. - Helpers: durationFromMinutes / minutesFromDuration alongside the existing seconds variants in plugin_scheduler.go. - Handlers: vacuum, ec_balance, balance, erasure_coding, iceberg, admin_script, s3_lifecycle now declare DetectionIntervalMinutes. - Admin: scheduler_status + types + UI templ + plugin_api.go pass through the new field; UI label and table cells switch to "min". |
||
|
|
1f6f473995 |
refactor(worker): co-locate plugin handlers with their task packages (#9301)
* refactor(worker): co-locate plugin handlers with their task packages
Move every per-task plugin handler from weed/plugin/worker/ into the
matching weed/worker/tasks/<name>/ package, so each task owns its
detection, scheduling, execution, and plugin handler in one place.
Step 0 (within pluginworker, no behavior change): extract shared helpers
that previously lived inside individual handler files into dedicated
files and export the ones now consumed across packages.
- activity.go: BuildExecutorActivity, BuildDetectorActivity
- config.go: ReadStringConfig/Double/Int64/Bytes/StringList, MapTaskPriority
- interval.go: ShouldSkipDetectionByInterval
- volume_state.go: VolumeState + consts, FilterMetricsByVolumeState/Location
- collection_filter.go: CollectionFilterMode + consts
- volume_metrics.go: export CollectVolumeMetricsFromMasters,
MasterAddressCandidates, FetchVolumeList
- testing_senders_test.go: shared test stubs
Phase 1: move the per-task plugin handlers (and the iceberg subpackage)
into their task packages.
weed/plugin/worker/vacuum_handler.go -> weed/worker/tasks/vacuum/plugin_handler.go
weed/plugin/worker/ec_balance_handler.go -> weed/worker/tasks/ec_balance/plugin_handler.go
weed/plugin/worker/erasure_coding_handler.go -> weed/worker/tasks/erasure_coding/plugin_handler.go
weed/plugin/worker/volume_balance_handler.go -> weed/worker/tasks/balance/plugin_handler.go
weed/plugin/worker/iceberg/ -> weed/worker/tasks/iceberg/
weed/plugin/worker/handlers/handlers.go now blank-imports all five
task subpackages so their init() registrations fire.
weed/command/mini.go and the worker tests construct the handler with
vacuum.DefaultMaxExecutionConcurrency (the constant moved with the
vacuum handler).
admin_script remains in weed/plugin/worker/ because there is no
underlying weed/worker/tasks/admin_script/ package to merge with.
* refactor(worker): update test/plugin_workers imports for moved handlers
Three handler constructors moved out of pluginworker into their task
packages — update the integration test files in test/plugin_workers/
to import from the new locations:
pluginworker.NewVacuumHandler -> vacuum.NewVacuumHandler
pluginworker.NewVolumeBalanceHandler -> balance.NewVolumeBalanceHandler
pluginworker.NewErasureCodingHandler -> erasure_coding.NewErasureCodingHandler
The pluginworker import is kept where the file still uses
pluginworker.WorkerOptions / pluginworker.JobHandler.
* refactor(worker): update test/s3tables iceberg import path
The iceberg subpackage moved from weed/plugin/worker/iceberg/ to
weed/worker/tasks/iceberg/. test/s3tables/maintenance/maintenance_integration_test.go
still imported the old path, breaking S3 Tables / RisingWave / Trino /
Spark / Iceberg-catalog / STS integration test builds.
Mirrors the OSS-side fix needed by every job in the run that
transitively imports test/s3tables/maintenance.
* chore: gofmt PR-touched files
The S3 Tables Format Check job runs `gofmt -l` over weed/s3api/s3tables
and test/s3tables, then fails if anything is unformatted. Files this
PR moved or modified had import-grouping and trailing-spacing issues
introduced by perl-based renames; reformat them with gofmt -w.
Touched files:
test/plugin_workers/erasure_coding/{detection,execution}_test.go
test/s3tables/maintenance/maintenance_integration_test.go
weed/plugin/worker/handlers/handlers.go
weed/worker/tasks/{balance,ec_balance,erasure_coding,vacuum}/plugin_handler*.go
* refactor(worker): bounds-checked int conversions for plugin config values
CodeQL flagged 18 go/incorrect-integer-conversion warnings on the moved
plugin handler files: results of pluginworker.ReadInt64Config (which
ultimately calls strconv.ParseInt with bit size 64) were being narrowed
to int32/uint32/int without an upper-bound check, so a malicious or
malformed admin/worker config value could overflow the target type.
Add three helpers in weed/plugin/worker/config.go that wrap
ReadInt64Config and clamp out-of-range values back to the caller's
fallback:
ReadInt32Config (math.MinInt32 .. math.MaxInt32)
ReadUint32Config (0 .. math.MaxUint32)
ReadIntConfig (math.MinInt32 .. math.MaxInt32, platform-portable)
Update each flagged call site in the four moved task packages to use
the bounds-checked helper. For protobuf uint32 fields (volume IDs)
the variable type also becomes uint32, removing the trailing
uint32(volumeID) casts and changing the "missing volume_id" check
from `<= 0` to `== 0`.
Touched files:
weed/plugin/worker/config.go
weed/worker/tasks/balance/plugin_handler.go
weed/worker/tasks/erasure_coding/plugin_handler.go
weed/worker/tasks/vacuum/plugin_handler.go
* refactor(worker): use ReadIntConfig for clamped derive-worker-config helpers
CodeQL still flagged three call sites where ReadInt64Config was being
narrowed to int after a value-range clamp (max_concurrent_moves <= 50,
batch_size <= 100, min_server_count >= 2). The clamp is correct but
CodeQL's flow analysis didn't recognize the bound, so it flagged them
as unbounded narrowing.
Switch to ReadIntConfig (already int32-bounded by the helper) for
those three sites, drop the now-redundant int64 intermediate variables.
Also drops the now-unused `> math.MaxInt32` clamp in
ec_balance.deriveECBalanceWorkerConfig (the helper covers it).
|
||
|
|
e1e5b4a8a6 |
add admin script worker (#8491)
* admin: add plugin lock coordination
* shell: allow bypassing lock checks
* plugin worker: add admin script handler
* mini: include admin_script in plugin defaults
* admin script UI: drop name and enlarge text
* admin script: add default script
* admin_script: make run interval configurable
* plugin: gate other jobs during admin_script runs
* plugin: use last completed admin_script run
* admin: backfill plugin config defaults
* templ
Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
* comparable to default version
Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
* default to run
Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
* format
Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
* shell: respect pre-set noLock for fix.replication
* shell: add force no-lock mode for admin scripts
* volume balance worker already exists
Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
* admin: expose scheduler status JSON
* shell: add sleep command
* shell: restrict sleep syntax
* Revert "shell: respect pre-set noLock for fix.replication"
This reverts commit
|