Skip to content

Commit 60f667c

Browse files
committed
fix(sidecar): enter dev cgroup namespace in ssh sessions
1 parent c62f9e0 commit 60f667c

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

infra/sidecar/entrypoint.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,23 @@ fi
6767
# If a remote command was requested, execute it inside the dev container.
6868
if [ -n "${SSH_ORIGINAL_COMMAND:-}" ]; then
6969
if nsenter --target "$DEV_PID" --mount -- test -x /bin/bash 2>/dev/null; then
70-
exec nsenter --target "$DEV_PID" --mount --uts --ipc --pid -- /bin/bash -lc "$SSH_ORIGINAL_COMMAND"
70+
exec nsenter --target "$DEV_PID" --mount --uts --ipc --pid --cgroup -- /bin/bash -lc "$SSH_ORIGINAL_COMMAND"
7171
else
72-
exec nsenter --target "$DEV_PID" --mount --uts --ipc --pid -- /bin/sh -lc "$SSH_ORIGINAL_COMMAND"
72+
exec nsenter --target "$DEV_PID" --mount --uts --ipc --pid --cgroup -- /bin/sh -lc "$SSH_ORIGINAL_COMMAND"
7373
fi
7474
fi
7575
7676
# If there is no TTY and no remote command (e.g. SSH master/control session),
7777
# keep the connection open so forwarding channels stay alive.
7878
if [ ! -t 0 ]; then
79-
exec nsenter --target "$DEV_PID" --mount --uts --ipc --pid -- /bin/sh -lc "while :; do sleep 3600; done"
79+
exec nsenter --target "$DEV_PID" --mount --uts --ipc --pid --cgroup -- /bin/sh -lc "while :; do sleep 3600; done"
8080
fi
8181
8282
# Run postAttach script for interactive sessions when present.
8383
if [ -n "${OKDEV_WORKSPACE_PATH:-}" ]; then
8484
POST_ATTACH="${OKDEV_WORKSPACE_PATH}/.okdev/post-attach.sh"
8585
if nsenter --target "$DEV_PID" --mount -- test -x "$POST_ATTACH" 2>/dev/null; then
86-
nsenter --target "$DEV_PID" --mount --uts --ipc --pid -- "$POST_ATTACH" 2>&1 || \
86+
nsenter --target "$DEV_PID" --mount --uts --ipc --pid --cgroup -- "$POST_ATTACH" 2>&1 || \
8787
echo "warning: postAttach script failed" >&2
8888
fi
8989
fi
@@ -102,17 +102,17 @@ if [ "${OKDEV_TMUX_FLAG:-}" = "1" ] && [ "${OKDEV_NO_TMUX:-}" != "1" ] && comman
102102
# process is killed by sshd, while the server keeps the session alive.
103103
if ! tmux has-session -t okdev 2>/dev/null; then
104104
if nsenter --target "$DEV_PID" --mount -- test -x /bin/bash 2>/dev/null; then
105-
tmux new-session -d -s okdev "nsenter --target $DEV_PID --mount --uts --ipc --pid -- /bin/bash -l"
105+
tmux new-session -d -s okdev "nsenter --target $DEV_PID --mount --uts --ipc --pid --cgroup -- /bin/bash -l"
106106
else
107-
tmux new-session -d -s okdev "nsenter --target $DEV_PID --mount --uts --ipc --pid -- /bin/sh -l"
107+
tmux new-session -d -s okdev "nsenter --target $DEV_PID --mount --uts --ipc --pid --cgroup -- /bin/sh -l"
108108
fi
109109
fi
110110
exec tmux attach-session -t okdev
111111
fi
112112
if nsenter --target "$DEV_PID" --mount -- test -x /bin/bash 2>/dev/null; then
113-
exec nsenter --target "$DEV_PID" --mount --uts --ipc --pid -- /bin/bash -l
113+
exec nsenter --target "$DEV_PID" --mount --uts --ipc --pid --cgroup -- /bin/bash -l
114114
else
115-
exec nsenter --target "$DEV_PID" --mount --uts --ipc --pid -- /bin/sh -l
115+
exec nsenter --target "$DEV_PID" --mount --uts --ipc --pid --cgroup -- /bin/sh -l
116116
fi
117117
SCRIPT
118118
safe_tmux_flag=$(printf '%s' "$OKDEV_TMUX_FLAG" | sed 's/[\/&]/\\&/g')

0 commit comments

Comments
 (0)