mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-15 02:50:45 +02:00
* refactor(s3/lifecycle): drop Per-Run Time Limit knob; use scheduler's Execution Timeout "Per-Run Time Limit (minutes)" duplicated the admin scheduler's "Execution Timeout (s)" — both are wall-clock caps on the same Execute call, stacked via context.WithTimeout. Whichever was shorter won. Under defaults the scheduler's 90s timeout always clobbered the worker's 60-min cap, so the "Per-Run Time Limit" knob was effectively dead unless an operator also raised Execution Timeout, and operators had to keep two values in agreement. Remove the worker-side knob and declare a sane scheduler default on the handler descriptor: - WorkerConfigForm: nil (was: one section with one field) - Config.MaxRuntime removed; ParseConfig drops max_runtime_minutes - Handler no longer wraps ctx in context.WithTimeout(MaxRuntime); runCtx is just the ctx the scheduler passes - AdminRuntimeDefaults.ExecutionTimeoutSeconds = 3600 (1h) and JobTypeMaxRuntimeSeconds = 3600 — the scheduler's global 90s default would otherwise kill every real run Tests: - TestParseConfigDefaults loses the MaxRuntime check; new TestParseConfigIgnoresWorkerValues documents the contract - TestDescriptor_WorkerConfigFormIsAbsent pins that the form is gone so a future re-add forces a conscious revisit - TestDescriptor_AdminRuntimeDefaultsBoundExecutionTimeout pins the 1h default with a comment about the 90s scheduler floor * fix(s3/lifecycle): no per-pass timeout by default Lifecycle is a scheduled batch — its natural duration is "as long as today's events take." The 1h default ExecutionTimeoutSeconds from the previous commit was still a footgun: too low truncates legitimate large-bucket passes; too high makes the value meaningless. Set both ExecutionTimeoutSeconds and JobTypeMaxRuntimeSeconds to math.MaxInt32 (~68 years) to say "no timeout in practice" in a code-review-readable way. Operators who genuinely want a wall-clock cap can set one in the admin UI; the scheduler's context.WithTimeout machinery is unchanged (we just hand it an effectively-infinite duration). Note: the scheduler floors ExecutionTimeout at 90s (defaultScheduledExecutionTimeout in weed/admin/plugin/plugin_scheduler.go), so 0 doesn't mean "unlimited" — it clamps back to 90s. A literal math.MaxInt32 is the way to express the intent without touching the shared scheduler code. Test updated to pin math.MaxInt32 and document the rationale so a future tighter cap fails the test and forces conscious revisit.
63 lines
2.0 KiB
Go
63 lines
2.0 KiB
Go
package s3_lifecycle
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/plugin_pb"
|
|
)
|
|
|
|
const (
|
|
jobType = "s3_lifecycle"
|
|
|
|
// In-process fan-out across the 16 shards.
|
|
shardPipelineGoroutines = 1
|
|
)
|
|
|
|
type Config struct {
|
|
Workers int
|
|
MetaLogRetention time.Duration
|
|
// WalkerInterval is the minimum time between steady-state walker
|
|
// fires per shard. 0 means "fire on every run", preserving prior
|
|
// behavior; positive values gate the walker via Cursor.LastWalkedNs
|
|
// inside dailyrun.runShard.
|
|
WalkerInterval time.Duration
|
|
}
|
|
|
|
func ParseConfig(adminValues map[string]*plugin_pb.ConfigValue, workerValues map[string]*plugin_pb.ConfigValue) Config {
|
|
cfg := Config{
|
|
Workers: shardPipelineGoroutines,
|
|
}
|
|
_ = workerValues // worker-side config form is currently empty; reserved for future per-worker tuning.
|
|
// Operator-declared meta-log retention. Negative or zero values stay
|
|
// zero so runShard falls back to maxTTL (PromotedHash dormant).
|
|
// Convert days->hours in int64 space before lifting to time.Duration
|
|
// so the unit is unambiguous.
|
|
if days := readInt64(adminValues, MetaLogRetentionDaysAdminKey, 0); days > 0 {
|
|
cfg.MetaLogRetention = time.Duration(days*24) * time.Hour
|
|
}
|
|
// Walker throttle. Negative / zero stay zero so dailyrun.runShard
|
|
// keeps the prior "fire every pass" semantics — important for in-
|
|
// repo integration tests and s3tests's sub-minute driver. Positive
|
|
// values throttle the steady-state walker per shard.
|
|
if mins := readInt64(adminValues, WalkerIntervalMinutesAdminKey, 0); mins > 0 {
|
|
cfg.WalkerInterval = time.Duration(mins) * time.Minute
|
|
}
|
|
return cfg
|
|
}
|
|
|
|
func readInt64(values map[string]*plugin_pb.ConfigValue, field string, fallback int64) int64 {
|
|
v, ok := values[field]
|
|
if !ok || v == nil {
|
|
return fallback
|
|
}
|
|
switch k := v.Kind.(type) {
|
|
case *plugin_pb.ConfigValue_Int64Value:
|
|
return k.Int64Value
|
|
case *plugin_pb.ConfigValue_DoubleValue:
|
|
return int64(k.DoubleValue)
|
|
case *plugin_pb.ConfigValue_StringValue:
|
|
return fallback
|
|
}
|
|
return fallback
|
|
}
|