Skip to content

Commit

Permalink
clean registry when disk util over 40 percent
Browse files Browse the repository at this point in the history
  • Loading branch information
zniu1011 committed Sep 13, 2024
1 parent 74a6367 commit 789b38c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion images/fcos-bastion-image/root/usr/bin/clean-registries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ wait_for_container_running() {
mapfile -t ports < <(systemctl list-units 'registry@*' --no-pager --quiet | awk -F'[@.]' '{print $2}')
for port in "${ports[@]}"; do
disk_use=$(df /opt/registry-"${port}" --output='pcent' | grep -o '[0-9]*')
if [ "$disk_use" -gt 85 ]; then
if [ "$disk_use" -gt 60 ]; then
rm -rf /opt/registry-"${port}"/data/docker/registry/v2/repositories/*
fi
if [ "$disk_use" -gt 50 ]; then
sed -i -e '/readonly/{n;s/enabled:.*/enabled: true/;}' /opt/registry-"${port}"/config.yaml
systemctl restart registry@"${port}".service
wait_for_container_running registry-"${port}"
Expand Down
3 changes: 3 additions & 0 deletions images/fcos-bastion-image/root/usr/bin/gen_registry_file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ storage:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/registry
maintenance:
readonly:
enabled: false
auth:
htpasswd:
realm: Registry Realm
Expand Down

0 comments on commit 789b38c

Please sign in to comment.