mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-25 01:15:58 +00:00
fix(sandbox): scope provisioner PVC data by user (#2973)
* fix(sandbox): scope provisioner PVC data by user * Address provisioner PVC review feedback
This commit is contained in:
@@ -92,12 +92,19 @@ class TestBuildVolumeMounts:
|
||||
userdata_mount = mounts[1]
|
||||
assert userdata_mount.sub_path is None
|
||||
|
||||
def test_pvc_sets_subpath(self, provisioner_module):
|
||||
"""PVC mode should set sub_path to threads/{thread_id}/user-data."""
|
||||
def test_pvc_sets_user_scoped_subpath(self, provisioner_module):
|
||||
"""PVC mode should include user_id in the user-data subPath."""
|
||||
provisioner_module.USERDATA_PVC_NAME = "my-pvc"
|
||||
mounts = provisioner_module._build_volume_mounts("thread-42", user_id="user-7")
|
||||
userdata_mount = mounts[1]
|
||||
assert userdata_mount.sub_path == "deer-flow/users/user-7/threads/thread-42/user-data"
|
||||
|
||||
def test_pvc_defaults_to_default_user_subpath(self, provisioner_module):
|
||||
"""Older callers should still land under a stable default user namespace."""
|
||||
provisioner_module.USERDATA_PVC_NAME = "my-pvc"
|
||||
mounts = provisioner_module._build_volume_mounts("thread-42")
|
||||
userdata_mount = mounts[1]
|
||||
assert userdata_mount.sub_path == "threads/thread-42/user-data"
|
||||
assert userdata_mount.sub_path == "deer-flow/users/default/threads/thread-42/user-data"
|
||||
|
||||
def test_skills_mount_read_only(self, provisioner_module):
|
||||
"""Skills mount should always be read-only."""
|
||||
@@ -146,13 +153,12 @@ class TestBuildPodVolumes:
|
||||
pod = provisioner_module._build_pod("sandbox-1", "thread-1")
|
||||
assert len(pod.spec.containers[0].volume_mounts) == 2
|
||||
|
||||
def test_pod_pvc_mode(self, provisioner_module):
|
||||
"""Pod should use PVC volumes when PVC names are configured."""
|
||||
def test_pod_pvc_mode_uses_user_scoped_subpath(self, provisioner_module):
|
||||
"""Pod should use a user-scoped subPath for PVC user-data."""
|
||||
provisioner_module.SKILLS_PVC_NAME = "skills-pvc"
|
||||
provisioner_module.USERDATA_PVC_NAME = "userdata-pvc"
|
||||
pod = provisioner_module._build_pod("sandbox-1", "thread-1")
|
||||
pod = provisioner_module._build_pod("sandbox-1", "thread-1", user_id="user-7")
|
||||
assert pod.spec.volumes[0].persistent_volume_claim is not None
|
||||
assert pod.spec.volumes[1].persistent_volume_claim is not None
|
||||
# subPath should be set on user-data mount
|
||||
userdata_mount = pod.spec.containers[0].volume_mounts[1]
|
||||
assert userdata_mount.sub_path == "threads/thread-1/user-data"
|
||||
assert userdata_mount.sub_path == "deer-flow/users/user-7/threads/thread-1/user-data"
|
||||
|
||||
Reference in New Issue
Block a user