mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 19:17:28 +01:00
mini: run the vector engine by default, without failing when it is missing
-vector now defaults to true, so a plain weed mini starts weed-vector and weed-worker whenever they are installed. Both binaries are looked up before ports are reserved; one that is not found is logged and left out, and mini runs without it. A vector engine that fails to start is logged the same way instead of shutting mini down. -vector=false still leaves vector search out.
This commit is contained in:
1 parent
4901404050
commit
d63b7d5125
4 files changed
+64
-54
No files matched your search
@@ -30,11 +30,12 @@ Override `SEAWEEDFS_IMAGE` to test a newer image. With metrics-enabled engines,
|
||||
append `--metrics-port=9329 --metrics-ip=0.0.0.0` to the vector command and scrape
|
||||
`vector:9329/metrics` inside the Compose network.
|
||||
|
||||
A native development setup can use `weed mini -vector -vectorBucket=embeddings`
|
||||
with `weed-vector` beside `weed` or on PATH. `-vector.binary` selects an explicit
|
||||
binary, and `-vector.metricsPort=9329` enables HTTP readiness and metrics on a
|
||||
compatible engine. The child inherits the cluster's configuration directory and
|
||||
stops with mini. Mini also starts the `weed-worker` maintenance worker, found the
|
||||
same way, unless `-vector.worker=false`. `weed shell`
|
||||
provides `s3vectors -operation <Operation> -file request.json` for the same API
|
||||
operations using trusted cluster credentials.
|
||||
A native development setup can use `weed mini -vectorBucket=embeddings`. Mini
|
||||
starts `weed-vector` and the `weed-worker` maintenance worker when it finds them
|
||||
beside `weed` or on PATH, and logs and continues without one it cannot find.
|
||||
`-vector.binary` and `-vector.worker.binary` select explicit binaries,
|
||||
`-vector=false` and `-vector.worker=false` leave them out, and
|
||||
`-vector.metricsPort=9329` enables HTTP readiness and metrics on a compatible
|
||||
engine. The children inherit the cluster's configuration directory and stop with
|
||||
mini. `weed shell` provides `s3vectors -operation <Operation> -file
|
||||
request.json` for the same API operations using trusted cluster credentials.
|
||||
+5
-10
@@ -418,7 +418,7 @@ var (
|
||||
miniS3AutoCreateBucket = cmdMini.Flag.Bool("s3.autoCreateBucket", true, "create the bucket on upload if it does not exist, for admin identities only")
|
||||
miniBucket = cmdMini.Flag.String("bucket", "", "comma-separated S3 bucket names to create on startup if they do not already exist; leave empty to skip. Falls back to S3_BUCKET env var.")
|
||||
miniTableBucket = cmdMini.Flag.String("tableBucket", "", "comma-separated S3 Tables buckets to create on startup if they do not already exist, each name[:FORMAT] with FORMAT one of ICEBERG (default) or LANCE, e.g. warehouse,vectors:LANCE; leave empty to skip. Falls back to S3_TABLE_BUCKET env var.")
|
||||
miniVector = cmdMini.Flag.Bool("vector", false, "start the weed-vector engine for vector indexes and search")
|
||||
miniVector = cmdMini.Flag.Bool("vector", true, "start the weed-vector engine for vector indexes and search, when it is installed")
|
||||
miniVectorBinary = cmdMini.Flag.String("vector.binary", "weed-vector", "path to the vector engine binary")
|
||||
miniVectorPort = cmdMini.Flag.Int("vector.port", 8090, "vector engine gRPC port")
|
||||
miniVectorMetricsPort = cmdMini.Flag.Int("vector.metricsPort", 0, "optional vector HTTP health and metrics port")
|
||||
@@ -1492,7 +1492,7 @@ func runMini(cmd *Command, args []string) bool {
|
||||
// plaintext-KEK warning and the IAM "no signing key" error don't fire.
|
||||
// Does nothing for keys the operator has already configured.
|
||||
ensureMiniDevSSES3Keys(*miniDataFolders)
|
||||
prepareMiniVectorWorker()
|
||||
prepareMiniVector()
|
||||
|
||||
*miniOptions.cpuprofile = util.ResolvePath(*miniOptions.cpuprofile)
|
||||
*miniOptions.memprofile = util.ResolvePath(*miniOptions.memprofile)
|
||||
@@ -1744,14 +1744,9 @@ func runMini(cmd *Command, args []string) bool {
|
||||
}
|
||||
if *miniVector {
|
||||
if err := startMiniVector(); err != nil {
|
||||
glog.Errorf("start vector engine: %v", err)
|
||||
triggerMiniClientsShutdown(5 * time.Second)
|
||||
return false
|
||||
}
|
||||
if err := startMiniVectorWorker(); err != nil {
|
||||
glog.Errorf("start weed-worker: %v", err)
|
||||
triggerMiniClientsShutdown(5 * time.Second)
|
||||
return false
|
||||
glog.Errorf("vector engine not started, continuing without vector search: %v", err)
|
||||
} else if err := startMiniVectorWorker(); err != nil {
|
||||
glog.Errorf("weed-worker not started, continuing without vector index maintenance: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+22
-14
@@ -18,9 +18,9 @@ import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
)
|
||||
|
||||
// miniVectorWorkerPath is weed-worker's resolved path, empty when mini does
|
||||
// not start it.
|
||||
var miniVectorWorkerPath string
|
||||
// miniVectorPath and miniVectorWorkerPath are the resolved binaries, empty
|
||||
// for a component mini does not start.
|
||||
var miniVectorPath, miniVectorWorkerPath string
|
||||
|
||||
// lookMiniBinary finds a companion binary named by its default name next to
|
||||
// weed first, then on PATH; any other value is used as given.
|
||||
@@ -49,15 +49,26 @@ func miniSecurityToml(env string) string {
|
||||
return path
|
||||
}
|
||||
|
||||
// prepareMiniVectorWorker finds weed-worker before the S3 gateway starts. The
|
||||
// Lance Namespace trusts the worker only by a token signed with a key derived
|
||||
// from jwt.filer_signing.key, so when the cluster has none, the namespace and
|
||||
// the worker share a key made for this run.
|
||||
func prepareMiniVectorWorker() {
|
||||
if !*miniVector || !*miniVectorWorker {
|
||||
// prepareMiniVector finds weed-vector and weed-worker before ports are
|
||||
// reserved and the S3 gateway starts. A component that is not installed is
|
||||
// logged and left out. The Lance Namespace trusts the worker only by a token
|
||||
// signed with a key derived from jwt.filer_signing.key, so when the cluster
|
||||
// has none, the namespace and the worker share a key made for this run.
|
||||
func prepareMiniVector() {
|
||||
if !*miniVector {
|
||||
return
|
||||
}
|
||||
binary, err := lookMiniBinary(*miniVectorWorkerBinary, "weed-worker")
|
||||
binary, err := lookMiniBinary(*miniVectorBinary, "weed-vector")
|
||||
if err != nil {
|
||||
glog.Warningf("%s is unavailable, starting without vector search: install weed-vector or set -vector.binary: %v", *miniVectorBinary, err)
|
||||
*miniVector = false
|
||||
return
|
||||
}
|
||||
miniVectorPath = binary
|
||||
if !*miniVectorWorker {
|
||||
return
|
||||
}
|
||||
binary, err = lookMiniBinary(*miniVectorWorkerBinary, "weed-worker")
|
||||
if err != nil {
|
||||
glog.Warningf("%s is unavailable, so vector and metadata indexes will not be built: install weed-worker or set -vector.worker.binary: %v", *miniVectorWorkerBinary, err)
|
||||
return
|
||||
@@ -106,10 +117,7 @@ func startMiniVectorWorker() error {
|
||||
}
|
||||
|
||||
func startMiniVector() error {
|
||||
binary, err := lookMiniBinary(*miniVectorBinary, "weed-vector")
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s is unavailable: install the vector component or set -vector.binary: %w", *miniVectorBinary, err)
|
||||
}
|
||||
binary := miniVectorPath
|
||||
address := util.JoinHostPort(*miniIp, *miniVectorPort)
|
||||
bindIP := *miniBindIp
|
||||
if bindIP == "" {
|
||||
|
||||
@@ -9,40 +9,46 @@ import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
)
|
||||
|
||||
func TestPrepareMiniVectorWorker(t *testing.T) {
|
||||
oldVector, oldWorker, oldBinary, oldPath, oldKey := *miniVector, *miniVectorWorker, *miniVectorWorkerBinary, miniVectorWorkerPath, miniS3Options.lanceWorkerKey
|
||||
func TestPrepareMiniVector(t *testing.T) {
|
||||
oldVector, oldVectorBinary, oldWorker, oldWorkerBinary := *miniVector, *miniVectorBinary, *miniVectorWorker, *miniVectorWorkerBinary
|
||||
oldPaths, oldKey := [2]string{miniVectorPath, miniVectorWorkerPath}, miniS3Options.lanceWorkerKey
|
||||
defer func() {
|
||||
*miniVector, *miniVectorWorker, *miniVectorWorkerBinary, miniVectorWorkerPath, miniS3Options.lanceWorkerKey = oldVector, oldWorker, oldBinary, oldPath, oldKey
|
||||
*miniVector, *miniVectorBinary, *miniVectorWorker, *miniVectorWorkerBinary = oldVector, oldVectorBinary, oldWorker, oldWorkerBinary
|
||||
miniVectorPath, miniVectorWorkerPath, miniS3Options.lanceWorkerKey = oldPaths[0], oldPaths[1], oldKey
|
||||
}()
|
||||
dir := t.TempDir()
|
||||
worker, missing := filepath.Join(dir, "weed-worker"), filepath.Join(dir, "missing")
|
||||
if err := os.WriteFile(worker, []byte("#!/bin/sh\n"), 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
for _, name := range []string{"weed-vector", "weed-worker"} {
|
||||
if err := os.WriteFile(filepath.Join(dir, name), []byte("#!/bin/sh\n"), 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
vector, worker, missing := filepath.Join(dir, "weed-vector"), filepath.Join(dir, "weed-worker"), filepath.Join(dir, "missing")
|
||||
t.Setenv("PATH", dir)
|
||||
t.Setenv("WEED_JWT_FILER_SIGNING_KEY", "")
|
||||
defer util.GetViper().Set("jwt.filer_signing.key", "")
|
||||
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
vector, start bool
|
||||
binary string
|
||||
clusterKey string
|
||||
wantWorker string
|
||||
wantKey bool
|
||||
name string
|
||||
vector, startWorker bool
|
||||
vectorBinary, workerBinary string
|
||||
clusterKey string
|
||||
wantVector bool
|
||||
wantVectorPath, wantWorker string
|
||||
wantKey bool
|
||||
}{
|
||||
{"installed", true, true, "weed-worker", "", worker, true},
|
||||
{"cluster key configured", true, true, "weed-worker", "cluster-key", worker, false},
|
||||
{"not installed", true, true, missing, "", "", false},
|
||||
{"-vector.worker=false", true, false, "weed-worker", "", "", false},
|
||||
{"without -vector", false, true, "weed-worker", "", "", false},
|
||||
{"both installed", true, true, "weed-vector", "weed-worker", "", true, vector, worker, true},
|
||||
{"cluster key configured", true, true, "weed-vector", "weed-worker", "cluster-key", true, vector, worker, false},
|
||||
{"weed-worker not installed", true, true, "weed-vector", missing, "", true, vector, "", false},
|
||||
{"weed-vector not installed", true, true, missing, "weed-worker", "", false, "", "", false},
|
||||
{"-vector.worker=false", true, false, "weed-vector", "weed-worker", "", true, vector, "", false},
|
||||
{"-vector=false", false, true, "weed-vector", "weed-worker", "", false, "", "", false},
|
||||
} {
|
||||
*miniVector, *miniVectorWorker, *miniVectorWorkerBinary = tc.vector, tc.start, tc.binary
|
||||
miniVectorWorkerPath, miniS3Options.lanceWorkerKey = "", nil
|
||||
*miniVector, *miniVectorWorker, *miniVectorBinary, *miniVectorWorkerBinary = tc.vector, tc.startWorker, tc.vectorBinary, tc.workerBinary
|
||||
miniVectorPath, miniVectorWorkerPath, miniS3Options.lanceWorkerKey = "", "", nil
|
||||
util.GetViper().Set("jwt.filer_signing.key", tc.clusterKey)
|
||||
prepareMiniVectorWorker()
|
||||
if miniVectorWorkerPath != tc.wantWorker || (len(miniS3Options.lanceWorkerKey) == 64) != tc.wantKey {
|
||||
t.Errorf("%s: worker %q, key length %d", tc.name, miniVectorWorkerPath, len(miniS3Options.lanceWorkerKey))
|
||||
prepareMiniVector()
|
||||
if *miniVector != tc.wantVector || miniVectorPath != tc.wantVectorPath || miniVectorWorkerPath != tc.wantWorker || (len(miniS3Options.lanceWorkerKey) == 64) != tc.wantKey {
|
||||
t.Errorf("%s: vector %v %q, worker %q, key length %d", tc.name, *miniVector, miniVectorPath, miniVectorWorkerPath, len(miniS3Options.lanceWorkerKey))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user