mirror of
https://github.com/hanzoai/s3.git
synced 2026-10-30 14:59:09 +00:00
hanzoai/s3 was an AGPL-3.0 MinIO fork whose network-copyleft blocks embedding
and reselling as a managed service. Replace it wholesale with a fork of
SeaweedFS (github.com/seaweedfs/seaweedfs, Apache-2.0, Go) which ships a
built-in S3 gateway + Filer.
- License: AGPL-3.0 -> Apache-2.0 (upstream LICENSE kept verbatim, incl.
"Copyright 2025 Chris Lu"); NOTICE added crediting SeaweedFS. No AGPL/BUSL/
SSPL/GPL or enterprise ("ee") files remain.
- Module: go.mod path set to github.com/hanzoai/s3 with a self-replace
(replace github.com/seaweedfs/seaweedfs => ./) so the ~1800 internal Go files
keep their upstream import paths with zero churn. Internal identifiers and
import paths are intentionally NOT renamed.
- CLI rebrand: the binary is built as `s3` (was `weed`); root usage, per-command
help/usage/flag strings, shell autocomplete program name, and the product name
in CLI output now read "Hanzo S3" / `s3`. Users never see `weed`.
(e.g. `s3 server`, `s3 filer`, `s3 master`, `s3 volume`, `s3 s3`, `s3 mount`.)
- Build: `make` (or `go build -o s3 ./weed`) builds the `s3` binary green;
`cmd/weed-db` and `cmd/weed-sql` also build; `go vet ./weed/command/` clean.
- README/LLM.md rewritten for Hanzo S3; AGENTS.md/CLAUDE.md symlinks preserved.
- Dropped a 33MB prebuilt Mach-O `stress` binary upstream had committed; `.gitignore`
updated to ignore the `s3` build output.
128 lines
4.2 KiB
Go
128 lines
4.2 KiB
Go
package dash
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/glog"
|
|
"github.com/seaweedfs/seaweedfs/weed/util"
|
|
"github.com/seaweedfs/seaweedfs/weed/worker/tasks/balance"
|
|
"github.com/seaweedfs/seaweedfs/weed/worker/tasks/base"
|
|
"github.com/seaweedfs/seaweedfs/weed/worker/tasks/erasure_coding"
|
|
"github.com/seaweedfs/seaweedfs/weed/worker/tasks/vacuum"
|
|
)
|
|
|
|
// TomlConfig is the subset of viper used to read admin.toml values.
|
|
type TomlConfig interface {
|
|
IsSet(key string) bool
|
|
GetBool(key string) bool
|
|
GetInt(key string) int
|
|
GetFloat64(key string) float64
|
|
GetString(key string) string
|
|
GetStringSlice(key string) []string
|
|
}
|
|
|
|
// ApplyMaintenanceConfigFromToml writes maintenance task settings declared in
|
|
// admin.toml through to the persisted task configs, so they survive data
|
|
// directory loss and override admin UI edits on restart. Absent keys keep
|
|
// their persisted values.
|
|
func (cp *ConfigPersistence) ApplyMaintenanceConfigFromToml(v TomlConfig) error {
|
|
vacuumConf := vacuum.LoadConfigFromPersistence(cp)
|
|
vacuumChanged := applyBaseConfigFromToml(v, "maintenance.vacuum.", &vacuumConf.BaseConfig)
|
|
if k := "maintenance.vacuum.garbage_threshold"; v.IsSet(k) {
|
|
vacuumConf.GarbageThreshold = v.GetFloat64(k)
|
|
vacuumChanged = true
|
|
}
|
|
if k := "maintenance.vacuum.min_volume_age_seconds"; v.IsSet(k) {
|
|
vacuumConf.MinVolumeAgeSeconds = v.GetInt(k)
|
|
vacuumChanged = true
|
|
}
|
|
|
|
balanceConf := balance.LoadConfigFromPersistence(cp)
|
|
balanceChanged := applyBaseConfigFromToml(v, "maintenance.balance.", &balanceConf.BaseConfig)
|
|
if k := "maintenance.balance.imbalance_threshold"; v.IsSet(k) {
|
|
balanceConf.ImbalanceThreshold = v.GetFloat64(k)
|
|
balanceChanged = true
|
|
}
|
|
if k := "maintenance.balance.min_server_count"; v.IsSet(k) {
|
|
balanceConf.MinServerCount = v.GetInt(k)
|
|
balanceChanged = true
|
|
}
|
|
|
|
ecConf := erasure_coding.LoadConfigFromPersistence(cp)
|
|
ecChanged := applyBaseConfigFromToml(v, "maintenance.erasure_coding.", &ecConf.BaseConfig)
|
|
if k := "maintenance.erasure_coding.fullness_ratio"; v.IsSet(k) {
|
|
ecConf.FullnessRatio = v.GetFloat64(k)
|
|
ecChanged = true
|
|
}
|
|
if k := "maintenance.erasure_coding.quiet_for_seconds"; v.IsSet(k) {
|
|
ecConf.QuietForSeconds = v.GetInt(k)
|
|
ecChanged = true
|
|
}
|
|
if k := "maintenance.erasure_coding.min_size_mb"; v.IsSet(k) {
|
|
ecConf.MinSizeMB = v.GetInt(k)
|
|
ecChanged = true
|
|
}
|
|
if k := "maintenance.erasure_coding.collection_filter"; v.IsSet(k) {
|
|
ecConf.CollectionFilter = v.GetString(k)
|
|
ecChanged = true
|
|
}
|
|
if k := "maintenance.erasure_coding.preferred_tags"; v.IsSet(k) {
|
|
// viper does not split comma-separated values from env vars
|
|
var tags []string
|
|
for _, tag := range v.GetStringSlice(k) {
|
|
tags = append(tags, strings.Split(tag, ",")...)
|
|
}
|
|
ecConf.PreferredTags = util.NormalizeTagList(tags)
|
|
ecChanged = true
|
|
}
|
|
if k := "maintenance.erasure_coding.replica_placement"; v.IsSet(k) {
|
|
ecConf.ReplicaPlacement = v.GetString(k)
|
|
ecChanged = true
|
|
}
|
|
|
|
if !vacuumChanged && !balanceChanged && !ecChanged {
|
|
return nil
|
|
}
|
|
if !cp.IsConfigured() {
|
|
return fmt.Errorf("admin.toml maintenance settings require -dataDir to persist")
|
|
}
|
|
|
|
if vacuumChanged {
|
|
if err := cp.SaveVacuumTaskPolicy(vacuumConf.ToTaskPolicy()); err != nil {
|
|
return fmt.Errorf("save vacuum task config: %w", err)
|
|
}
|
|
glog.V(0).Infof("Applied [maintenance.vacuum] settings from admin.toml")
|
|
}
|
|
if balanceChanged {
|
|
if err := cp.SaveBalanceTaskPolicy(balanceConf.ToTaskPolicy()); err != nil {
|
|
return fmt.Errorf("save balance task config: %w", err)
|
|
}
|
|
glog.V(0).Infof("Applied [maintenance.balance] settings from admin.toml")
|
|
}
|
|
if ecChanged {
|
|
if err := cp.SaveErasureCodingTaskPolicy(ecConf.ToTaskPolicy()); err != nil {
|
|
return fmt.Errorf("save erasure coding task config: %w", err)
|
|
}
|
|
glog.V(0).Infof("Applied [maintenance.erasure_coding] settings from admin.toml")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func applyBaseConfigFromToml(v TomlConfig, prefix string, c *base.BaseConfig) bool {
|
|
changed := false
|
|
if k := prefix + "enabled"; v.IsSet(k) {
|
|
c.Enabled = v.GetBool(k)
|
|
changed = true
|
|
}
|
|
if k := prefix + "scan_interval_seconds"; v.IsSet(k) {
|
|
c.ScanIntervalSeconds = v.GetInt(k)
|
|
changed = true
|
|
}
|
|
if k := prefix + "max_concurrent"; v.IsSet(k) {
|
|
c.MaxConcurrent = v.GetInt(k)
|
|
changed = true
|
|
}
|
|
return changed
|
|
}
|