Skip to content

[Store] Single Go HA-wrapper for etcd+k8s#2643

Open
vladnosiv wants to merge 1 commit into
kvcache-ai:mainfrom
vladnosiv:simplify-build-of-ha-backends
Open

[Store] Single Go HA-wrapper for etcd+k8s#2643
vladnosiv wants to merge 1 commit into
kvcache-ai:mainfrom
vladnosiv:simplify-build-of-ha-backends

Conversation

@vladnosiv

@vladnosiv vladnosiv commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Description

Currently, the HA etcd and k8s backends are mutually exclusive when building, as they are two different Go modules that must be separated for a single go runtime.

This creates a strong UX problem: the pip package must have different versions for different HA backends. This makes it extremely difficult to use the k8s HA backend when integrating with SGLang/vLLM.

It is proposed to combine 2 Go modules into one HA-wrapper module, in this case, when building, work with different HA-backends will be available. Redis-backend uses C++, so there is no such problem.

A large part of the diff appeared due to pre-commit hooks on CMakeLists.txt

Module

  • Transfer Engine (mooncake-transfer-engine)
  • Mooncake Store (mooncake-store)
  • Mooncake EP (mooncake-ep)
  • Mooncake PG (mooncake-pg)
  • Integration (mooncake-integration)
  • P2P Store (mooncake-p2p-store)
  • Python Wheel (mooncake-wheel)
  • Common (mooncake-common)
  • Mooncake RL (mooncake-rl)
  • CI/CD
  • Docs
  • Other

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Breaking change
  • Documentation update
  • Performance improvement
  • Other

How Has This Been Tested?

Test commands:

# Example: bash scripts/run_ci_test.sh

Test results:

  • Unit tests pass
  • Integration tests pass (if applicable)
  • Manual testing done (describe below)

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 run --all-files and all hooks pass
  • I have updated the documentation (if applicable)
  • I have added tests to prove my changes are effective
  • For changes >500 LOC: I have filed an RFC issue

AI Assistance Disclosure

  • No AI tools were used
  • AI tools were used (specify below)

Signed-off-by: Vladislav Nosivskoy <vladnosiv@gmail.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request consolidates the separate Go-based HA wrappers for etcd and Kubernetes lease into a single unified Go HA wrapper library under mooncake-common/ha-wrapper, updating the CMake build configurations, scripts, and bindings across the repository. Feedback on these changes suggests removing go mod tidy from the CMake build phase to support offline builds, committing the missing go.sum file, and downgrading the Go toolchain version in go.mod from the non-existent 1.25.0 to a stable release like 1.24.0 to avoid compilation failures.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +1 to +14
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libmooncake_ha_wrapper.so
${CMAKE_CURRENT_BINARY_DIR}/libmooncake_ha_wrapper.h
COMMAND bash -c "go mod tidy"
COMMAND
bash -c
"go build -buildmode=c-shared -o ${CMAKE_CURRENT_BINARY_DIR}/libmooncake_ha_wrapper.so etcd_wrapper.go k8s_lease_wrapper.go"
COMMAND
${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_BINARY_DIR}/libmooncake_ha_wrapper.h
${CMAKE_CURRENT_SOURCE_DIR}/libmooncake_ha_wrapper.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Building unified Go HA wrapper"
DEPENDS etcd_wrapper.go k8s_lease_wrapper.go go.mod)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Running go mod tidy during the CMake build phase is an anti-pattern. It requires internet access to fetch dependencies, which will fail in offline or restricted build environments (e.g., secure CI/CD, hermetic package builds). It also modifies the source directory during the build, violating the out-of-source build principle. go mod tidy should be run manually by developers during development, and the resulting go.sum should be committed to the repository.\n\nAdditionally, using bash -c to execute go build is unnecessary and reduces portability. Since CMake executes multiple COMMAND arguments sequentially, you can invoke go directly.

add_custom_command(\n  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libmooncake_ha_wrapper.so\n         ${CMAKE_CURRENT_BINARY_DIR}/libmooncake_ha_wrapper.h\n  COMMAND\n    go build -buildmode=c-shared -o ${CMAKE_CURRENT_BINARY_DIR}/libmooncake_ha_wrapper.so etcd_wrapper.go k8s_lease_wrapper.go\n  COMMAND\n    ${CMAKE_COMMAND} -E copy\n    ${CMAKE_CURRENT_BINARY_DIR}/libmooncake_ha_wrapper.h\n    ${CMAKE_CURRENT_SOURCE_DIR}/libmooncake_ha_wrapper.h\n  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}\n  COMMENT "Building unified Go HA wrapper"\n  DEPENDS etcd_wrapper.go k8s_lease_wrapper.go go.mod)

@@ -0,0 +1,68 @@
module github.com/kvcache-ai/Mooncake/mooncake-common/ha-wrapper

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The go.sum file is missing from the mooncake-common/ha-wrapper directory. In Go projects, it is best practice to commit go.sum alongside go.mod to ensure reproducible builds and dependency verification. Please run go mod tidy locally and commit the resulting go.sum file.

Comment on lines +3 to +5
go 1.25.0

toolchain go1.25.10

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Go 1.25.0 is not a released version of Go (the current latest stable release is Go 1.24). Specifying go 1.25.0 and toolchain go1.25.10 in go.mod will cause compilation failures for developers using standard Go toolchains. It is recommended to downgrade this to a stable, widely available version such as go 1.24.0.

go 1.24.0\n\ntoolchain go1.24.0

@alogfans

Copy link
Copy Markdown
Collaborator

A good contribution! However, you may first check CI for build problems.

@ykwd ykwd requested a review from Icedcoco June 29, 2026 02:54
@Icedcoco

Copy link
Copy Markdown
Collaborator

Thanks for working on this. The direction makes sense to me; having one Go HA wrapper for both etcd and k8s should make the wheel story much easier.

One thing I noticed is that the Rust binding path still seems to look for the old wrapper name. In mooncake-store/rust/build.rs, the optional library detection still checks etcd_wrapper, while this PR now builds libmooncake_ha_wrapper.so. The current CI failures also look related to that path: the Rust test link step reports unresolved symbols such as NewEtcdClient and EtcdStore*Wrapper. Could you check whether build.rs should be updated to link mooncake_ha_wrapper instead?

I also wonder if we should avoid running go mod tidy from the CMake build step. Since the new ha-wrapper module has go.mod but no committed go.sum, the build may depend on network/module-cache state and can also modify the source tree during a normal build. Would it be better to commit the generated go.sum and let CMake only run go build?

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.

3 participants