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

OCPQE-20708 : clean registry when disk util over 50 percent #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions images/fcos-bastion-image/root/usr/bin/clean-registries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@ 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
rm -rf /opt/registry-"${port}"/data/docker/registry/v2/repositories/*
if [ "$disk_use" -gt 50 ]; then
for dir in `find /opt/registry-"${port}"/data/docker/registry/v2/repositories/ -maxdepth 1 -type d -mtime +1`; do
find ${dir}/release/_manifests/tags/ -name link -type f -exec rm -f {} \;
done
sed -i -e '/delete/{n;s/enabled:.*/enabled: true/;}' /opt/registry-"${port}"/config.yaml
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}"
podman exec registry-"${port}" /bin/registry garbage-collect /etc/docker/registry/config.yml
sed -i -e '/delete/{n;s/enabled:.*/enabled: false/;}' /opt/registry-"${port}"/config.yaml
sed -i -e '/readonly/{n;s/enabled:.*/enabled: false/;}' /opt/registry-"${port}"/config.yaml
systemctl restart registry@"${port}".service
for dir in `find /opt/registry-"${port}"/data/docker/registry/v2/repositories/ -maxdepth 1 -type d -mtime +1`; do
rm -rf ${dir}
done
fi
done

Expand Down
5 changes: 4 additions & 1 deletion images/fcos-bastion-image/root/usr/bin/gen_registry_file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ http:
key: /certs/domain.key
storage:
delete:
enabled: true
enabled: false
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/registry
maintenance:
readonly:
enabled: false
auth:
htpasswd:
realm: Registry Realm
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[Unit]
Description=Timer to cleanup mirrored registries caches on boot
Description=Timer to cleanup mirrored registries caches on boot and 6 hours once
[Timer]
OnBootSec=5min
OnCalendar=*-*-* *:00:00
OnCalendar=*-*-* */6:00:00

[Install]
WantedBy=timers.target