Skip to content

[Store] Load Store configs from an injected Environ - #4514

Open
Aionw wants to merge 3 commits into
kvcache-ai:mainfrom
Aionw:refactor/environ-injectable-configs-v2
Open

Aionw wants to merge 3 commits into
kvcache-ai:mainfrom
Aionw:refactor/environ-injectable-configs-v2

Conversation

@Aionw

@Aionw Aionw commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Part of #3809. Replaces #4400, which was closed when its base branch
(refactor/environ-reader, #4401) merged. Stacked on #4513: until that
merges, this PR also shows its two commits; review only the last commit.

Every Store config now takes the environment as a parameter:

  • Entry point. Each config has a single entry point, FromEnvironment(const Environ& env, ...).
  • Production call sites pass Environ::Process(). These are the places where a later change will pass down configs resolved at the process entry point instead.
  • Config tests inject a MapEnvironSource instead of calling setenv/unsetenv and restoring values. Tests that exercise production paths that still read the process environment keep using setenv().
  • Compatibility wrappers. This removes the Environ::Read/ReadOr/GetDouble wrappers that [Store] Make Environ an injectable environment reader #4401 kept.

The change is mechanical. Parsing, defaults, diagnostics and alias handling are
unchanged. Most of the line count is tests (+1331/-1980 of +1876/-2363), which
drop their per-file process-environment guards.

Module

  • Mooncake Store (mooncake-store)
  • Common (mooncake-common)

Type of Change

  • Refactor

How Has This Been Tested?

  • Full Linux build (GCC). s3_helper.cpp and spdk_wrapper.cpp are behind build options that were off; their changes are one-line call-site updates.
  • All 46 test binaries touched by this change, plus environ_test and standalone_client_test, pass on Linux.
  • Code behind build options this change touches compiles (-fsyntax-only) with
    USE_NOF (SPDK v23.01.1 headers), HAVE_AWS_SDK (AWS SDK 1.11 headers),
    USE_CUDA (GCC 11.4, CUDA 12.8) and USE_CXL.

Checklist

  • I have performed a self-review of my own code
  • I have formatted my code using ./scripts/code_format.sh
  • I have run pre-commit on the files changed in this PR and all hooks pass
  • I have added tests to prove my changes are effective

AI Assistance Disclosure

  • AI tools were used (specify below)

Claude Code (Claude Opus) assisted with the mechanical call-site and test migration. I reviewed every changed line.

kvcache-ai#3665 reads MOONCAKE_ENABLE_EMBEDDED_MASTER in real_client.cpp through
Environ::GetBool, and kvcache-ai#4401, merged after it, removed that static helper.
Each change built on its own branch, but main no longer compiles
mooncake_store.

Define MOONCAKE_ENABLE_EMBEDDED_MASTER in the environment variable catalog
and read it with Environ::Process().GetTypedOr(..., false). This keeps the
previous behavior: an unset value is false, the canonical boolean spellings
are accepted, and an invalid value warns and falls back to false.
Aionw added 2 commits October 8, 2026 20:25
…R registration

kvcache-ai#4329 reads MC_RDMA_DATA_DIRECT in RdmaTransport::registerLocalMemoryInternal
through Environ::Get().GetRdmaDataDirect(). kvcache-ai#4401, merged after it, removed
that accessor and moved the setting to GlobalConfig::rdma_data_direct. The
call is inside #ifdef USE_CUDA, so only CUDA builds fail.

Read globalConfig().rdma_data_direct, as rdma_context.cpp already does. Both
parse MC_RDMA_DATA_DIRECT with TryParseBool and fall back to false on an
invalid value.
Every Store config exposes a single FromEnvironment(const Environ& env, ...)
entry point. Production call sites pass Environ::Process(); these are the
places where a later change threads resolved configs from the process
entry point instead. Config tests inject a MapEnvironSource instead of
mutating the process environment; tests that exercise production paths
reading the process environment keep using setenv().

This removes the Read/ReadOr/GetDouble compatibility wrappers. Parsing,
defaults and diagnostics are unchanged.
@Aionw
Aionw force-pushed the refactor/environ-injectable-configs-v2 branch from 101ab4b to 24ffbb6 Compare October 8, 2026 12:35

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant