Skip to content

Commit 2dbf4aa

Browse files
committed
revert proc_id
1 parent c091864 commit 2dbf4aa

File tree

5 files changed

+5
-26
lines changed

5 files changed

+5
-26
lines changed

src/ai/backend/agent/agent.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ def __init__(
235235
distro: str,
236236
local_config: Mapping[str, Any],
237237
computers: MutableMapping[DeviceName, ComputerContext],
238-
proc_uid: int,
239238
restarting: bool = False,
240239
) -> None:
241240
self.image_labels = kernel_config["image"]["labels"]
@@ -254,7 +253,6 @@ def __init__(
254253
self.computers = computers
255254
self.restarting = restarting
256255
self.local_config = local_config
257-
self.proc_uid = proc_uid
258256

259257
@abstractmethod
260258
async def get_extra_envs(self) -> Mapping[str, str]:
@@ -575,7 +573,6 @@ def mount_static_binary(filename: str, target_path: str) -> None:
575573
already_injected_hooks.add(hook_path)
576574

577575
self.additional_allowed_syscalls = sorted(list(additional_allowed_syscalls_set))
578-
environ["ADDITIONAL_GIDS"] = ",".join(map(str, additional_gid_set))
579576
update_additional_gids(environ, additional_gids)
580577

581578
def get_overriding_uid(self) -> Optional[int]:
@@ -619,7 +616,6 @@ class AbstractAgent(
619616
computers: MutableMapping[DeviceName, ComputerContext]
620617
images: Mapping[str, str]
621618
port_pool: Set[int]
622-
proc_uid: int
623619

624620
redis: Redis
625621

@@ -675,7 +671,6 @@ def __init__(
675671
local_config["container"]["port-range"][1] + 1,
676672
)
677673
)
678-
self.proc_uid = os.geteuid()
679674
self.stats_monitor = stats_monitor
680675
self.error_monitor = error_monitor
681676
self._pending_creation_tasks = defaultdict(set)
@@ -1761,7 +1756,6 @@ async def init_kernel_context(
17611756
kernel_image: ImageRef,
17621757
kernel_config: KernelCreationConfig,
17631758
*,
1764-
proc_uid: int,
17651759
restarting: bool = False,
17661760
cluster_ssh_port_mapping: Optional[ClusterSSHPortMapping] = None,
17671761
) -> AbstractKernelCreationContext:
@@ -1888,7 +1882,6 @@ async def create_kernel(
18881882
kernel_image,
18891883
kernel_config,
18901884
restarting=restarting,
1891-
proc_uid=self.proc_uid,
18921885
cluster_ssh_port_mapping=cluster_info.get("cluster_ssh_port_mapping"),
18931886
)
18941887
environ: dict[str, str] = {**kernel_config["environ"]}
@@ -1911,10 +1904,10 @@ async def create_kernel(
19111904
if KernelFeatures.UID_MATCH in ctx.kernel_features:
19121905
environ["LOCAL_GROUP_ID"] = str(kernel_gid)
19131906

1914-
update_additional_gids(environ, sgids)
19151907
environ.update(
19161908
await ctx.get_extra_envs(),
19171909
)
1910+
update_additional_gids(environ, sgids)
19181911
image_labels = kernel_config["image"]["labels"]
19191912

19201913
agent_architecture = get_arch_name()

src/ai/backend/agent/docker/agent.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ def __init__(
211211
agent_sockpath: Path,
212212
resource_lock: asyncio.Lock,
213213
network_plugin_ctx: NetworkPluginContext,
214-
proc_uid: int,
215214
restarting: bool = False,
216215
cluster_ssh_port_mapping: Optional[ClusterSSHPortMapping] = None,
217216
gwbridge_subnet: Optional[str] = None,
@@ -226,7 +225,6 @@ def __init__(
226225
distro,
227226
local_config,
228227
computers,
229-
proc_uid=proc_uid,
230228
restarting=restarting,
231229
)
232230
scratch_dir = (self.local_config["container"]["scratch-root"] / str(kernel_id)).resolve()
@@ -303,7 +301,7 @@ async def prepare_resource_spec(self) -> Tuple[KernelResourceSpec, Optional[Mapp
303301
return resource_spec, resource_opts
304302

305303
def _chown(self, paths: Iterable[Path], uid: Optional[int], gid: Optional[int]) -> None:
306-
if self.proc_uid == 0: # only possible when I am root.
304+
if os.geteuid() == 0: # only possible when I am root.
307305
for p in paths:
308306
if KernelFeatures.UID_MATCH in self.kernel_features:
309307
_uid = uid if uid is not None else self.local_config["container"]["kernel-uid"]
@@ -1706,7 +1704,6 @@ async def init_kernel_context(
17061704
kernel_image: ImageRef,
17071705
kernel_config: KernelCreationConfig,
17081706
*,
1709-
proc_uid: int,
17101707
restarting: bool = False,
17111708
cluster_ssh_port_mapping: Optional[ClusterSSHPortMapping] = None,
17121709
) -> DockerKernelCreationContext:
@@ -1725,7 +1722,6 @@ async def init_kernel_context(
17251722
self.agent_sockpath,
17261723
self.resource_lock,
17271724
self.network_plugin_ctx,
1728-
proc_uid=proc_uid,
17291725
restarting=restarting,
17301726
cluster_ssh_port_mapping=cluster_ssh_port_mapping,
17311727
gwbridge_subnet=self.gwbridge_subnet,

src/ai/backend/agent/dummy/agent.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def __init__(
6262
distro: str,
6363
local_config: Mapping[str, Any],
6464
computers: MutableMapping[DeviceName, ComputerContext],
65-
proc_uid: int,
6665
restarting: bool = False,
6766
*,
6867
dummy_config: Mapping[str, Any],
@@ -77,7 +76,6 @@ def __init__(
7776
distro,
7877
local_config,
7978
computers,
80-
proc_uid=proc_uid,
8179
restarting=restarting,
8280
)
8381
self.dummy_config = dummy_config
@@ -322,7 +320,6 @@ async def init_kernel_context(
322320
kernel_image: ImageRef,
323321
kernel_config: KernelCreationConfig,
324322
*,
325-
proc_uid: int,
326323
restarting: bool = False,
327324
cluster_ssh_port_mapping: Optional[ClusterSSHPortMapping] = None,
328325
) -> DummyKernelCreationContext:
@@ -337,7 +334,6 @@ async def init_kernel_context(
337334
distro,
338335
self.local_config,
339336
self.computers,
340-
proc_uid=proc_uid,
341337
restarting=restarting,
342338
dummy_config=self.dummy_config,
343339
)

src/ai/backend/agent/kubernetes/agent.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ def __init__(
112112
computers: MutableMapping[DeviceName, ComputerContext],
113113
workers: Mapping[str, Mapping[str, str]],
114114
static_pvc_name: str,
115-
proc_uid: int,
116115
restarting: bool = False,
117116
) -> None:
118117
super().__init__(
@@ -125,7 +124,6 @@ def __init__(
125124
distro,
126125
local_config,
127126
computers,
128-
proc_uid=proc_uid,
129127
restarting=restarting,
130128
)
131129
scratch_dir = (self.local_config["container"]["scratch-root"] / str(kernel_id)).resolve()
@@ -1040,7 +1038,6 @@ async def init_kernel_context(
10401038
kernel_image: ImageRef,
10411039
kernel_config: KernelCreationConfig,
10421040
*,
1043-
proc_uid: int,
10441041
restarting: bool = False,
10451042
cluster_ssh_port_mapping: Optional[ClusterSSHPortMapping] = None,
10461043
) -> KubernetesKernelCreationContext:
@@ -1058,7 +1055,6 @@ async def init_kernel_context(
10581055
self.computers,
10591056
self.workers,
10601057
"backend-ai-static-pvc",
1061-
proc_uid=proc_uid,
10621058
restarting=restarting,
10631059
)
10641060

src/ai/backend/manager/registry.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,7 @@ async def create_session(
626626
{
627627
"uid": user_row.container_uid,
628628
"main_gid": user_row.container_main_gid,
629-
"supplementary_gids": (
630-
user_row.container_supplementary_gids or []
631-
),
629+
"supplementary_gids": (user_row.container_gids or []),
632630
"image_ref": image_ref,
633631
"cluster_role": DEFAULT_ROLE,
634632
"cluster_idx": 1,
@@ -1334,7 +1332,7 @@ async def enqueue_session(
13341332
),
13351333
"uid": kernel["uid"],
13361334
"main_gid": kernel["main_gid"],
1337-
"supplementary_gids": kernel["supplementary_gids"],
1335+
"gids": kernel["supplementary_gids"],
13381336
"image": image_ref.canonical,
13391337
# "image_id": image_row.id,
13401338
"architecture": image_ref.architecture,
@@ -1854,7 +1852,7 @@ def get_image_conf(kernel: KernelRow) -> ImageConfig:
18541852
"cluster_hostname": binding.kernel.cluster_hostname,
18551853
"uid": binding.kernel.uid,
18561854
"main_gid": binding.kernel.main_gid,
1857-
"supplementary_gids": binding.kernel.supplementary_gids or [],
1855+
"supplementary_gids": binding.kernel.gids or [],
18581856
"idle_timeout": int(idle_timeout),
18591857
"mounts": [item.to_json() for item in scheduled_session.vfolder_mounts],
18601858
"environ": {

0 commit comments

Comments
 (0)