mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-26 08:18:18 +00:00
fix(logging): enforce single-writer sinks and bound tracing (#4765)
* fix(obs): prevent rolling log stdout aliasing * fix(ecstore): bound hot-path tracing payloads * test(logging): guard service and disk log invariants * fix(obs): silence useless_conversion on st_dev for Linux clippy rustix's Stat.st_dev is u64 on Linux/glibc, making u64::try_from a no-op that trips clippy::useless_conversion under -D warnings. The conversion is still needed on macOS/BSD where st_dev is a signed dev_t, so suppress the lint on that line rather than dropping the portable fallible conversion. * fix(logging): keep stdout sink validation portable (#4769) * fix(obs): keep stdout device conversion portable * docs(logging): update single-writer plan status --------- Co-authored-by: overtrue <anzhengchao@gmail.com> Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
@@ -653,4 +653,49 @@ for pattern in "${forbidden_patterns[@]}"; do
|
||||
fi
|
||||
done
|
||||
|
||||
systemd_unit="deploy/build/rustfs.service"
|
||||
if rg -n '^Standard(Output|Error)=append:.*rustfs.*\.log$' "$systemd_unit" >/dev/null; then
|
||||
echo "❌ logging guardrail violation: systemd must not append stdout/stderr to a RustFS-managed rolling log" >&2
|
||||
rg -n '^Standard(Output|Error)=append:.*rustfs.*\.log$' "$systemd_unit" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for directive in 'StandardOutput=journal' 'StandardError=journal'; do
|
||||
if ! rg -n -F -- "$directive" "$systemd_unit" >/dev/null; then
|
||||
echo "❌ logging guardrail violation: missing '$directive' in $systemd_unit" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
disk_logging_files=(
|
||||
"crates/ecstore/src/disk/mod.rs"
|
||||
"crates/ecstore/src/disk/local.rs"
|
||||
"crates/ecstore/src/cluster/rpc/remote_disk.rs"
|
||||
)
|
||||
|
||||
for file in "${disk_logging_files[@]}"; do
|
||||
unexpected_instrumentation="$(rg -n '#\[tracing::instrument' "$file" | rg -v 'level = "trace", skip_all' || true)"
|
||||
if [[ -n "$unexpected_instrumentation" ]]; then
|
||||
echo "❌ logging guardrail violation: disk instrumentation must be TRACE-only and skip all arguments in $file" >&2
|
||||
echo "$unexpected_instrumentation" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
if rg -n -U 'debug!\([\s\S]{0,600}"Remote disk RPC started"' crates/ecstore/src/cluster/rpc/remote_disk.rs >/dev/null; then
|
||||
echo "❌ logging guardrail violation: successful remote disk RPC events must not be emitted at DEBUG" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if rg -n -F 'debug!("list_dir' crates/ecstore/src/cluster/rpc/remote_disk.rs >/dev/null; then
|
||||
echo "❌ logging guardrail violation: RemoteDisk list_dir must not emit per-RPC DEBUG logs" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
stdout_sink_calls="$(rg -n -F 'validate_stdout_sink(&file_appender)' crates/obs/src/telemetry/local.rs crates/obs/src/telemetry/otel.rs | wc -l | tr -d ' ')"
|
||||
if [[ "$stdout_sink_calls" != "2" ]]; then
|
||||
echo "❌ logging guardrail violation: local and OTLP file logging must both validate stdout sink ownership" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Logging guardrails check passed"
|
||||
|
||||
Reference in New Issue
Block a user