mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-05 04:47:43 +00:00
98d3619613
* fix: address rc.1 release blockers
* fix: route release guards through architecture boundaries
* fix: close remaining rc.1 regression gaps
* refactor: group multipart listing options
* fix: resolve rc.1 CI regressions
* fix(ecstore): keep bucket-config writes off the caller's stack
A bucket-config write nests incarnation resolution (which can drive legacy
migration and a peer fan-out), a full metadata load, and `save` — itself an
object PUT that pulls in the whole erasure write path. Every request that
mutates bucket config is already several futures deep, so inlining all of
that into one state machine overflows the 2MiB worker stack in debug builds.
Two CI lanes aborted with SIGABRT on this:
ILM Integration (serial)
rustfs app::lifecycle_transition_api_test::
compensation_driven_complete_multipart_upload_still_transitions
Test and Lint (swift)
rustfs-protocols::swift_metadata_persistence::
swift_metadata_writes_are_durable
Neither test file is touched by this branch and both lanes are green on
main. Stack-pointer probing showed ~780KiB consumed between
`metadata_sys::update` and the config read alone, with single hops of
363KiB (`update` -> `acquire_config_write_guard_for_incarnation`), 125KiB
and 105KiB.
Box the deep sub-futures on both read-modify-write paths (`update` /
`update_checked` and `update_config_with` / `update_config_with_checked`)
so each guard's own state machine stays small. Behaviour is unchanged;
`update` -> guard drops to 253KiB and both tests pass on the default stack.
* fix(lifecycle): unbreak restore under the bucket generation fence
The ILM lane aborted on a stack overflow before reaching these, so they
were never reported; with that fixed, four restore tests fail. All four
are green on main and none of their test files are touched by this branch.
1. RestoreObject and ListMultipartUploads hard-required
`opts.expected_bucket_incarnation_id`, but `apply_bucket_generation_guard`
deliberately leaves it unset when no guard extension is present — only the
S3 access layer installs one. Every direct caller therefore got
`InternalError: ... bucket generation guard is missing`. Resolve the
current generation instead, the way the copy path already does. The fence
is unaffected: RestoreObject still re-reads the incarnation from disk and
compares before admitting the restore, and the multipart listing is
filtered by the value it resolves.
2. `restore_expiry_snapshot_matches` (new on this branch) rejected every
restored-copy expiry whose `restore_expires` had not already elapsed.
Whether the restored copy is due to expire is the ILM evaluator's
decision, made when it emitted DeleteRestoredAction; re-deriving it in
the set layer only adds a way for a legitimate action to be rejected.
The stale-event risk it appears to guard is already covered by the
surrounding snapshot match — a re-restore rewrites `restore_expires`,
so a replayed event fails the equality check. Drop the clause; the
fifteen identity clauses are unchanged.
Fixed:
rustfs app::lifecycle_transition_api_test::
restore_object_usecase_accepts_exactly_one_of_two_concurrent_restores
restore_object_usecase_completes_suspended_null_version_in_place
restore_object_usecase_reports_ongoing_conflict
rustfs-scanner::lifecycle_integration_test serial_tests::
test_restore_chain_local_read_expiry_keeps_remote_and_allows_re_restore
Verification: the CI ILM lane filter now runs 53/53 green locally.
* chore: address review follow-ups on this branch
Four items from the adversarial review that were still open.
- Restore the assertion `test_bucket_replication_replayed_delete_marker_
preserves_source_mtime_without_source_restart` is named for. The branch
had replaced the backlog#867 mtime check with `assert_replication_
converged`, which any successful replication satisfies, and deleted the
two helpers it needed — so the regression the test exists to catch would
now pass. This matters here specifically because the branch changes the
flag feeding `replication_delete_remove_options` and routes replay
through a new file and ordering.
- Drop `read_config_no_lock_preserve_empty`: zero production callers (the
one real consumer calls the `_with_metadata` variant directly). Its test
stanza now exercises that variant, so the coverage moves to live code
rather than being deleted.
- Revert the `bytesize` bump. It is a no-op: `Cargo.lock` already pinned
2.7.0 before this branch and is untouched, so the caret range already
resolved there. Nothing in the diff uses the crate.
- Split the AGENTS.md "Adversarial Validation" policy change out of this
branch. The edit is defensible on its own, but it relaxes the review gate
that this branch has to pass, so it should land as its own PR reviewed on
its own merits rather than bundled with the change that benefits from it.
The reverted hunks are unchanged and ready to re-apply.
Not changed, deliberately: the missing-sidecar path still fails closed.
`missing_bucket_incarnation_sidecar_for_new_metadata_fails_closed` pins
that on purpose, and serving a non-authoritative Object Lock state would
be the wrong trade. The residual concern stands and is recorded in review
— a crash between the two writes in `persist_new_and_set` leaves the
bucket unloadable until DeleteBucket+CreateBucket, and the repair branches
in `migrate_legacy_metadata` and `make_bucket` are unreachable dead code
for that case. Resolving it needs the read path and the (transaction-lock
holding) repair path to be separated, which is more than a follow-up edit.
* test(ci): serialize the new bucket-incarnation tests
The five tests this branch adds around the incarnation / lifecycle fence
drive `init_bucket_metadata_sys` and `bucket_metadata_sys_of` — process-global
OnceLock state that `serial_test`'s `#[serial]` cannot protect across
nextest's process boundary — and they delete+recreate buckets, the shape that
raced into InsufficientWriteQuorum in backlog#937.
Add them to the `ecstore-serial-flaky` group in both the default and ci
profiles (nextest evaluates a named profile's own overrides list, so the
ci mirror is required). Preventive serialization only, no retries.
Not a full fix for the review comment: `bucket_delete_waits_for_config_
mutation_fence` still proves liveness with a fixed 200ms sleep plus
`assert!(!delete.is_finished())`. Turning that into readiness polling needs
a production-side signal to wait on — asserting "still blocked" is inherently
a negative. Serializing the group removes the parallel-load pressure that
makes the window fragile; the sleep itself is left for a follow-up.
* test(ecstore): pin that a drained bucket is actually deletable
`DeleteBucket`'s emptiness check is `has_xlmeta_files`, a raw scan of the
bucket directory on local disks — not an S3-level listing. So "the client
drained the bucket" and "the bucket is deletable" are two different
contracts, and only the first one was covered.
That gap is what the `S3 Implemented Tests` lane is failing on: 219 cases,
all `BucketNotEmpty` on `nuke_prefixed_buckets`, with every test body
passing. The first one is `test_versioning_obj_suspend_versions`, reported
by pytest as PASSED followed by ERROR at teardown.
Add the missing assertion for the unversioned path: PUT, client DELETE,
then assert no `xl.meta` survives and `DeleteBucket` succeeds. It passes —
which is itself a result: the plain delete path leaves no residue, so the
s3-tests failure is not there.
The versioning-suspended path is the remaining suspect (the client DELETE
leaves a null delete marker, and draining means purging it by
`versionId=null`). It is not covered here: `BucketVersioningSys` resolves
through the ambient `get_bucket_metadata_sys()` OnceLock, which this unit
env cannot set, so the bucket never actually reports as suspended. That
repro belongs at the e2e layer where a real server owns the versioning
state.
* fix(ecstore): let an explicit null-version delete purge its delete marker
Root cause of the `S3 Implemented Tests` lane: 219 cases, all
`BucketNotEmpty` on `nuke_prefixed_buckets`, every test body passing.
On a versioning-suspended bucket a client DELETE leaves a null delete
marker — correct S3 semantics, and an `xl.meta` on disk. Draining the
bucket therefore means purging that marker as `?versionId=null`, which is
what `nuke_bucket` does before `DeleteBucket`. That purge was rejected:
explicit null-version purge of the null delete marker must succeed,
got [Some(MethodNotAllowed)]
so the marker survived, and `DeleteBucket`'s emptiness check — a raw
`has_xlmeta_files` scan of the bucket directory, not an S3 listing — kept
reporting the bucket as non-empty.
The two sides of the version comparison in the batch delete loop are in
different namespaces. `goi.version_id` is the client-facing identity, where
`from_file_info` synthesizes `Some(Uuid::nil())` for a null version on a
versioned *or versioning-suspended* bucket. `version_id` is the storage
identity, where `delete_file_info_version_id` maps an explicit
`?versionId=null` to `None`. Comparing them raw makes the purge look like a
version mismatch, so `explicit_delete_marker` is false and the
`MethodNotAllowed` from the lookup is recorded as a delete failure.
This only became reachable on this branch: previously `check_opts` did not
carry `dobj.version_id`, so `set_disk_delete_creates_delete_marker` was
true, `object_lock_check_required` was false, and the lookup that produces
`MethodNotAllowed` never ran. Adding the version id to `check_opts` lit up
a comparison that was already wrong.
Normalize both sides through `delete_file_info_version_id`.
The regression test injects a real Suspended bucket-config snapshot — the
delete path reads versioned/suspended from that snapshot, not from `opts`,
so without it `from_file_info` never synthesizes the null version id and
the branch is not reached. Mutation-checked: restoring the raw comparison
fails the test with the exact `MethodNotAllowed` above.
* fix(app): drop the now-needless struct update
Reverting `crates/replication` to main removed the extra `MrfReplicateEntry`
fields, so this literal specifies every field again and `..Default::default()`
trips `clippy::needless_update` under `-D warnings`.
Caught by CI, not locally: I had run `cargo check --workspace --all-targets`,
which does not see clippy-only lints. Ran `cargo clippy --workspace
--all-targets -- -D warnings` here — clean.
* test(e2e): assert the fresh-volume classification
four_node_empty_legacy_volumes_start_as_fresh only started the cluster and
listed buckets — no assertion, so any classification path that still permits
startup left it green without proving the pre-created empty `.minio.sys`
directories were treated as fresh volumes.
Pin what that classification actually leaves behind: no buckets adopted into
the namespace, `.rustfs.sys/format.json` written on every drive, and the empty
legacy directory left untouched rather than migrated into.
* fix(bucket): apply the requested Object Lock to existing buckets
Site replication replays make-with-versioning against the destination,
carrying the source's `lockEnabled`. When the destination bucket already
exists it takes `force_create`, and the whole option-application block was
gated on `confirmed_missing` — so the call returned success while the replica
stayed unlocked. Replicated versions could then be deleted without the
retention the source enforces.
Object Lock enable is one-way, so applying it to an existing bucket is safe:
move it out of the creation-only gate, keeping `created` and versioning-only
options creation-scoped as before.
An existing authoritative bucket takes the `cache_bucket_metadata_in` branch,
which only caches, so the enable would have been dropped on restart. Persist
instead when the enable actually changed something.
Mutation-checked: restoring the creation-only gate fails the new
`force_create_enables_object_lock_on_an_existing_bucket` with "Object Lock
must be enabled on the existing bucket".
cargo nextest run -p rustfs-ecstore --lib: 3633 passed.
* fix(ecstore): box the generation-checked config mutation paths too
The earlier stack fix boxed `update` and `delete`, but an authorized
bucket-config mutation carrying an incarnation takes `update_if_incarnation`
/ `delete_if_incarnation` instead — which were still inlining the whole
resolve/load/save chain into an already-deep request future. Same overflow,
sibling path.
* fix(restore): keep the nil-version normalization the strip removed
Reverting the replication subsystem to main took `set_disk/replication.rs`
with it, but one line in that file was this branch's own fix rather than
replication work:
- self.version_id.filter(|v| !v.is_nil()) == fi.version_id.filter(|v| !v.is_nil())
+ self.version_id == fi.version_id
For a versioning-suspended object the expected version is `Some(Uuid::nil())`
while the read-back `FileInfo` carries `None`, so the raw compare reports
every suspended restore as "restored object changed before restore metadata
finalization" and the copy-back never commits. Same nil-vs-None mismatch as
the null delete-marker purge fixed earlier on this branch.
Caught by `Test and Lint (rio-v2)`, not by my local runs: the test lives in
`transition_commit_failure_tests`, gated behind `feature = "test-util"`, so
the 3633-test suite I had been running never included it. Re-ran with
`--features rio-v2,test-util`: 3722 passed.
439 lines
16 KiB
Rust
439 lines
16 KiB
Rust
// Copyright 2024 RustFS Team
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
//! End-to-end acceptance for backlog#1052: two embedded RustFS servers coexist
|
|
//! in one process, on different ports and volumes, and their S3 data planes
|
|
//! stay isolated.
|
|
|
|
use aws_sdk_s3::config::{Credentials, Region};
|
|
use aws_sdk_s3::primitives::ByteStream;
|
|
use aws_sdk_s3::{Client, Config};
|
|
#[cfg(feature = "e2e-test-hooks")]
|
|
use chrono::Utc;
|
|
#[cfg(feature = "e2e-test-hooks")]
|
|
use hmac::{Hmac, KeyInit, Mac};
|
|
#[cfg(feature = "e2e-test-hooks")]
|
|
use reqwest::StatusCode;
|
|
#[cfg(feature = "e2e-test-hooks")]
|
|
use rustfs::embedded::pause_embedded_startup_after_http_bind;
|
|
use rustfs::embedded::{RustFSServerBuilder, find_available_port};
|
|
|
|
mod common;
|
|
#[cfg(feature = "e2e-test-hooks")]
|
|
use sha2::{Digest, Sha256};
|
|
#[cfg(feature = "e2e-test-hooks")]
|
|
use std::time::Duration;
|
|
|
|
#[cfg(feature = "e2e-test-hooks")]
|
|
type HmacSha256 = Hmac<Sha256>;
|
|
|
|
fn s3_client(endpoint: &str, access_key: &str, secret_key: &str) -> Client {
|
|
let creds = Credentials::new(access_key, secret_key, None, None, "test");
|
|
let config = Config::builder()
|
|
.credentials_provider(creds)
|
|
.region(Region::new("us-east-1"))
|
|
.endpoint_url(endpoint)
|
|
.force_path_style(true)
|
|
.behavior_version_latest()
|
|
.build();
|
|
Client::from_conf(config)
|
|
}
|
|
|
|
#[cfg(feature = "e2e-test-hooks")]
|
|
fn hex(bytes: impl AsRef<[u8]>) -> String {
|
|
bytes.as_ref().iter().map(|byte| format!("{byte:02x}")).collect()
|
|
}
|
|
|
|
#[cfg(feature = "e2e-test-hooks")]
|
|
fn sha256_hex(bytes: &[u8]) -> String {
|
|
hex(Sha256::digest(bytes))
|
|
}
|
|
|
|
#[cfg(feature = "e2e-test-hooks")]
|
|
fn hmac(key: &[u8], value: &str) -> Vec<u8> {
|
|
let mut mac = HmacSha256::new_from_slice(key).expect("HMAC accepts arbitrary key lengths");
|
|
mac.update(value.as_bytes());
|
|
mac.finalize().into_bytes().to_vec()
|
|
}
|
|
|
|
#[cfg(feature = "e2e-test-hooks")]
|
|
fn signed_admin_request(
|
|
client: &reqwest::Client,
|
|
endpoint: &str,
|
|
request_path: &str,
|
|
access_key: &str,
|
|
secret_key: &str,
|
|
) -> reqwest::RequestBuilder {
|
|
let host = endpoint
|
|
.strip_prefix("http://")
|
|
.or_else(|| endpoint.strip_prefix("https://"))
|
|
.expect("embedded endpoint scheme");
|
|
let payload_hash = sha256_hex(b"");
|
|
let now = Utc::now();
|
|
let amz_date = now.format("%Y%m%dT%H%M%SZ").to_string();
|
|
let date = now.format("%Y%m%d").to_string();
|
|
let canonical_headers = format!("host:{host}\nx-amz-content-sha256:{payload_hash}\nx-amz-date:{amz_date}\n");
|
|
let signed_headers = "host;x-amz-content-sha256;x-amz-date";
|
|
let (path, query) = request_path.split_once('?').unwrap_or((request_path, ""));
|
|
let canonical_request = format!("GET\n{path}\n{query}\n{canonical_headers}\n{signed_headers}\n{payload_hash}");
|
|
let scope = format!("{date}/us-east-1/s3/aws4_request");
|
|
let string_to_sign = format!("AWS4-HMAC-SHA256\n{amz_date}\n{scope}\n{}", sha256_hex(canonical_request.as_bytes()));
|
|
let date_key = hmac(format!("AWS4{secret_key}").as_bytes(), &date);
|
|
let region_key = hmac(&date_key, "us-east-1");
|
|
let service_key = hmac(®ion_key, "s3");
|
|
let signing_key = hmac(&service_key, "aws4_request");
|
|
let authorization = format!(
|
|
"AWS4-HMAC-SHA256 Credential={access_key}/{scope}, SignedHeaders={signed_headers}, Signature={}",
|
|
hex(hmac(&signing_key, &string_to_sign))
|
|
);
|
|
|
|
client
|
|
.get(format!("{endpoint}{request_path}"))
|
|
.header("host", host)
|
|
.header("x-amz-content-sha256", payload_hash)
|
|
.header("x-amz-date", amz_date)
|
|
.header("authorization", authorization)
|
|
}
|
|
|
|
// backlog#1052 acceptance: a second embedded server in the same process no
|
|
// longer aborts on write-once startup state — before this change,
|
|
// `RustFSServer::build()` returned AlreadyStarted (guard) or panicked on
|
|
// region/endpoints (bootstrap context write-once). This test proves the
|
|
// startup pipeline lifts; a follow-up will widen the request path to route
|
|
// per-server so the two servers can also serve different data planes end-to-
|
|
// end without the shared-IAM caveat.
|
|
#[test]
|
|
fn two_embedded_servers_start_and_shutdown_independently() {
|
|
common::run_embedded_test(two_embedded_servers_start_and_shutdown_independently_body);
|
|
}
|
|
|
|
async fn two_embedded_servers_start_and_shutdown_independently_body() {
|
|
let port_a = match find_available_port() {
|
|
Ok(port) => port,
|
|
Err(err) if err.kind() == std::io::ErrorKind::PermissionDenied => return,
|
|
Err(err) => panic!("find free port for server A: {err}"),
|
|
};
|
|
let server_a = RustFSServerBuilder::new()
|
|
.address(format!("127.0.0.1:{port_a}"))
|
|
.access_key("shared-access")
|
|
.secret_key("shared-secret")
|
|
.build()
|
|
.await
|
|
.expect("start embedded server A");
|
|
|
|
let port_b = match find_available_port() {
|
|
Ok(port) => port,
|
|
Err(err) if err.kind() == std::io::ErrorKind::PermissionDenied => {
|
|
server_a.shutdown().await;
|
|
return;
|
|
}
|
|
Err(err) => {
|
|
server_a.shutdown().await;
|
|
panic!("find free port for server B: {err}");
|
|
}
|
|
};
|
|
let server_b = RustFSServerBuilder::new()
|
|
.address(format!("127.0.0.1:{port_b}"))
|
|
.access_key("shared-access")
|
|
.secret_key("shared-secret")
|
|
.build()
|
|
.await
|
|
.expect("start embedded server B — a second server must be allowed after startup handoff");
|
|
|
|
assert_ne!(server_a.address().port(), server_b.address().port(), "each server binds its own port");
|
|
|
|
// Both endpoints serve the readiness probe — the crudest possible check
|
|
// that both HTTP stacks are actually listening on their own port.
|
|
let a_endpoint = server_a.endpoint();
|
|
let b_endpoint = server_b.endpoint();
|
|
assert!(a_endpoint.ends_with(&format!(":{port_a}")));
|
|
assert!(b_endpoint.ends_with(&format!(":{port_b}")));
|
|
|
|
server_b.shutdown().await;
|
|
// Server A remains fully usable after server B shuts down — the second
|
|
// shutdown must not have released state server A depends on.
|
|
let client_a = s3_client(&server_a.endpoint(), server_a.access_key(), server_a.secret_key());
|
|
client_a
|
|
.create_bucket()
|
|
.bucket("survives-b-shutdown")
|
|
.send()
|
|
.await
|
|
.expect("server A still serves after server B shuts down");
|
|
client_a
|
|
.put_object()
|
|
.bucket("survives-b-shutdown")
|
|
.key("marker.txt")
|
|
.body(ByteStream::from_static(b"still here"))
|
|
.send()
|
|
.await
|
|
.expect("server A still writes after server B shuts down");
|
|
|
|
server_a.shutdown().await;
|
|
}
|
|
|
|
// backlog#1052 full acceptance: two embedded servers with *different*
|
|
// credentials are isolated end to end — auth (each accepts its own key and
|
|
// rejects the other's) AND data plane (each server's buckets/objects are
|
|
// invisible to the other; each lists/creates/deletes only on its own disks
|
|
// and bucket-metadata system).
|
|
#[test]
|
|
fn two_embedded_servers_isolate_auth_and_data_planes() {
|
|
common::run_embedded_test(two_embedded_servers_isolate_auth_and_data_planes_body);
|
|
}
|
|
|
|
async fn two_embedded_servers_isolate_auth_and_data_planes_body() {
|
|
let port_a = match find_available_port() {
|
|
Ok(port) => port,
|
|
Err(err) if err.kind() == std::io::ErrorKind::PermissionDenied => return,
|
|
Err(err) => panic!("find free port for server A: {err}"),
|
|
};
|
|
let server_a = RustFSServerBuilder::new()
|
|
.address(format!("127.0.0.1:{port_a}"))
|
|
.access_key("access-key-a")
|
|
.secret_key("secret-key-a")
|
|
.build()
|
|
.await
|
|
.expect("start embedded server A");
|
|
|
|
let port_b = match find_available_port() {
|
|
Ok(port) => port,
|
|
Err(err) if err.kind() == std::io::ErrorKind::PermissionDenied => {
|
|
server_a.shutdown().await;
|
|
return;
|
|
}
|
|
Err(err) => {
|
|
server_a.shutdown().await;
|
|
panic!("find free port for server B: {err}");
|
|
}
|
|
};
|
|
let server_b = RustFSServerBuilder::new()
|
|
.address(format!("127.0.0.1:{port_b}"))
|
|
.access_key("access-key-b")
|
|
.secret_key("secret-key-b")
|
|
.build()
|
|
.await
|
|
.expect("start embedded server B");
|
|
|
|
// Server B authenticates with its OWN key — before per-server auth this
|
|
// failed with InvalidAccessKeyId because validation used the process
|
|
// (server A's) credentials.
|
|
let client_b = s3_client(&server_b.endpoint(), "access-key-b", "secret-key-b");
|
|
client_b
|
|
.list_buckets()
|
|
.send()
|
|
.await
|
|
.expect("server B must authenticate with its own credentials");
|
|
|
|
// Server B rejects server A's key — the two servers have distinct root
|
|
// identities.
|
|
let cross = s3_client(&server_b.endpoint(), "access-key-a", "secret-key-a")
|
|
.list_buckets()
|
|
.send()
|
|
.await;
|
|
assert!(cross.is_err(), "server B must reject server A's access key; got {cross:?}");
|
|
|
|
// Server A still authenticates with its own key.
|
|
let client_a = s3_client(&server_a.endpoint(), "access-key-a", "secret-key-a");
|
|
client_a
|
|
.list_buckets()
|
|
.send()
|
|
.await
|
|
.expect("server A must authenticate with its own credentials");
|
|
|
|
// ---- Data-plane isolation (backlog#1052 S7) ----
|
|
|
|
// Server A owns a bucket + object.
|
|
client_a
|
|
.create_bucket()
|
|
.bucket("only-on-a")
|
|
.send()
|
|
.await
|
|
.expect("server A creates its bucket");
|
|
client_a
|
|
.put_object()
|
|
.bucket("only-on-a")
|
|
.key("marker.txt")
|
|
.body(ByteStream::from_static(b"belongs to A"))
|
|
.send()
|
|
.await
|
|
.expect("server A writes its object");
|
|
|
|
// Server B's listing does not contain server A's bucket.
|
|
let b_buckets: Vec<_> = client_b
|
|
.list_buckets()
|
|
.send()
|
|
.await
|
|
.expect("server B lists buckets")
|
|
.buckets()
|
|
.iter()
|
|
.flat_map(|bucket| bucket.name.clone())
|
|
.collect();
|
|
assert!(
|
|
!b_buckets.contains(&"only-on-a".to_string()),
|
|
"server B must not see server A's bucket; saw {b_buckets:?}"
|
|
);
|
|
|
|
// Server B cannot resolve server A's object either.
|
|
let cross_head = client_b.head_object().bucket("only-on-a").key("marker.txt").send().await;
|
|
assert!(cross_head.is_err(), "server B must not resolve server A's object; got {cross_head:?}");
|
|
|
|
// Server B's own bucket is invisible to server A.
|
|
client_b
|
|
.create_bucket()
|
|
.bucket("only-on-b")
|
|
.send()
|
|
.await
|
|
.expect("server B creates its bucket");
|
|
let a_buckets: Vec<_> = client_a
|
|
.list_buckets()
|
|
.send()
|
|
.await
|
|
.expect("server A lists buckets")
|
|
.buckets()
|
|
.iter()
|
|
.flat_map(|bucket| bucket.name.clone())
|
|
.collect();
|
|
assert!(
|
|
a_buckets.contains(&"only-on-a".to_string()),
|
|
"server A must keep seeing its own bucket; saw {a_buckets:?}"
|
|
);
|
|
assert!(
|
|
!a_buckets.contains(&"only-on-b".to_string()),
|
|
"server A must not see server B's bucket; saw {a_buckets:?}"
|
|
);
|
|
|
|
// Server A's data plane is intact.
|
|
let a_get = client_a
|
|
.get_object()
|
|
.bucket("only-on-a")
|
|
.key("marker.txt")
|
|
.send()
|
|
.await
|
|
.expect("server A serves its own object");
|
|
let a_data = a_get.body.collect().await.expect("read A body").into_bytes();
|
|
assert_eq!(a_data.as_ref(), b"belongs to A");
|
|
|
|
server_a.shutdown().await;
|
|
server_b.shutdown().await;
|
|
}
|
|
|
|
#[cfg(feature = "e2e-test-hooks")]
|
|
#[tokio::test]
|
|
async fn second_embedded_server_fails_closed_until_its_context_slot_is_installed() {
|
|
let port_a = match find_available_port() {
|
|
Ok(port) => port,
|
|
Err(err) if err.kind() == std::io::ErrorKind::PermissionDenied => return,
|
|
Err(err) => panic!("find free port for server A: {err}"),
|
|
};
|
|
let server_a = RustFSServerBuilder::new()
|
|
.address(format!("127.0.0.1:{port_a}"))
|
|
.access_key("startup-window-access-a")
|
|
.secret_key("startup-window-secret-a")
|
|
.build()
|
|
.await
|
|
.expect("start embedded server A");
|
|
let client_a = s3_client(&server_a.endpoint(), server_a.access_key(), server_a.secret_key());
|
|
client_a
|
|
.create_bucket()
|
|
.bucket("startup-window")
|
|
.send()
|
|
.await
|
|
.expect("server A creates the shared-name bucket");
|
|
client_a
|
|
.put_object()
|
|
.bucket("startup-window")
|
|
.key("marker.txt")
|
|
.body(ByteStream::from_static(b"from A"))
|
|
.send()
|
|
.await
|
|
.expect("server A writes its marker");
|
|
|
|
let port_b = match find_available_port() {
|
|
Ok(port) => port,
|
|
Err(err) if err.kind() == std::io::ErrorKind::PermissionDenied => {
|
|
server_a.shutdown().await;
|
|
return;
|
|
}
|
|
Err(err) => {
|
|
server_a.shutdown().await;
|
|
panic!("find free port for server B: {err}");
|
|
}
|
|
};
|
|
let endpoint_b = format!("http://127.0.0.1:{port_b}");
|
|
let b_access_key = "startup-window-access-b";
|
|
let b_secret_key = "startup-window-secret-b";
|
|
let mut barrier = pause_embedded_startup_after_http_bind(port_b);
|
|
let startup_b = tokio::spawn(async move {
|
|
RustFSServerBuilder::new()
|
|
.address(format!("127.0.0.1:{port_b}"))
|
|
.access_key(b_access_key)
|
|
.secret_key(b_secret_key)
|
|
.build()
|
|
.await
|
|
});
|
|
tokio::time::timeout(Duration::from_secs(10), barrier.wait_until_http_bound())
|
|
.await
|
|
.expect("server B must bind HTTP before installing its context slot");
|
|
|
|
let http = reqwest::Client::builder()
|
|
.no_proxy()
|
|
.timeout(Duration::from_secs(5))
|
|
.build()
|
|
.expect("build local admin client without proxy");
|
|
let inspect_path = "/rustfs/admin/v3/inspect-data?file=marker.txt&volume=startup-window";
|
|
let before_install = signed_admin_request(&http, &endpoint_b, inspect_path, b_access_key, b_secret_key)
|
|
.send()
|
|
.await
|
|
.expect("server B HTTP listener must accept the paused request");
|
|
let before_install_status = before_install.status();
|
|
let before_install_body = before_install.text().await.expect("read paused response body");
|
|
assert_eq!(before_install_status, StatusCode::SERVICE_UNAVAILABLE, "{before_install_body}");
|
|
assert!(
|
|
before_install_body.contains("server context is not ready"),
|
|
"paused request must not resolve server A: {before_install_body}"
|
|
);
|
|
|
|
barrier.release();
|
|
let server_b = tokio::time::timeout(Duration::from_secs(20), startup_b)
|
|
.await
|
|
.expect("server B startup must complete after releasing the barrier")
|
|
.expect("server B startup task must not panic")
|
|
.expect("start embedded server B");
|
|
let client_b = s3_client(&server_b.endpoint(), server_b.access_key(), server_b.secret_key());
|
|
client_b
|
|
.create_bucket()
|
|
.bucket("startup-window")
|
|
.send()
|
|
.await
|
|
.expect("server B creates its isolated shared-name bucket");
|
|
client_b
|
|
.put_object()
|
|
.bucket("startup-window")
|
|
.key("marker.txt")
|
|
.body(ByteStream::from_static(b"from B"))
|
|
.send()
|
|
.await
|
|
.expect("server B writes its marker");
|
|
|
|
let after_install = signed_admin_request(&http, &server_b.endpoint(), inspect_path, b_access_key, b_secret_key)
|
|
.send()
|
|
.await
|
|
.expect("server B admin request after context installation");
|
|
assert_eq!(after_install.status(), StatusCode::OK);
|
|
assert_eq!(after_install.bytes().await.expect("read server B marker"), b"from B".as_slice());
|
|
|
|
server_b.shutdown().await;
|
|
server_a.shutdown().await;
|
|
}
|