Skip to content

Commit

Permalink
Place playground processes into a systemd slice
Browse files Browse the repository at this point in the history
This allows us to influence the OOM killer's behavior, hopefully
killing our processes instead of something more important to the
system.
  • Loading branch information
shepmaster committed Sep 21, 2023
1 parent 42b6ace commit 15dc1ac
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ansible/roles/playground/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
state: restarted
daemon_reload: true

- name: restart-containerd
systemd:
name: containerd
state: restarted
daemon_reload: true

- name: start-playground-update
systemd:
name: playground-update
Expand Down
25 changes: 25 additions & 0 deletions ansible/roles/playground/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
---

# Create a Systemd slice to manage resources (Memory, CPU) across the
# processes spawned by the playground.

- name: Configure playground slice
template:
src: playground.slice
dest: /etc/systemd/system/playground.slice
mode: 0644

# --------------------

- name: Add Docker APT repository GPG key
apt_key:
state: present
Expand Down Expand Up @@ -30,6 +41,20 @@
mode: 0600
notify: restart-docker

- name: Add Docker to the Playground slice
template:
src: docker-override.conf
dest: /etc/systemd/system/docker.service.d/override.conf
mode: 0600
notify: restart-docker

- name: Add ContainerD to the Playground slice
template:
src: containerd-override.conf
dest: /etc/systemd/system/containerd.service.d/override.conf
mode: 0600
notify: restart-containerd

# --------------------

# Set up a partition with limited space to avoid temporary
Expand Down
2 changes: 2 additions & 0 deletions ansible/roles/playground/templates/containerd-override.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Service]
Slice=playground.slice
1 change: 1 addition & 0 deletions ansible/roles/playground/templates/daemon.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"cgroup-parent": "playground.slice",
"storage-driver": "overlay2"
}
2 changes: 2 additions & 0 deletions ansible/roles/playground/templates/docker-override.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Service]
Slice=playground.slice
2 changes: 2 additions & 0 deletions ansible/roles/playground/templates/playground.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Description=The Rust Playground

[Service]
Slice=playground.slice

Restart=on-failure

Environment=TMPDIR={{ vars_playground_mountpoint_path }}
Expand Down
3 changes: 3 additions & 0 deletions ansible/roles/playground/templates/playground.slice
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[Unit]
Description=Resource management group for playground processes
Before=slices.target

0 comments on commit 15dc1ac

Please sign in to comment.