Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tasks: Regularly clean up leftover containers and outdated images #630

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ansible/aws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ If you run more than one at a time, set a custom host name with `-e hostname=coc

Webhook setup
-------------
AWS runs our primary webhook. Deploy or update it with:
Our primary webhook runs in CentOS CI. If that goes down, we can bring up a
fallback in AWS. Deploy or update it with:

ansible-playbook -i inventory aws/launch-webhook.yml

Expand Down
9 changes: 9 additions & 0 deletions ansible/roles/tasks-systemd/cockpituous-janitor.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Clean up cockpituous cruft

[Service]
Type=oneshot
# remove leftover containers
ExecStart=/bin/sh -ec 'podman ps -q --filter status=exited | xargs -r podman rm'
# remove old task images
ExecStart=/usr/bin/podman image prune --all --force
7 changes: 7 additions & 0 deletions ansible/roles/tasks-systemd/cockpituous-janitor.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Unit]
Description=Regularly clean up cockpituous cruft

[Timer]
OnBootSec=1h
OnUnitActiveSec=24h
AccuracySec=15min
12 changes: 12 additions & 0 deletions ansible/roles/tasks-systemd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@
'--env=COCKPIT_GITHUB_TOKEN_FILE=/run/secrets/github-token',
]

- name: Create janitor service
copy:
src: "{{ role_path }}/cockpituous-janitor.service"
dest: /etc/systemd/system/cockpituous-janitor.service
mode: preserve

- name: Create janitor timer
copy:
src: "{{ role_path }}/cockpituous-janitor.timer"
dest: /etc/systemd/system/cockpituous-janitor.timer
mode: preserve

- name: Set up systemd service for cockpit/tasks
shell: |
export INSTANCES={{ instances | default(1) }}
Expand Down
1 change: 1 addition & 0 deletions tasks/install-service
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ cat <<EOF > /etc/systemd/system/[email protected]
Description=Cockpit Tasks %i
Requires=podman.socket
After=podman.socket
Wants=cockpituous-janitor.timer

[Service]
Restart=always
Expand Down