Skip to content

fix(#592): forward S3/storage env vars to remote MPI ranks via -x#596

Merged
FileSystemGuy merged 1 commit into
mainfrom
fix/592-forward-s3-env-to-mpi-ranks
Jun 30, 2026
Merged

fix(#592): forward S3/storage env vars to remote MPI ranks via -x#596
FileSystemGuy merged 1 commit into
mainfrom
fix/592-forward-s3-env-to-mpi-ranks

Conversation

@russfellows

Copy link
Copy Markdown
Contributor

Fixes #592 (Problem A — S3 credential forwarding).

The bug

OpenMPI does not propagate arbitrary env vars to remote hosts by
default. For a multi-host object-storage run, the launcher host sets
AWS_ENDPOINT_URL, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,
S3DLIO_FOLLOW_REDIRECTS, STORAGE_LIBRARY, and BUCKET — but only
DLIO_DROP_CACHES_TIMEOUT was being forwarded to remote ranks via
-x. Remote ranks had none of the S3 config and would hang or fail
with auth errors on their first S3 operation.

The fix

In DLIOBenchmark.generate_dlio_command(), after the existing
DLIO_DROP_CACHES_TIMEOUT forwarding, iterate os.environ (sorted
for determinism) and append -x VARNAME for every variable whose name
starts with AWS_ or S3DLIO_, or is exactly STORAGE_LIBRARY or
BUCKET.

for _v in sorted(os.environ):
    if (_v.startswith('AWS_') or _v.startswith('S3DLIO_')
            or _v in ('STORAGE_LIBRARY', 'BUCKET')):
        mpi_prefix += f" -x {_v}"

Tests

11 new tests in tests/unit/test_mpi_s3_env_forwarding.py. All call
the real generate_dlio_command() with generate_mpi_prefix_cmd
patched to a fixed prefix string.

TestS3EnvForwardingMissing (6 tests) — RED before fix, GREEN after:

  • test_aws_endpoint_url_forwarded — S3 endpoint must reach remote ranks
  • test_aws_access_key_id_forwarded — access key must reach remote ranks
  • test_aws_secret_access_key_forwarded — secret key must reach remote ranks
  • test_s3dlio_follow_redirects_forwarded — AIStore redirect flag must reach remote ranks
  • test_storage_library_forwarded — storage library selection must reach remote ranks
  • test_bucket_forwarded — bucket name must reach remote ranks

TestAbsentVarsNotForwarded (2 tests):

  • Vars not in the launcher env must not produce spurious -x flags

TestDropCachesTimeoutStillForwarded (2 tests):

  • Pre-existing -x DLIO_DROP_CACHES_TIMEOUT forwarding must not regress
  • Both DLIO and S3 vars appear together when all are set

TestNonMpiRunsUnchanged (1 test):

  • No -x flags when exec_type is not MPI

Verification

  • uv run pytest tests/unit/test_mpi_s3_env_forwarding.py -v
    7 FAILED (bug confirmed), then 11 passed after fix
  • uv run pytest tests/unit -q → 2266 passed, no regressions
  • On-cluster: multi-host object-storage run should no longer
    hang/auth-fail on remote ranks

Files

  • mlpstorage_py/benchmarks/dlio.py — extend MPI env forwarding loop
  • tests/unit/test_mpi_s3_env_forwarding.py — 11 new tests

@russfellows russfellows requested a review from a team June 30, 2026 15:54
@github-actions

Copy link
Copy Markdown

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

OpenMPI does not propagate arbitrary env vars to remote hosts by
default; -x VARNAME opts a specific variable in.  Before this fix,
only DLIO_DROP_CACHES_TIMEOUT was forwarded.  For multi-host
object-storage runs, remote ranks had no AWS_*, S3DLIO_*,
STORAGE_LIBRARY, or BUCKET — the first S3 operation on each remote
rank would hang or fail with an authentication error.

Fix: in generate_dlio_command(), after the existing
DLIO_DROP_CACHES_TIMEOUT forwarding, iterate os.environ (sorted)
and append "-x VARNAME" for every var whose name starts with AWS_
or S3DLIO_, or is exactly STORAGE_LIBRARY or BUCKET.

Tests (tests/unit/test_mpi_s3_env_forwarding.py — 11 new tests):

  TestS3EnvForwardingMissing (6 tests): each asserts a required
  -x flag IS present in generate_dlio_command() output, calling
  the real method with generate_mpi_prefix_cmd patched to a fixed
  string.  All 6 FAILED before this fix (bug confirmed), all 6
  PASS after:
    - test_aws_endpoint_url_forwarded
    - test_aws_access_key_id_forwarded
    - test_aws_secret_access_key_forwarded
    - test_s3dlio_follow_redirects_forwarded
    - test_storage_library_forwarded
    - test_bucket_forwarded

  TestAbsentVarsNotForwarded (2 tests): vars not in the launcher
  env must not appear as -x flags (no spurious forwarding).

  TestDropCachesTimeoutStillForwarded (2 tests): pre-existing
  DLIO_DROP_CACHES_TIMEOUT forwarding must not regress; also
  verifies both DLIO and S3 vars appear together when all are set.

  TestNonMpiRunsUnchanged (1 test): no -x flags when exec_type
  is not MPI.

Full suite: 2266 passed, no regressions.
@russfellows russfellows force-pushed the fix/592-forward-s3-env-to-mpi-ranks branch from e2dc931 to 69ae4b2 Compare June 30, 2026 15:57
@FileSystemGuy FileSystemGuy merged commit 9158d86 into main Jun 30, 2026
3 checks passed
@FileSystemGuy FileSystemGuy deleted the fix/592-forward-s3-env-to-mpi-ranks branch June 30, 2026 16:01
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

2 participants