mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 02:57:37 +01:00
* 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>
132 lines
4.6 KiB
Rust
132 lines
4.6 KiB
Rust
//! What every integration test in this crate needs to drive a handler: a sender
|
|
//! that keeps what the handler sent, and the two settings that make a handler
|
|
//! usable against a test gateway.
|
|
//!
|
|
//! Each test binary compiles this module on its own and uses part of it.
|
|
#![allow(dead_code)]
|
|
|
|
use std::collections::HashMap;
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
use anyhow::Result;
|
|
use seaweed_worker_core::pb::ClusterContext;
|
|
use seaweed_worker_core::pb::{
|
|
ActivityEvent, ConfigValue, DetectionComplete, DetectionProposals, JobCompleted,
|
|
JobProgressUpdate, JobProposal, ObjectObservation, WorkerObservations, config_value::Kind,
|
|
};
|
|
use seaweed_worker_core::{ClusterObserver, DetectionSender, ExecutionSender};
|
|
use weed_lance_worker::admin_cluster::AdminCluster;
|
|
use weed_lance_worker::catalog::{NamespaceClient, SigningKey};
|
|
|
|
/// Keeps everything a handler reports, so a test can assert on it afterwards.
|
|
#[derive(Default)]
|
|
pub struct Recorder {
|
|
pub proposals: Mutex<Vec<JobProposal>>,
|
|
pub observations: Mutex<Vec<ObjectObservation>>,
|
|
pub completed: Mutex<Vec<JobCompleted>>,
|
|
}
|
|
|
|
impl DetectionSender for Recorder {
|
|
fn send_proposals(&self, proposals: DetectionProposals) -> Result<()> {
|
|
self.proposals.lock().unwrap().extend(proposals.proposals);
|
|
Ok(())
|
|
}
|
|
fn send_complete(&self, _complete: DetectionComplete) -> Result<()> {
|
|
Ok(())
|
|
}
|
|
fn send_activity(&self, _activity: ActivityEvent) -> Result<()> {
|
|
Ok(())
|
|
}
|
|
fn send_observations(&self, observations: WorkerObservations) -> Result<()> {
|
|
self.observations
|
|
.lock()
|
|
.unwrap()
|
|
.extend(observations.observations);
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
impl ExecutionSender for Recorder {
|
|
fn send_progress(&self, _progress: JobProgressUpdate) -> Result<()> {
|
|
Ok(())
|
|
}
|
|
fn send_completed(&self, completed: JobCompleted) -> Result<()> {
|
|
self.completed.lock().unwrap().push(completed);
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
/// The gateway to run against, or nothing, in which case the caller skips:
|
|
/// these handlers rewrite real files, and there is nothing to learn from them
|
|
/// against a fake.
|
|
pub fn namespace_url() -> Option<String> {
|
|
// The handlers say why they skip a table only in their logs.
|
|
let _ = tracing_subscriber::fmt()
|
|
.with_env_filter(
|
|
tracing_subscriber::EnvFilter::try_from_default_env()
|
|
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")),
|
|
)
|
|
.with_test_writer()
|
|
.try_init();
|
|
std::env::var("WEED_LANCE_NAMESPACE")
|
|
.ok()
|
|
.filter(|s| !s.is_empty())
|
|
}
|
|
|
|
pub fn int_config(name: &str, value: i64) -> HashMap<String, ConfigValue> {
|
|
let mut values = HashMap::new();
|
|
values.insert(
|
|
name.to_string(),
|
|
ConfigValue {
|
|
kind: Some(Kind::Int64Value(value)),
|
|
},
|
|
);
|
|
values
|
|
}
|
|
|
|
/// The cluster as admin would describe it to the worker: the namespace at
|
|
/// `url` and the filer WEED_FILER names, as the master lists it (`host:port` or
|
|
/// `host:port.grpc`). A live namespace without the filer would have the tests
|
|
/// seed tables through lance's own S3 store, which reaches nothing.
|
|
pub async fn cluster(url: &str) -> Arc<AdminCluster> {
|
|
let filer = std::env::var("WEED_FILER")
|
|
.ok()
|
|
.filter(|s| !s.is_empty())
|
|
.expect("WEED_LANCE_NAMESPACE names a live namespace; WEED_FILER must name its filer");
|
|
let connection =
|
|
weed_lance_worker::cluster::connection(&security(), String::new()).expect("security.toml");
|
|
let cluster = AdminCluster::new(connection, signing_key());
|
|
cluster
|
|
.observe(&ClusterContext {
|
|
lance_namespace_urls: vec![url.to_string()],
|
|
filer_addresses: vec![filer],
|
|
..Default::default()
|
|
})
|
|
.await;
|
|
Arc::new(cluster)
|
|
}
|
|
|
|
/// The cluster's storage, for seeding and reading tables beside a handler.
|
|
pub async fn storage() -> weed_lance_worker::dataset::Storage {
|
|
cluster(&namespace_url().unwrap_or_default())
|
|
.await
|
|
.storage()
|
|
.expect("storage")
|
|
}
|
|
|
|
fn security() -> weed_lance_worker::security::Security {
|
|
weed_lance_worker::security::Security::load(None).expect("security.toml")
|
|
}
|
|
|
|
/// The cluster token the namespace authenticates its processes by, from
|
|
/// `jwt.filer_signing.key` (WEED_JWT_FILER_SIGNING_KEY or security.toml),
|
|
/// as the worker reads it.
|
|
pub fn signing_key() -> Option<SigningKey> {
|
|
SigningKey::new(security().get("jwt.filer_signing.key"))
|
|
}
|
|
|
|
/// The namespace client the handlers would use.
|
|
pub fn client(url: &str) -> NamespaceClient {
|
|
NamespaceClient::new(url.to_string()).with_signing_key(signing_key().as_ref())
|
|
}
|