Commit c6b504e9 authored by Ramon Nou's avatar Ramon Nou
Browse files

fix(client): preserve local bypass before lazy hostfile initialization

parent e030a9c0
Loading
Loading
Loading
Loading
Loading
+4 −2
Changes for src/client/preload.cpp: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -785,8 +785,10 @@ init_preload() {
    } else if(gkfs::env::var_is_set("LIBGKFS_LOCAL_BYPASS")) {
        bypass_enabled = gkfs::env::get_var_bool("LIBGKFS_LOCAL_BYPASS", true);
    }
    if(gkfs::env::get_var_bool(gkfs::env::USE_MEM, false) ||
       CTX->fs_conf()->rootdir.empty()) {
    // The backend root is not known until lazy environment initialization
    // reads the hostfile. An empty root here does not imply memory storage.
    // load_hostfile() disables bypass for advertised memory backends too.
    if(gkfs::env::get_var_bool(gkfs::env::USE_MEM, false)) {
        bypass_enabled = false;
    }
    CTX->local_bypass(bypass_enabled);
+21
Changes for tests/integration/syscalls/test_interceptor_runtime_bypass.py: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -4,6 +4,27 @@ from pathlib import Path
import pytest


@pytest.mark.parametrize("enabled", ["ON", "OFF"])
def test_lazy_file_backend_preserves_local_bypass(gkfs_daemon, gkfs_shell,
                                                  tmp_path, enabled):
    """An uninitialized backend root must not override the requested bypass."""
    log = tmp_path / "bypass.log"
    result = gkfs_shell.run(
        "env", "GKFS_USE_MEM=OFF", "GKFS_ENABLE_LOCAL_BYPASS=" + enabled,
        "LIBGKFS_ENABLE_LOCAL_BYPASS=" + enabled,
        "LIBGKFS_LOG=info", "LIBGKFS_LOG_OUTPUT=" + str(log),
        "/usr/bin/python3", "-c", """
import pathlib, sys
p = pathlib.Path(sys.argv[1]) / 'lazy-bypass'
payload = b'bypass-regression' * 131072
p.write_bytes(payload)
assert p.read_bytes() == payload
p.unlink()
""", str(gkfs_daemon.mountdir), timeout=60)
    assert result.exit_code == 0, result.stderr
    assert "Local chunk bypass: " + enabled in log.read_text()


@pytest.mark.parametrize("shell_fixture", ["gkfs_shell", "gkfs_shellLibc"])
def test_external_paths_preserve_resolution(shell_fixture, request,
                                           gkfs_daemon, tmp_path):