Skip to content

Commit 0809c3b

Browse files
authored
Merge pull request circleci#5043 from circleci/runner-no-cgroups
Drop systemd-run in favour of sudo -u
2 parents badf1bb + 44615a3 commit 0809c3b

File tree

1 file changed

+2
-36
lines changed

1 file changed

+2
-36
lines changed

jekyll/_cci2/runner-installation.adoc

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ api:
179179
auth_token: AUTH_TOKEN
180180
runner:
181181
name: RUNNER_NAME
182-
command_prefix: ["/opt/circleci/launch-task"]
182+
command_prefix: ["sudo", "-niHu", "circleci", "--"]
183183
working_directory: /opt/circleci/workdir/%s
184184
cleanup_working_directory: true
185185
```
@@ -195,7 +195,7 @@ sudo chmod 600 /opt/circleci/launch-agent-config.yaml
195195

196196
=== Create the circleci user & working directory
197197

198-
These will be used when executing the `build-agent`.
198+
These will be used when executing the task agent. These commands must be run as a user with permissions to create other users (e.g. `root`).
199199

200200
```bash
201201
id -u circleci &>/dev/null || adduser --uid 1500 --disabled-password --gecos GECOS circleci
@@ -204,40 +204,6 @@ mkdir -p /opt/circleci/workdir
204204
chown -R circleci /opt/circleci/workdir
205205
```
206206

207-
=== Install the launch script
208-
209-
This wrapper script will be used by launch agent to execute the task agent, while ensuring appropriate sandboxing and a clean shutdown.
210-
211-
Create `/opt/circleci/launch-task` owned by `root` with permissions `755`
212-
213-
```bash
214-
#!/bin/bash
215-
216-
set -euo pipefail
217-
218-
## This script launches the build-agent using systemd-run in order to create a
219-
## cgroup which will capture all child processes so they're cleaned up correctly
220-
## on exit.
221-
222-
# The user to run the build-agent as - must be numeric
223-
USER_ID=$(id -u circleci)
224-
225-
# Give the transient systemd unit an inteligible name
226-
unit="circleci-$CIRCLECI_LAUNCH_ID"
227-
228-
# When this process exits, tell the systemd unit to shut down
229-
abort() {
230-
if systemctl is-active --quiet "$unit"; then
231-
systemctl stop "$unit"
232-
fi
233-
}
234-
trap abort EXIT
235-
236-
systemd-run \
237-
--pipe --collect --quiet --wait \
238-
--uid "$USER_ID" --unit "$unit" -- "$@"
239-
```
240-
241207
=== Enable the `systemd` unit
242208

243209
Create `/opt/circleci/circleci.service` owned by `root` with permissions `755`.

0 commit comments

Comments
 (0)