feat: set ownerReference on ModelMetadata CRs for automatic GC on pod deletion#507
feat: set ownerReference on ModelMetadata CRs for automatic GC on pod deletion#507omerap12 wants to merge 7 commits into
Conversation
WalkthroughMetadata publishing now carries optional Kubernetes pod name and UID values from environment variables through Python and gRPC APIs into server backends. The Kubernetes backend uses both values to set ChangesKubernetes Pod Metadata Propagation
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
modelexpress_server/src/p2p/service.rs (1)
433-455: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winExercise the pod identity propagation contract end to end.
The updated test seams accept the new fields but either discard them, pass empty values, or ignore them in assertions, allowing propagation regressions to pass.
modelexpress_server/src/p2p/service.rs#L433-L455: send non-empty pod fields and assert the backend receives both.modelexpress_client/python/tests/test_artifact_transfer.py#L1266-L1266: retainpod_nameandpod_uidon_FakeMxClientfor assertions.modelexpress_server/src/p2p/state.rs#L462-L485: assert both values reachMetadataBackend.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@modelexpress_server/src/p2p/service.rs` around lines 433 - 455, Strengthen the pod identity propagation tests: in modelexpress_server/src/p2p/service.rs:433-455, update test_publish_metadata_success to send non-empty pod name and UID values and assert both are received by the backend; in modelexpress_client/python/tests/test_artifact_transfer.py:1266, retain pod_name and pod_uid on _FakeMxClient for assertions; in modelexpress_server/src/p2p/state.rs:462-485, assert both values reach MetadataBackend.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@modelexpress_server/src/p2p/backend/kubernetes.rs`:
- Around line 226-239: Update the publish/update flow surrounding
owner_references so an existing custom resource receives the Pod OwnerReference
whenever both pod name and UID are available, not only during initial creation.
Reuse the existing has_pod_name_and_uid condition and preserve None when either
value is absent, ensuring metadata is patched for previously unowned resources.
---
Outside diff comments:
In `@modelexpress_server/src/p2p/service.rs`:
- Around line 433-455: Strengthen the pod identity propagation tests: in
modelexpress_server/src/p2p/service.rs:433-455, update
test_publish_metadata_success to send non-empty pod name and UID values and
assert both are received by the backend; in
modelexpress_client/python/tests/test_artifact_transfer.py:1266, retain pod_name
and pod_uid on _FakeMxClient for assertions; in
modelexpress_server/src/p2p/state.rs:462-485, assert both values reach
MetadataBackend.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 3b176d7c-e631-4922-aed9-79d81ecc1b87
📒 Files selected for processing (14)
modelexpress_client/python/modelexpress/client.pymodelexpress_client/python/modelexpress/envs.pymodelexpress_client/python/modelexpress/metadata/k8s_service_client.pymodelexpress_client/python/modelexpress/metadata/publish.pymodelexpress_client/python/modelexpress/p2p_pb2.pymodelexpress_client/python/tests/test_artifact_transfer.pymodelexpress_common/proto/p2p.protomodelexpress_common/src/envs.rsmodelexpress_server/src/p2p/backend.rsmodelexpress_server/src/p2p/backend/kubernetes.rsmodelexpress_server/src/p2p/backend/memory.rsmodelexpress_server/src/p2p/backend/redis.rsmodelexpress_server/src/p2p/service.rsmodelexpress_server/src/p2p/state.rs
0d01b02 to
7dcee69
Compare
… deletion Signed-off-by: Omer Aplatony <omerap12@gmail.com>
Signed-off-by: Omer Aplatony <omerap12@gmail.com>
Signed-off-by: Zheng Luo <zheluo@nvidia.com>
7dcee69 to
ebdb78a
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Signed-off-by: Zheng Luo <zheluo@nvidia.com>
|
/ok to test df84eee |
zhengluo-nv
left a comment
There was a problem hiding this comment.
Do not merge, waiting for final review
Overview
This PR associates Kubernetes-backed
ModelMetadatarecords with the Pod thatpublished them. When a client provides a complete same-namespace Pod identity,
the Kubernetes metadata backend adds a Pod
ownerReference, allowing Kubernetesto garbage-collect the metadata immediately when that Pod is deleted.
The change applies to every engine and metadata type that uses the shared
PublishMetadatapath, including weight and artifact metadata.What changed
pod_name,pod_uid, andpod_namespacefields toPublishMetadataRequest.POD_NAME,POD_UID,and
POD_NAMESPACE.ModelMetadataCRs for complete same-namespace identities;metadata publication.
ModelMetadata-> tensorConfigMapownership chain,so deleting a Pod collects both the CR and its tensor metadata.
manifests.
Compatibility
The protobuf fields are additive. MX 0.4.0 and other older clients omit them and
continue publishing metadata without a Pod owner reference. Missing, partial,
or cross-namespace identity also preserves this fallback behavior. Redis,
in-memory, and non-Kubernetes environments ignore the Pod fields and continue
using the existing heartbeat/reaper lifecycle.
Validation
Local and CI-equivalent checks
origin/mainmerge focused client/SGLang tests: 44 passedKubernetes E2E
Tested in namespace
zhengon a B200 node with the Kubernetes metadata backend,an isolated server built from this PR, the shared model PVC, and
Qwen/Qwen2.5-0.5B. Source and target ran on the same node; this validates thecomplete Kubernetes lifecycle and NIXL/UCX P2P path, but is not a cross-node RDMA
benchmark.
/v1/modelssucceeded; completion returnedParis/v1/modelssucceeded; completion returnedParisFor both engines:
ModelMetadataCRs;Kubernetes owner garbage collection;
ModelMetadataCRs were manually deleted.The live E2E run exercised weight metadata. Artifact metadata uses the same
PublishMetadataownership path, but artifact transfer was not run as a separateE2E case in this validation.