Skip to content

Commit

Permalink
OCPQE-25546: Add timer service to cleanup podman unused resources (#81)
Browse files Browse the repository at this point in the history
Timer will run daily at 6 am

PR also updates logs and comments for deleting clusters older than `24h`
from previouly set `3 days`
  • Loading branch information
sgoveas authored Sep 11, 2024
1 parent cf4d330 commit 74a6367
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
6 changes: 3 additions & 3 deletions images/fcos-bastion-image/root/usr/bin/clean-up.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

echo "<3>Starting the clean up process"
echo "<2>Checking if any /var/builds/* folder container is older than 3 days and prune the related clusters"
# Check if any /var/builds/* folder container is older than 3 days
echo "<2>Checking if any /var/builds/* folder container is older than 24 hours and prune the related clusters"
# Check if any /var/builds/* folder container is older than 24 hours
while IFS= read -r -d '' cluster_folder
do
echo "<3>Deleting $cluster_folder"
Expand Down Expand Up @@ -33,7 +33,7 @@ do
[ "${enddate}" -le "${nowdate}" ] && \
echo "<3>$cluster no longer to be preserved"
fi
echo "<3>$cluster is more than 3 days old and not preserved, starting the pruning...."
echo "<3>$cluster is more than 24 hours old and not preserved, starting the pruning...."
prune_nodes "$cluster"
done < <(find /var/builds/ -maxdepth 1 -type d -mmin +1440 -print0)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
[Unit]
Description=Service does a clean up of clusters running more than 3 days
Description=Service does a clean up of clusters running more than 24 hours

[Service]
Type=oneshot
ExecStart=/usr/bin/clean-up.sh
StandardOutput=journal
StandardError=journal
Type=oneshot
RestartSec=10
Restart=on-failure

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Unit]
Description=Timer to prune cluster nodes running longer than 3 days
Description=Timer to prune cluster nodes running longer than 24 hour

[Timer]
OnCalendar=*-*-* *:02:00
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Service does a clean up of unused podman resources

[Service]
Type=oneshot
ExecStart=/usr/bin/podman system prune -af --volumes
StandardOutput=journal
StandardError=journal
RestartSec=10
Restart=on-failure
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=Timer to daily prune unused podman resources

[Timer]
OnCalendar=*-*-* 06:00:00

[Install]
WantedBy=timers.target

0 comments on commit 74a6367

Please sign in to comment.