Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/environment-compatibility-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ on:
- scripts/performance_delete_probe.py
- test_performance_s3.py
- scripts/check_execution_environment.py
- scripts/local_rustfs.py
- scripts/musl_cpu_affinity.py
- scripts/check_shell_syntax.py
- scripts/prepare_table_smoke.py
- test_check_shell_syntax.py
- .github/workflows/rustfs-table-test.yml
- scripts/lib/**
- test_check_execution_environment.py
- test_musl_cpu_affinity.py
- test_rustfs_table.py
- test_rustfs_performance_testing.py
- test_rustfs_replication.py
Expand All @@ -36,12 +39,15 @@ on:
- scripts/performance_delete_probe.py
- test_performance_s3.py
- scripts/check_execution_environment.py
- scripts/local_rustfs.py
- scripts/musl_cpu_affinity.py
- scripts/check_shell_syntax.py
- scripts/prepare_table_smoke.py
- test_check_shell_syntax.py
- .github/workflows/rustfs-table-test.yml
- scripts/lib/**
- test_check_execution_environment.py
- test_musl_cpu_affinity.py
- test_rustfs_table.py
- test_rustfs_performance_testing.py
- test_rustfs_replication.py
Expand Down Expand Up @@ -70,6 +76,7 @@ jobs:
python3 -B -m unittest -v
test_check_execution_environment.py
test_check_shell_syntax.py
test_musl_cpu_affinity.py
test_rustfs_table.py
test_rustfs_performance_testing.py
test_performance_s3.py
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,17 @@ python3 scripts/sts_root_regression.py --rustfs-bin /absolute/path/to/rustfs --c
python3 scripts/sts_root_regression.py --endpoint http://127.0.0.1:9000
```

### Static musl CPU-affinity regression (rustfs/rustfs#9625)

The standalone `runtime.musl-cpu-affinity` case runs on native x86_64 Linux with at least two allowed CPU IDs below 128, four from 128 through 1023, and a cgroup CPU quota of at least four cores (or no quota). It starts the candidate on loopback with a fresh volume for each four-CPU mask, one high-only and one mixed. Each instance must reach `/health/ready`. Matching ECStore tests check fsync dispatch and scheduler width, ILM expiry and transition defaults, and an expiry worker's handling of queued recovery work. Inadequate CPU affinity fails preflight.

Provide the static x86_64-musl candidate and the ECStore unit-test executable built from the same RustFS commit. From the RustFS checkout, `cargo test --locked -p rustfs-ecstore --lib --target x86_64-unknown-linux-musl --no-run` prints the test executable path.

```bash
python3 -B scripts/musl_cpu_affinity.py --rustfs-bin /path/to/rustfs \
--ecstore-test-bin /path/to/rustfs_ecstore-test
```

## Tier suite artifacts

The full Tier suite requires `mosquitto_sub` and `mosquitto_pub`. Before changing any RustFS node, it checks MQTT publish/subscribe delivery through `${RUSTFS_HEAL_IP}:1883`. An existing broker is reused. If the endpoint is local and has no listener, the suite starts an isolated `eclipse-mosquitto:2` Docker container and removes only that container on exit, including failed setup. Docker must be available directly or through `sudo -n`. Set `RUSTFS_TIER_MQTT_MODE=external` to require an already running broker without creating one; use `RUSTFS_MQTT_PORT` to override port 1883. Remote brokers must be provisioned separately. Canonical tiering, events, and audit validation cases do not require MQTT.
Expand Down
94 changes: 94 additions & 0 deletions scripts/musl_cpu_affinity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/usr/bin/env python3
"""Run the RustFS musl CPU-affinity regression on a high-CPU Linux runner."""

import argparse
import json
import os
from pathlib import Path
import platform
import secrets
import subprocess
import tempfile
from types import SimpleNamespace

if __package__:
from .local_rustfs import local_rustfs
else:
from local_rustfs import local_rustfs


CASE_ID = "runtime.musl-cpu-affinity"
LIFECYCLE_TESTS = "bucket::lifecycle::bucket_lifecycle_ops::tests::"
ECSTORE_TESTS = (
"disk::os::tests::disk_blocking_queue_bounds_concurrency_and_recovers_from_panic",
LIFECYCLE_TESTS + "expiry_worker_count_resolves_all_env_states",
LIFECYCLE_TESTS + "resolve_transition_worker_count_uses_fallback_when_env_missing",
LIFECYCLE_TESTS + "resize_workers_wires_recovery_notify_to_worker_failures",
)


def select_masks(allowed):
low = sorted(cpu for cpu in allowed if cpu < 128)
high = sorted(cpu for cpu in allowed if 128 <= cpu < 1024)
if len(low) < 2 or len(high) < 4:
raise RuntimeError("requires at least two allowed CPUs below 128 and four in 128–1023")
return {"high-only": set(high[:4]), "mixed": set(low[:2] + high[:2])}


def run_ecstore_tests(binary, directory):
env = {"PATH": os.environ.get("PATH", os.defpath), "RUST_MIN_STACK": "4194304"}
for name in ECSTORE_TESTS:
result = subprocess.run(
[str(binary), "--exact", name, "--test-threads=1", "--color=never"],
cwd=directory, env=env, capture_output=True, text=True, timeout=90, check=False,
)
if result.returncode or not any(
line.startswith("test result: ok. 1 passed; 0 failed; 0 ignored;")
for line in result.stdout.splitlines()
):
raise RuntimeError(f"{name} did not pass exactly once")


def exercise(server, ecstore_tests, root):
allowed = os.sched_getaffinity(0)
masks = select_masks(allowed)
credentials = SimpleNamespace(access_key="affinity-regression", secret_key=secrets.token_hex(24))
for label, mask in masks.items():
directory = root / label
directory.mkdir()
try:
os.sched_setaffinity(0, mask)
if os.sched_getaffinity(0) != mask:
raise RuntimeError("runner did not grant the full CPU mask")
with local_rustfs(server, credentials, directory, {}) as _port:
pass # The helper waits for /health/ready.
run_ecstore_tests(ecstore_tests, directory)
except (OSError, RuntimeError, subprocess.TimeoutExpired) as error:
raise RuntimeError(f"{label} {sorted(mask)}: {error}") from error
finally:
os.sched_setaffinity(0, allowed)
return {"case_id": CASE_ID, "masks": {label: sorted(mask) for label, mask in masks.items()},
"ecstore_tests_per_mask": len(ECSTORE_TESTS)}


def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--rustfs-bin", type=Path, required=True, help="static x86_64-musl RustFS binary")
parser.add_argument("--ecstore-test-bin", type=Path, required=True, help="ECStore musl unit-test binary from the same source")
args = parser.parse_args()
if platform.system() != "Linux" or platform.machine() != "x86_64":
parser.error("requires x86_64 Linux")
binaries = (args.rustfs_bin.resolve(), args.ecstore_test_bin.resolve())
for binary in binaries:
if not binary.is_file() or not os.access(binary, os.X_OK):
parser.error(f"expected an executable file: {binary}")

with tempfile.TemporaryDirectory(prefix="rustfs-musl-affinity-") as temporary:
try:
print(json.dumps(exercise(*binaries, Path(temporary))))
except RuntimeError as error:
parser.exit(1, f"{CASE_ID}: {error}\n")


if __name__ == "__main__":
main()
53 changes: 53 additions & 0 deletions test_musl_cpu_affinity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from pathlib import Path
from subprocess import CompletedProcess
import tempfile
import unittest
from unittest.mock import call, patch

from scripts import musl_cpu_affinity as probe


class MuslCpuAffinityTests(unittest.TestCase):
def test_selects_high_only_and_mixed_masks_of_equal_width(self):
allowed = {10, 11, 12, 127, 128, 192, 193, 198, 199, 1024}
self.assertEqual(probe.select_masks(allowed), {
"high-only": {128, 192, 193, 198},
"mixed": {10, 11, 128, 192},
})

def test_missing_high_or_low_cpus_fails_preflight(self):
for allowed in ({0, 1, 128, 129, 130, 1024}, {127, 128, 129, 130, 131}):
with self.subTest(allowed=allowed), self.assertRaisesRegex(RuntimeError, "requires at least two"):
probe.select_masks(allowed)

@patch.object(probe.subprocess, "run")
def test_rejects_zero_matching_tests_and_nonzero_exit(self, run):
for status, count in ((0, 0), (0, 11), (101, 1)):
summary = f"test result: ok. {count} passed; 0 failed; 0 ignored;"
with self.subTest(status=status, summary=summary):
run.return_value = CompletedProcess([], status, stdout=summary)
with self.assertRaisesRegex(RuntimeError, "did not pass exactly once"):
probe.run_ecstore_tests(Path("/fixture/ecstore-tests"), Path("/fixture"))

@patch.object(probe.subprocess, "run")
def test_runs_each_named_test_in_a_separate_process(self, run):
run.return_value = CompletedProcess([], 0, stdout="test result: ok. 1 passed; 0 failed; 0 ignored;")
probe.run_ecstore_tests(Path("/fixture/ecstore-tests"), Path("/fixture"))
self.assertEqual([call.args[0][2] for call in run.call_args_list], list(probe.ECSTORE_TESTS))
self.assertEqual(run.call_args.kwargs["env"]["RUST_MIN_STACK"], "4194304")

@patch.object(probe.os, "sched_setaffinity", create=True)
@patch.object(probe.os, "sched_getaffinity", create=True)
@patch.object(probe, "local_rustfs", side_effect=RuntimeError("startup failed"))
def test_restores_original_affinity_when_startup_fails(self, _local_rustfs, get_affinity, set_affinity):
allowed = {4, 5, 128, 129, 130, 131}
mask = {128, 129, 130, 131}
get_affinity.side_effect = [allowed, mask]
with tempfile.TemporaryDirectory() as directory:
with self.assertRaisesRegex(RuntimeError, "high-only.*startup failed"):
probe.exercise(Path("/fixture/rustfs"), Path("/fixture/ecstore-tests"), Path(directory))
self.assertEqual(set_affinity.call_args_list, [call(0, mask), call(0, allowed)])


if __name__ == "__main__":
unittest.main()