Enhance backend management and performance tuning

- Introduced remounting logic for data directories to ensure correct bindings before restarting services, improving reliability during performance tuning.
- Added functions to sanitize and ensure absolute paths for backend scripts, preventing issues with relative paths in bind mounts.
- Enhanced the `patch_backends_extra_args` function to clean up corrupted entries and ensure proper configuration of backend parameters.
- Updated tests to validate the new sanitization and path handling functionalities, ensuring robustness in backend management.
This commit is contained in:
Leonid Pershin
2026-08-21 11:44:25 +03:00
parent fc60fef279
commit 021feaa839
4 changed files with 174 additions and 33 deletions
+10 -2
View File
@@ -68,9 +68,17 @@ ensure_data_mount() {
ensure_bind() {
local src="$1" dst="$2"
mkdir -p "$src" "$dst"
if ! findmnt "$dst" >/dev/null 2>&1; then
mount --bind "$src" "$dst"
if findmnt "$dst" >/dev/null 2>&1; then
# git reset --hard can leave a stale/wrong bind; remount if SOURCE mismatch.
local src_mnt
src_mnt="$(findmnt -n -o SOURCE --target "$dst" 2>/dev/null || true)"
if [[ "$src_mnt" == "$src" ]]; then
return 0
fi
log "bind remount ${dst} (было: ${src_mnt:-?})"
umount "$dst" 2>/dev/null || umount -l "$dst" 2>/dev/null || true
fi
mount --bind "$src" "$dst" || log "WARN: mount --bind ${src}${dst} failed"
if ! grep -Fq " ${dst} " /etc/fstab; then
echo "${src} ${dst} none bind,nofail 0 0" >> /etc/fstab
fi